Committed to branch dmalcolm/jit: gcc/jit/ChangeLog.jit: * docs/intro/install.rst: Markup fixes. * docs/intro/tutorial01.rst: Likewise. * docs/intro/tutorial02.rst: Likewise. * docs/topics/contexts.rst: Likewise. * docs/topics/expressions.rst: Likewise. * docs/topics/functions.rst: Likewise. * docs/topics/locations.rst: Likewise. * docs/topics/types.rst: Likewise. --- gcc/jit/ChangeLog.jit | 11 +++++++++++ gcc/jit/docs/intro/install.rst | 32 +++++++++++++++++++++++--------- gcc/jit/docs/intro/tutorial01.rst | 8 +++++--- gcc/jit/docs/intro/tutorial02.rst | 4 +++- gcc/jit/docs/topics/contexts.rst | 16 +++++++++++++--- gcc/jit/docs/topics/expressions.rst | 34 +++++++++++++++++++++++++--------- gcc/jit/docs/topics/functions.rst | 28 +++++++++++++++++++++------- gcc/jit/docs/topics/locations.rst | 8 ++++++-- gcc/jit/docs/topics/types.rst | 16 ++++++++++++---- 9 files changed, 119 insertions(+), 38 deletions(-)
diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit index 7ee7ebf..11c9298 100644 --- a/gcc/jit/ChangeLog.jit +++ b/gcc/jit/ChangeLog.jit @@ -1,5 +1,16 @@ 2014-09-18 David Malcolm <dmalc...@redhat.com> + * docs/intro/install.rst: Markup fixes. + * docs/intro/tutorial01.rst: Likewise. + * docs/intro/tutorial02.rst: Likewise. + * docs/topics/contexts.rst: Likewise. + * docs/topics/expressions.rst: Likewise. + * docs/topics/functions.rst: Likewise. + * docs/topics/locations.rst: Likewise. + * docs/topics/types.rst: Likewise. + +2014-09-18 David Malcolm <dmalc...@redhat.com> + * docs/examples/install-hello-world.c (main): Fix missing "return". * docs/examples/tut01-square.c (main): Likewise. diff --git a/gcc/jit/docs/intro/install.rst b/gcc/jit/docs/intro/install.rst index fc2e96e..1a39192 100644 --- a/gcc/jit/docs/intro/install.rst +++ b/gcc/jit/docs/intro/install.rst @@ -41,12 +41,14 @@ your system. Having done this, sudo yum install libgccjit-devel should give you both the JIT library (`libgccjit`) and the header files -needed to develop against it (`libgccjit-devel`):: +needed to develop against it (`libgccjit-devel`): - [david@c64 ~]$ rpm -qlv libgccjit +.. code-block:: console + + $ rpm -qlv libgccjit lrwxrwxrwx 1 root root 18 Aug 12 07:56 /usr/lib64/libgccjit.so.0 -> libgccjit.so.0.0.1 -rwxr-xr-x 1 root root 14463448 Aug 12 07:57 /usr/lib64/libgccjit.so.0.0.1 - [david@c64 ~]$ rpm -qlv libgccjit-devel + $ rpm -qlv libgccjit-devel -rwxr-xr-x 1 root root 37654 Aug 12 07:56 /usr/include/libgccjit++.h -rwxr-xr-x 1 root root 28967 Aug 12 07:56 /usr/include/libgccjit.h lrwxrwxrwx 1 root root 14 Aug 12 07:56 /usr/lib64/libgccjit.so -> libgccjit.so.0 @@ -103,7 +105,9 @@ To build it (within the "jit/build" subdirectory, installing to On my 4-core laptop this takes 17 minutes and 1.1G of disk space (it's much faster with many cores and a corresponding -j setting). -This should build a libgccjit.so within jit/build/gcc:: +This should build a libgccjit.so within jit/build/gcc: + +.. code-block:: console [build] $ file gcc/libgccjit.so* gcc/libgccjit.so: symbolic link to `libgccjit.so.0' @@ -126,14 +130,18 @@ earlier) via: On my laptop this uses a further 0.4G of disk space. You should be able to see the header files within the `include` -subdirectory of the installation prefix:: +subdirectory of the installation prefix: + +.. code-block:: console $ find $PREFIX/include /home/david/gcc-jit/install/include /home/david/gcc-jit/install/include/libgccjit.h /home/david/gcc-jit/install/include/libgccjit++.h -and the library within the `lib` subdirectory:: +and the library within the `lib` subdirectory: + +.. code-block:: console $ find $PREFIX/lib/libgccjit.* /home/david/gcc-jit/install/lib/libgccjit.so @@ -152,7 +160,9 @@ a call to `printf` and use it to write a message to stdout. Copy it to `jit-hello-world.c`. -To build it with prebuilt packages, use:: +To build it with prebuilt packages, use: + +.. code-block:: console $ gcc \ jit-hello-world.c \ @@ -165,7 +175,9 @@ To build it with prebuilt packages, use:: If building against an locally-built install (to $PREFIX), specify the -include and library paths with -I and -L:: +include and library paths with -I and -L: + +.. code-block:: console $ gcc \ jit-hello-world.c \ @@ -173,7 +185,9 @@ include and library paths with -I and -L:: -lgccjit \ -I$PREFIX/include -L$PREFIX/lib -and when running, specify the dynamic linkage path via LD_LIBRARY_PATH:: +and when running, specify the dynamic linkage path via LD_LIBRARY_PATH: + +.. code-block:: console $ LD_LIBRARY_PATH=$PREFIX/lib ./jit-hello-world hello world diff --git a/gcc/jit/docs/intro/tutorial01.rst b/gcc/jit/docs/intro/tutorial01.rst index ae47caf..4084027 100644 --- a/gcc/jit/docs/intro/tutorial01.rst +++ b/gcc/jit/docs/intro/tutorial01.rst @@ -266,7 +266,7 @@ before compiling: 1); result = gcc_jit_context_compile (ctxt); -.. code-block:: asm +.. code-block:: gas .file "fake.c" .text @@ -305,7 +305,7 @@ By default, no optimizations are performed, the equivalent of GCC's GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL, 3); -.. code-block:: asm +.. code-block:: gas .file "fake.c" .text @@ -337,7 +337,9 @@ Here's what the above looks like as a complete program: :lines: 1- :language: c -Building and running it:: +Building and running it: + +.. code-block:: console $ gcc \ tut01-square.c \ diff --git a/gcc/jit/docs/intro/tutorial02.rst b/gcc/jit/docs/intro/tutorial02.rst index 2151205..981c1c5 100644 --- a/gcc/jit/docs/intro/tutorial02.rst +++ b/gcc/jit/docs/intro/tutorial02.rst @@ -364,7 +364,9 @@ Full example :lines: 1- :language: c -Building and running it:: +Building and running it: + +.. code-block:: console $ gcc \ tut02-sum-of-squares.c \ diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst index 9d57a7c..d8dd4f8 100644 --- a/gcc/jit/docs/topics/contexts.rst +++ b/gcc/jit/docs/topics/contexts.rst @@ -153,9 +153,11 @@ String Options Set a string option of the context. + .. type:: enum gcc_jit_str_option + There is currently just one string option: - .. describe:: GCC_JIT_STR_OPTION_PROGNAME + .. macro:: GCC_JIT_STR_OPTION_PROGNAME The name of the program, for use as a prefix when printing error messages to stderr. If `NULL`, or default, "libgccjit.so" is used. @@ -170,6 +172,8 @@ Boolean options Set a boolean option of the context. Zero is "false" (the default), non-zero is "true". + .. type:: enum gcc_jit_bool_option + .. macro:: GCC_JIT_BOOL_OPTION_DEBUGINFO If true, :func:`gcc_jit_context_compile` will attempt to do the right @@ -215,7 +219,9 @@ Boolean options If true, :func:`gcc_jit_context_compile` will dump the "gimple" representation of your code to stderr, before any optimizations - are performed. The dump resembles C code:: + are performed. The dump resembles C code: + + .. code-block:: c square (signed int i) { @@ -229,7 +235,9 @@ Boolean options .. macro:: GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE If true, :func:`gcc_jit_context_compile` will dump the final - generated code to stderr, in the form of assembly language:: + generated code to stderr, in the form of assembly language: + + .. code-block:: gas .file "fake.c" .text @@ -293,6 +301,8 @@ Integer options Set an integer option of the context. + .. type:: enum gcc_jit_int_option + There is currently just one integer option: .. macro:: GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst index 753050e..357ccf2 100644 --- a/gcc/jit/docs/topics/expressions.rst +++ b/gcc/jit/docs/topics/expressions.rst @@ -66,15 +66,19 @@ Simple expressions gcc_jit_type *numeric_type) Given a numeric type (integer or floating point), get the rvalue for - zero. Essentially this is just a shortcut for:: + zero. Essentially this is just a shortcut for: - gcc_jit_context_new_rvalue_from_int (ctxt, numeric_type, 0); + .. code-block:: c + + gcc_jit_context_new_rvalue_from_int (ctxt, numeric_type, 0) .. function:: gcc_jit_rvalue *gcc_jit_context_one (gcc_jit_context *ctxt, \ gcc_jit_type *numeric_type) Given a numeric type (integer or floating point), get the rvalue for - zero. Essentially this is just a shortcut for:: + zero. Essentially this is just a shortcut for: + + .. code-block:: c gcc_jit_context_new_rvalue_from_int (ctxt, numeric_type, 1) @@ -97,7 +101,9 @@ Simple expressions gcc_jit_type *pointer_type) Given a pointer type, build an rvalue for ``NULL``. Essentially this - is just a shortcut for:: + is just a shortcut for: + + .. code-block:: c gcc_jit_context_new_rvalue_from_ptr (ctxt, pointer_type, NULL) @@ -403,7 +409,9 @@ Working with pointers, structs and unions gcc_jit_location *loc) Given an rvalue of pointer type ``T *``, dereferencing the pointer, - getting an lvalue of type ``T``. Analogous to:: + getting an lvalue of type ``T``. Analogous to: + + .. code-block:: c *(EXPR) @@ -417,7 +425,9 @@ Field access is provided separately for both lvalues and rvalues. gcc_jit_field *field) Given an lvalue of struct or union type, access the given field, - getting an lvalue of the field's type. Analogous to:: + getting an lvalue of the field's type. Analogous to: + + .. code-block:: c (EXPR).field = ...; @@ -429,7 +439,9 @@ Field access is provided separately for both lvalues and rvalues. gcc_jit_field *field) Given an rvalue of struct or union type, access the given field - as an rvalue. Analogous to:: + as an rvalue. Analogous to: + + .. code-block:: c (EXPR).field @@ -441,7 +453,9 @@ Field access is provided separately for both lvalues and rvalues. gcc_jit_field *field) Given an rvalue of pointer type ``T *`` where T is of struct or union - type, access the given field as an lvalue. Analogous to:: + type, access the given field as an lvalue. Analogous to: + + .. code-block:: c (EXPR)->field @@ -456,7 +470,9 @@ Field access is provided separately for both lvalues and rvalues. Given an rvalue of pointer type ``T *``, get at the element `T` at the given index, using standard C array indexing rules i.e. each increment of ``index`` corresponds to ``sizeof(T)`` bytes. - Analogous to:: + Analogous to: + + .. code-block:: c PTR[INDEX] diff --git a/gcc/jit/docs/topics/functions.rst b/gcc/jit/docs/topics/functions.rst index b28d6ed..15c895a 100644 --- a/gcc/jit/docs/topics/functions.rst +++ b/gcc/jit/docs/topics/functions.rst @@ -185,7 +185,9 @@ Statements Add evaluation of an rvalue, discarding the result (e.g. a function call that "returns" void). - This is equivalent to this C code:: + This is equivalent to this C code: + + .. code-block:: c (void)expression; @@ -198,7 +200,9 @@ Statements Add evaluation of an rvalue, assigning the result to the given lvalue. - This is roughly equivalent to this C code:: + This is roughly equivalent to this C code: + + .. code-block:: c lvalue = rvalue; @@ -212,7 +216,9 @@ Statements Add evaluation of an rvalue, using the result to modify an lvalue. - This is analogous to "+=" and friends:: + This is analogous to "+=" and friends: + + .. code-block:: c lvalue += rvalue; lvalue *= rvalue; @@ -242,7 +248,9 @@ Statements Terminate a block by adding evaluation of an rvalue, branching on the result to the appropriate successor block. - This is roughly equivalent to this C code:: + This is roughly equivalent to this C code: + + .. code-block:: c if (boolval) goto on_true; @@ -259,7 +267,9 @@ Statements Terminate a block by adding a jump to the given target block. - This is roughly equivalent to this C code:: + This is roughly equivalent to this C code: + + .. code-block:: c goto target; @@ -271,7 +281,9 @@ Statements Terminate a block by adding evaluation of an rvalue, returning the value. - This is roughly equivalent to this C code:: + This is roughly equivalent to this C code: + + .. code-block:: c return expression; @@ -283,6 +295,8 @@ Statements Terminate a block by adding a valueless return, for use within a function with "void" return type. - This is equivalent to this C code:: + This is equivalent to this C code: + + .. code-block:: c return; diff --git a/gcc/jit/docs/topics/locations.rst b/gcc/jit/docs/topics/locations.rst index 6422270..d1db974 100644 --- a/gcc/jit/docs/topics/locations.rst +++ b/gcc/jit/docs/topics/locations.rst @@ -34,7 +34,9 @@ Source Locations You need to enable :c:macro:`GCC_JIT_BOOL_OPTION_DEBUGINFO` on the :c:type:`gcc_jit_context` for these locations to actually be usable by - the debugger:: + the debugger: + + .. code-block:: c gcc_jit_context_set_bool_option ( ctxt, @@ -54,7 +56,9 @@ Faking it --------- If you don't have source code for your internal representation, but need to debug, you can generate a C-like representation of the functions in -your context using :c:func:`gcc_jit_context_dump_to_file()`:: +your context using :c:func:`gcc_jit_context_dump_to_file()`: + +.. code-block:: c gcc_jit_context_dump_to_file (ctxt, "/tmp/something.c", 1 /* update_locations */); diff --git a/gcc/jit/docs/topics/types.rst b/gcc/jit/docs/topics/types.rst index c234e8d..6770eca 100644 --- a/gcc/jit/docs/topics/types.rst +++ b/gcc/jit/docs/topics/types.rst @@ -31,14 +31,18 @@ Types Types can be created in several ways: * fundamental types can be accessed using - :func:`gcc_jit_context_get_type`:: + :func:`gcc_jit_context_get_type`: + + .. code-block:: c gcc_jit_type *int_type = gcc_jit_context_get_type (GCC_JIT_TYPE_INT); See :func:`gcc_jit_context_get_type` for the available types. * derived types can be accessed by using functions such as - :func:`gcc_jit_type_get_pointer` and :func:`gcc_jit_type_get_const`:: + :func:`gcc_jit_type_get_pointer` and :func:`gcc_jit_type_get_const`: + + .. code-block:: c gcc_jit_type *const_int_star = gcc_jit_type_get_pointer (gcc_jit_type_get_const (int_type)); gcc_jit_type *int_const_star = gcc_jit_type_get_const (gcc_jit_type_get_pointer (int_type)); @@ -131,7 +135,9 @@ You can model C `struct` types by creating :c:type:`gcc_jit_struct *` and struct coord {double x; double y; }; - you could call:: + you could call: + + .. code-block:: c gcc_jit_field *field_x = gcc_jit_context_new_field (ctxt, NULL, double_type, "x"); @@ -148,7 +154,9 @@ You can model C `struct` types by creating :c:type:`gcc_jit_struct *` and struct node { int m_hash; struct node *m_next; }; - like this:: + like this: + + .. code-block:: c gcc_jit_type *node = gcc_jit_context_new_opaque_struct (ctxt, NULL, "node"); -- 1.7.11.7