diff options
Diffstat (limited to 'gcc/jit')
-rw-r--r-- | gcc/jit/docs/cp/intro/tutorial04.rst | 73 | ||||
-rw-r--r-- | gcc/jit/docs/intro/tutorial04.rst | 73 | ||||
-rw-r--r-- | gcc/jit/docs/intro/tutorial05.rst | 37 | ||||
-rw-r--r-- | gcc/jit/docs/topics/compilation.rst | 22 | ||||
-rw-r--r-- | gcc/jit/docs/topics/expressions.rst | 97 | ||||
-rw-r--r-- | gcc/jit/docs/topics/types.rst | 111 |
6 files changed, 270 insertions, 143 deletions
diff --git a/gcc/jit/docs/cp/intro/tutorial04.rst b/gcc/jit/docs/cp/intro/tutorial04.rst index 45198ce..66dcce9 100644 --- a/gcc/jit/docs/cp/intro/tutorial04.rst +++ b/gcc/jit/docs/cp/intro/tutorial04.rst @@ -50,30 +50,55 @@ Naturally, a real interpreter would be much more complicated that this. The following operations are supported: -====================== ======================== =============== ============== -Operation Meaning Old Stack New Stack -====================== ======================== =============== ============== -DUP Duplicate top of stack. ``[..., x]`` ``[..., x, x]`` -ROT Swap top two elements ``[..., x, y]`` ``[..., y, x]`` - of stack. -BINARY_ADD Add the top two elements ``[..., x, y]`` ``[..., (x+y)]`` - on the stack. -BINARY_SUBTRACT Likewise, but subtract. ``[..., x, y]`` ``[..., (x-y)]`` -BINARY_MULT Likewise, but multiply. ``[..., x, y]`` ``[..., (x*y)]`` -BINARY_COMPARE_LT Compare the top two ``[..., x, y]`` ``[..., (x<y)]`` - elements on the stack - and push a nonzero/zero - if (x<y). -RECURSE Recurse, passing the top ``[..., x]`` ``[..., fn(x)]`` - of the stack, and - popping the result. -RETURN Return the top of the ``[x]`` ``[]`` - stack. -PUSH_CONST `arg` Push an int const. ``[...]`` ``[..., arg]`` -JUMP_ABS_IF_TRUE `arg` Pop; if top of stack was ``[..., x]`` ``[...]`` - nonzero, jump to - ``arg``. -====================== ======================== =============== ============== +.. list-table:: + :header-rows: 1 + :widths: 35 50 25 25 + + * - Operation + - Meaning + - Old Stack + - New Stack + + * - DUP + - Duplicate top of stack. + - ``[..., x]`` + - ``[..., x, x]`` + * - ROT + - Swap top two elements of stack. + - ``[..., x, y]`` + - ``[..., y, x]`` + * - BINARY_ADD + - Add the top two elements on the stack. + - ``[..., x, y]`` + - ``[..., (x+y)]`` + * - BINARY_SUBTRACT + - Likewise, but subtract. + - ``[..., x, y]`` + - ``[..., (x-y)]`` + * - BINARY_MULT + - Likewise, but multiply. + - ``[..., x, y]`` + - ``[..., (x*y)]`` + * - BINARY_COMPARE_LT + - Compare the top two elements on the stack and push a nonzero/zero if (x<y). + - ``[..., x, y]`` + - ``[..., (x<y)]`` + * - RECURSE + - Recurse, passing the top of the stack, and popping the result. + - ``[..., x]`` + - ``[..., fn(x)]`` + * - RETURN + - Return the top of the stack. + - ``[x]`` + - ``[]`` + * - PUSH_CONST `arg` + - Push an int const. + - ``[...]`` + - ``[..., arg]`` + * - JUMP_ABS_IF_TRUE `arg` + - Pop; if top of stack was nonzero, jump to ``arg``. + - ``[..., x]`` + - ``[...]`` Programs can be interpreted, disassembled, and compiled to machine code. diff --git a/gcc/jit/docs/intro/tutorial04.rst b/gcc/jit/docs/intro/tutorial04.rst index 8909887..c2e3fb5c0 100644 --- a/gcc/jit/docs/intro/tutorial04.rst +++ b/gcc/jit/docs/intro/tutorial04.rst @@ -48,30 +48,55 @@ Naturally, a real interpreter would be much more complicated that this. The following operations are supported: -====================== ======================== =============== ============== -Operation Meaning Old Stack New Stack -====================== ======================== =============== ============== -DUP Duplicate top of stack. ``[..., x]`` ``[..., x, x]`` -ROT Swap top two elements ``[..., x, y]`` ``[..., y, x]`` - of stack. -BINARY_ADD Add the top two elements ``[..., x, y]`` ``[..., (x+y)]`` - on the stack. -BINARY_SUBTRACT Likewise, but subtract. ``[..., x, y]`` ``[..., (x-y)]`` -BINARY_MULT Likewise, but multiply. ``[..., x, y]`` ``[..., (x*y)]`` -BINARY_COMPARE_LT Compare the top two ``[..., x, y]`` ``[..., (x<y)]`` - elements on the stack - and push a nonzero/zero - if (x<y). -RECURSE Recurse, passing the top ``[..., x]`` ``[..., fn(x)]`` - of the stack, and - popping the result. -RETURN Return the top of the ``[x]`` ``[]`` - stack. -PUSH_CONST `arg` Push an int const. ``[...]`` ``[..., arg]`` -JUMP_ABS_IF_TRUE `arg` Pop; if top of stack was ``[..., x]`` ``[...]`` - nonzero, jump to - ``arg``. -====================== ======================== =============== ============== +.. list-table:: + :header-rows: 1 + :widths: 35 50 25 25 + + * - Operation + - Meaning + - Old Stack + - New Stack + + * - DUP + - Duplicate top of stack. + - ``[..., x]`` + - ``[..., x, x]`` + * - ROT + - Swap top two elements of stack. + - ``[..., x, y]`` + - ``[..., y, x]`` + * - BINARY_ADD + - Add the top two elements on the stack. + - ``[..., x, y]`` + - ``[..., (x+y)]`` + * - BINARY_SUBTRACT + - Likewise, but subtract. + - ``[..., x, y]`` + - ``[..., (x-y)]`` + * - BINARY_MULT + - Likewise, but multiply. + - ``[..., x, y]`` + - ``[..., (x*y)]`` + * - BINARY_COMPARE_LT + - Compare the top two elements on the stack and push a nonzero/zero if (x<y). + - ``[..., x, y]`` + - ``[..., (x<y)]`` + * - RECURSE + - Recurse, passing the top of the stack, and popping the result. + - ``[..., x]`` + - ``[..., fn(x)]`` + * - RETURN + - Return the top of the stack. + - ``[x]`` + - ``[]`` + * - PUSH_CONST `arg` + - Push an int const. + - ``[...]`` + - ``[..., arg]`` + * - JUMP_ABS_IF_TRUE `arg` + - Pop; if top of stack was nonzero, jump to ``arg``. + - ``[..., x]`` + - ``[...]`` Programs can be interpreted, disassembled, and compiled to machine code. diff --git a/gcc/jit/docs/intro/tutorial05.rst b/gcc/jit/docs/intro/tutorial05.rst index 5f3ed28..b977d1d 100644 --- a/gcc/jit/docs/intro/tutorial05.rst +++ b/gcc/jit/docs/intro/tutorial05.rst @@ -42,19 +42,30 @@ within the array. brainf is hard for humans to read, but it's trivial to write a parser for it, as there is no lexing; just a stream of bytes. The operations are: -====================== ============================= -Character Meaning -====================== ============================= -``>`` ``idx += 1`` -``<`` ``idx -= 1`` -``+`` ``data[idx] += 1`` -``-`` ``data[idx] -= 1`` -``.`` ``output (data[idx])`` -``,`` ``data[idx] = input ()`` -``[`` loop until ``data[idx] == 0`` -``]`` end of loop -Anything else ignored -====================== ============================= +.. list-table:: + :header-rows: 1 + + * - Character + - Meaning + + * - ``>`` + - ``idx += 1`` + * - ``<`` + - ``idx -= 1`` + * - ``+`` + - ``data[idx] += 1`` + * - ``-`` + - ``data[idx] -= 1`` + * - ``.`` + - ``output (data[idx])`` + * - ``,`` + - ``data[idx] = input ()`` + * - ``[`` + - loop until ``data[idx] == 0`` + * - ``]`` + - end of loop + * - Anything else + - ignored Unlike the previous example, we'll implement an ahead-of-time compiler, which reads ``.bf`` scripts and outputs executables (though it would diff --git a/gcc/jit/docs/topics/compilation.rst b/gcc/jit/docs/topics/compilation.rst index 91b9c25..adcde8d 100644 --- a/gcc/jit/docs/topics/compilation.rst +++ b/gcc/jit/docs/topics/compilation.rst @@ -169,14 +169,20 @@ For linking in object files, use :c:func:`gcc_jit_context_add_driver_option`. The available kinds of output are: -============================================== ============== -Output kind Typical suffix -============================================== ============== -:c:macro:`GCC_JIT_OUTPUT_KIND_ASSEMBLER` .s -:c:macro:`GCC_JIT_OUTPUT_KIND_OBJECT_FILE` .o -:c:macro:`GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY` .so or .dll -:c:macro:`GCC_JIT_OUTPUT_KIND_EXECUTABLE` None, or .exe -============================================== ============== +.. list-table:: + :header-rows: 1 + + * - Output kind + - Typical suffix + + * - :c:macro:`GCC_JIT_OUTPUT_KIND_ASSEMBLER` + - .s + * - :c:macro:`GCC_JIT_OUTPUT_KIND_OBJECT_FILE` + - .o + * - :c:macro:`GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY` + - .so or .dll + * - :c:macro:`GCC_JIT_OUTPUT_KIND_EXECUTABLE` + - None, or .exe .. c:macro:: GCC_JIT_OUTPUT_KIND_ASSEMBLER diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index 00e2ec8..ff1eec8 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -313,14 +313,20 @@ Unary Operations The available unary operations are: -========================================== ============ -Unary Operation C equivalent -========================================== ============ -:c:macro:`GCC_JIT_UNARY_OP_MINUS` `-(EXPR)` -:c:macro:`GCC_JIT_UNARY_OP_BITWISE_NEGATE` `~(EXPR)` -:c:macro:`GCC_JIT_UNARY_OP_LOGICAL_NEGATE` `!(EXPR)` -:c:macro:`GCC_JIT_UNARY_OP_ABS` `abs (EXPR)` -========================================== ============ +.. list-table:: + :header-rows: 1 + + * - Unary Operation + - C equivalent + + * - :c:macro:`GCC_JIT_UNARY_OP_MINUS` + - `-(EXPR)` + * - :c:macro:`GCC_JIT_UNARY_OP_BITWISE_NEGATE` + - `~(EXPR)` + * - :c:macro:`GCC_JIT_UNARY_OP_LOGICAL_NEGATE` + - `!(EXPR)` + * - :c:macro:`GCC_JIT_UNARY_OP_ABS` + - `abs (EXPR)` .. c:macro:: GCC_JIT_UNARY_OP_MINUS @@ -380,22 +386,36 @@ Binary Operations The available binary operations are: -======================================== ============ -Binary Operation C equivalent -======================================== ============ -:c:macro:`GCC_JIT_BINARY_OP_PLUS` `x + y` -:c:macro:`GCC_JIT_BINARY_OP_MINUS` `x - y` -:c:macro:`GCC_JIT_BINARY_OP_MULT` `x * y` -:c:macro:`GCC_JIT_BINARY_OP_DIVIDE` `x / y` -:c:macro:`GCC_JIT_BINARY_OP_MODULO` `x % y` -:c:macro:`GCC_JIT_BINARY_OP_BITWISE_AND` `x & y` -:c:macro:`GCC_JIT_BINARY_OP_BITWISE_XOR` `x ^ y` -:c:macro:`GCC_JIT_BINARY_OP_BITWISE_OR` `x | y` -:c:macro:`GCC_JIT_BINARY_OP_LOGICAL_AND` `x && y` -:c:macro:`GCC_JIT_BINARY_OP_LOGICAL_OR` `x || y` -:c:macro:`GCC_JIT_BINARY_OP_LSHIFT` `x << y` -:c:macro:`GCC_JIT_BINARY_OP_RSHIFT` `x >> y` -======================================== ============ +.. list-table:: + :header-rows: 1 + + * - Binary Operation + - C equivalent + + * - :c:macro:`GCC_JIT_BINARY_OP_PLUS` + - `x + y` + * - :c:macro:`GCC_JIT_BINARY_OP_MINUS` + - `x - y` + * - :c:macro:`GCC_JIT_BINARY_OP_MULT` + - `x * y` + * - :c:macro:`GCC_JIT_BINARY_OP_DIVIDE` + - `x / y` + * - :c:macro:`GCC_JIT_BINARY_OP_MODULO` + - `x % y` + * - :c:macro:`GCC_JIT_BINARY_OP_BITWISE_AND` + - `x & y` + * - :c:macro:`GCC_JIT_BINARY_OP_BITWISE_XOR` + - `x ^ y` + * - :c:macro:`GCC_JIT_BINARY_OP_BITWISE_OR` + - `x | y` + * - :c:macro:`GCC_JIT_BINARY_OP_LOGICAL_AND` + - `x && y` + * - :c:macro:`GCC_JIT_BINARY_OP_LOGICAL_OR` + - `x || y` + * - :c:macro:`GCC_JIT_BINARY_OP_LSHIFT` + - `x << y` + * - :c:macro:`GCC_JIT_BINARY_OP_RSHIFT` + - `x >> y` .. c:macro:: GCC_JIT_BINARY_OP_PLUS @@ -536,17 +556,24 @@ Comparisons .. enum:: gcc_jit_comparison -======================================= ============ -Comparison C equivalent -======================================= ============ -:c:macro:`GCC_JIT_COMPARISON_EQ` `x == y` -:c:macro:`GCC_JIT_COMPARISON_NE` `x != y` -:c:macro:`GCC_JIT_COMPARISON_LT` `x < y` -:c:macro:`GCC_JIT_COMPARISON_LE` `x <= y` -:c:macro:`GCC_JIT_COMPARISON_GT` `x > y` -:c:macro:`GCC_JIT_COMPARISON_GE` `x >= y` -======================================= ============ - +.. list-table:: + :header-rows: 1 + + * - Comparison + - C equivalent + + * - :c:macro:`GCC_JIT_COMPARISON_EQ` + - `x == y` + * - :c:macro:`GCC_JIT_COMPARISON_NE` + - `x != y` + * - :c:macro:`GCC_JIT_COMPARISON_LT` + - `x < y` + * - :c:macro:`GCC_JIT_COMPARISON_LE` + - `x <= y` + * - :c:macro:`GCC_JIT_COMPARISON_GT` + - `x > y` + * - :c:macro:`GCC_JIT_COMPARISON_GE` + - `x >= y` Function calls ************** diff --git a/gcc/jit/docs/topics/types.rst b/gcc/jit/docs/topics/types.rst index db7fac6..457b362 100644 --- a/gcc/jit/docs/topics/types.rst +++ b/gcc/jit/docs/topics/types.rst @@ -57,45 +57,78 @@ Standard types Access a specific type. The available types are: - ========================================== ================================ - `enum gcc_jit_types` value Meaning - ========================================== ================================ - :c:data:`GCC_JIT_TYPE_VOID` C's ``void`` type. - :c:data:`GCC_JIT_TYPE_VOID_PTR` C's ``void *``. - :c:data:`GCC_JIT_TYPE_BOOL` C++'s ``bool`` type; also C99's - ``_Bool`` type, aka ``bool`` if - using stdbool.h. - :c:data:`GCC_JIT_TYPE_CHAR` C's ``char`` (of some signedness) - :c:data:`GCC_JIT_TYPE_SIGNED_CHAR` C's ``signed char`` - :c:data:`GCC_JIT_TYPE_UNSIGNED_CHAR` C's ``unsigned char`` - :c:data:`GCC_JIT_TYPE_SHORT` C's ``short`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_SHORT` C's ``unsigned short`` - :c:data:`GCC_JIT_TYPE_INT` C's ``int`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_INT` C's ``unsigned int`` - :c:data:`GCC_JIT_TYPE_LONG` C's ``long`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG` C's ``unsigned long`` - :c:data:`GCC_JIT_TYPE_LONG_LONG` C99's ``long long`` (signed) - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG_LONG` C99's ``unsigned long long`` - :c:data:`GCC_JIT_TYPE_UINT8_T` C99's ``uint8_t`` - :c:data:`GCC_JIT_TYPE_UINT16_T` C99's ``uint16_t`` - :c:data:`GCC_JIT_TYPE_UINT32_T` C99's ``uint32_t`` - :c:data:`GCC_JIT_TYPE_UINT64_T` C99's ``uint64_t`` - :c:data:`GCC_JIT_TYPE_UINT128_T` C99's ``__uint128_t`` - :c:data:`GCC_JIT_TYPE_INT8_T` C99's ``int8_t`` - :c:data:`GCC_JIT_TYPE_INT16_T` C99's ``int16_t`` - :c:data:`GCC_JIT_TYPE_INT32_T` C99's ``int32_t`` - :c:data:`GCC_JIT_TYPE_INT64_T` C99's ``int64_t`` - :c:data:`GCC_JIT_TYPE_INT128_T` C99's ``__int128_t`` - :c:data:`GCC_JIT_TYPE_FLOAT` - :c:data:`GCC_JIT_TYPE_DOUBLE` - :c:data:`GCC_JIT_TYPE_LONG_DOUBLE` - :c:data:`GCC_JIT_TYPE_CONST_CHAR_PTR` C type: ``(const char *)`` - :c:data:`GCC_JIT_TYPE_SIZE_T` C's ``size_t`` type - :c:data:`GCC_JIT_TYPE_FILE_PTR` C type: ``(FILE *)`` - :c:data:`GCC_JIT_TYPE_COMPLEX_FLOAT` C99's ``_Complex float`` - :c:data:`GCC_JIT_TYPE_COMPLEX_DOUBLE` C99's ``_Complex double`` - :c:data:`GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE` C99's ``_Complex long double`` - ========================================== ================================ + .. list-table:: + :header-rows: 1 + + * - `enum gcc_jit_types` value + - Meaning + + * - :c:data:`GCC_JIT_TYPE_VOID` + - C's ``void`` type. + * - :c:data:`GCC_JIT_TYPE_VOID_PTR` + - C's ``void *``. + * - :c:data:`GCC_JIT_TYPE_BOOL` + - C++'s ``bool`` type; also C99's ``_Bool`` type, aka ``bool`` if using stdbool.h. + * - :c:data:`GCC_JIT_TYPE_CHAR` + - C's ``char`` (of some signedness) + * - :c:data:`GCC_JIT_TYPE_SIGNED_CHAR` + - C's ``signed char`` + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_CHAR` + - C's ``unsigned char`` + * - :c:data:`GCC_JIT_TYPE_SHORT` + - C's ``short`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_SHORT` + - C's ``unsigned short`` + * - :c:data:`GCC_JIT_TYPE_INT` + - C's ``int`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_INT` + - C's ``unsigned int`` + * - :c:data:`GCC_JIT_TYPE_LONG` + - C's ``long`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG` + - C's ``unsigned long`` + * - :c:data:`GCC_JIT_TYPE_LONG_LONG` + - C99's ``long long`` (signed) + * - :c:data:`GCC_JIT_TYPE_UNSIGNED_LONG_LONG` + - C99's ``unsigned long long`` + * - :c:data:`GCC_JIT_TYPE_UINT8_T` + - C99's ``uint8_t`` + * - :c:data:`GCC_JIT_TYPE_UINT16_T` + - C99's ``uint16_t`` + * - :c:data:`GCC_JIT_TYPE_UINT32_T` + - C99's ``uint32_t`` + * - :c:data:`GCC_JIT_TYPE_UINT64_T` + - C99's ``uint64_t`` + * - :c:data:`GCC_JIT_TYPE_UINT128_T` + - C99's ``__uint128_t`` + * - :c:data:`GCC_JIT_TYPE_INT8_T` + - C99's ``int8_t`` + * - :c:data:`GCC_JIT_TYPE_INT16_T` + - C99's ``int16_t`` + * - :c:data:`GCC_JIT_TYPE_INT32_T` + - C99's ``int32_t`` + * - :c:data:`GCC_JIT_TYPE_INT64_T` + - C99's ``int64_t`` + * - :c:data:`GCC_JIT_TYPE_INT128_T` + - C99's ``__int128_t`` + * - :c:data:`GCC_JIT_TYPE_FLOAT` + - + * - :c:data:`GCC_JIT_TYPE_DOUBLE` + - + * - :c:data:`GCC_JIT_TYPE_LONG_DOUBLE` + - + * - :c:data:`GCC_JIT_TYPE_CONST_CHAR_PTR` + - C type: ``(const char *)`` + * - :c:data:`GCC_JIT_TYPE_SIZE_T` + - C's ``size_t`` type + * - :c:data:`GCC_JIT_TYPE_FILE_PTR` + - C type: ``(FILE *)`` + * - :c:data:`GCC_JIT_TYPE_COMPLEX_FLOAT` + - C99's ``_Complex float`` + * - :c:data:`GCC_JIT_TYPE_COMPLEX_DOUBLE` + - C99's ``_Complex double`` + * - :c:data:`GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE` + - C99's ``_Complex long double`` .. function:: gcc_jit_type *\ gcc_jit_context_get_int_type (gcc_jit_context *ctxt, \ |