Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting the inline attribute #3

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v2

- name: Install mpfr
run: sudo apt-get install gcc-10 libmpfr-dev libmpc-dev

- name: Build libgccjit
run: |
cd ..
ls
mkdir build install
cd build
../gcc/configure --enable-host-shared --enable-languages=jit,c++ --disable-bootstrap --disable-multilib --enable-checking=release --prefix=$(pwd)/../install
make -j4

- uses: actions/upload-artifact@v2
with:
name: libgccjit.so
path: /home/runner/work/gcc/build/gcc/libgccjit.so
70 changes: 69 additions & 1 deletion gcc/jit/docs/topics/compatibility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ entrypoints:
.. _LIBGCCJIT_ABI_15:

``LIBGCCJIT_ABI_15``
-----------------------
--------------------
``LIBGCCJIT_ABI_15`` covers the addition of API entrypoints for directly
embedding assembler instructions:

Expand All @@ -243,3 +243,71 @@ embedding assembler instructions:
* :func:`gcc_jit_extended_asm_add_input_operand`
* :func:`gcc_jit_extended_asm_add_clobber`
* :func:`gcc_jit_context_add_top_level_asm`

.. _LIBGCCJIT_ABI_16:

``LIBGCCJIT_ABI_16``
--------------------
``LIBGCCJIT_ABI_16`` covers the addition of reflection functions via API
entrypoints:

* :func:`gcc_jit_function_get_return_type`

* :func:`gcc_jit_function_get_param_count`

* :func:`gcc_jit_type_is_array`

* :func:`gcc_jit_type_is_bool`

* :func:`gcc_jit_type_is_integral`

* :func:`gcc_jit_type_is_pointer`

* :func:`gcc_jit_type_is_struct`

* :func:`gcc_jit_type_is_vector`

* :func:`gcc_jit_type_unqualified`

* :func:`gcc_jit_type_is_function_ptr_type`

* :func:`gcc_jit_function_type_get_return_type`

* :func:`gcc_jit_function_type_get_param_count`

* :func:`gcc_jit_function_type_get_param_type`

* :func:`gcc_jit_vector_type_get_num_units`

* :func:`gcc_jit_vector_type_get_element_type`

* :func:`gcc_jit_struct_get_field`

* :func:`gcc_jit_struct_get_field_count`

.. _LIBGCCJIT_ABI_17:

``LIBGCCJIT_ABI_17``
-----------------------
``LIBGCCJIT_ABI_17`` covers the addition of an API entrypoint to set the
thread-local storage model of a variable:

* :func:`gcc_jit_lvalue_set_tls_model`

.. _LIBGCCJIT_ABI_18:

``LIBGCCJIT_ABI_18``
-----------------------
``LIBGCCJIT_ABI_18`` covers the addition of an API entrypoint to set the link
section of a variable:

* :func:`gcc_jit_lvalue_set_link_section`

.. _LIBGCCJIT_ABI_19:

``LIBGCCJIT_ABI_19``
-----------------------
``LIBGCCJIT_ABI_19`` covers the addition of an API entrypoint to set the value
of a global variable:

* :func:`gcc_jit_global_set_initializer_value`
54 changes: 54 additions & 0 deletions gcc/jit/docs/topics/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,46 @@ where the rvalue is computed by reading from the storage area.

in C.

.. function:: void
gcc_jit_lvalue_set_link_section (gcc_jit_lvalue *lvalue,
const char *name)

Set the link section of a variable; analogous to:

.. code-block:: c

int variable __attribute__((section(".section")));

in C.

.. function:: void\
gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue,\
enum gcc_jit_tls_model model)

Make a variable a thread-local variable.

The "model" parameter determines the thread-local storage model of the "lvalue":

.. type:: enum gcc_jit_tls_model

.. c:macro:: GCC_JIT_TLS_MODEL_GLOBAL_DYNAMIC

.. c:macro:: GCC_JIT_TLS_MODEL_LOCAL_DYNAMIC

.. c:macro:: GCC_JIT_TLS_MODEL_INITIAL_EXEC

.. c:macro:: GCC_JIT_TLS_MODEL_LOCAL_EXEC

.. c:macro:: GCC_JIT_TLS_MODEL_DEFAULT

This is analogous to:

.. code-block:: c

_Thread_local int foo;

in C.

Global variables
****************

Expand Down Expand Up @@ -603,6 +643,20 @@ Global variables

#ifdef LIBGCCJIT_HAVE_gcc_jit_global_set_initializer

.. function:: void
gcc_jit_global_set_initializer_value (gcc_jit_lvalue *global,\
gcc_jit_rvalue *value)

Set an initializer for ``global`` using the specified value.
``global`` must be the same type as ``value``.

This entrypoint was added in :ref:`LIBGCCJIT_ABI_19`; you can test for
its presence using

.. code-block:: c

#ifdef LIBGCCJIT_HAVE_gcc_jit_global_set_initializer_value

Working with pointers, structs and unions
-----------------------------------------

Expand Down
26 changes: 26 additions & 0 deletions gcc/jit/docs/topics/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,32 @@ Functions
underlying string, so it is valid to pass in a pointer to an on-stack
buffer.

.. function:: ssize_t \
gcc_jit_function_get_param_count (gcc_jit_function *func)

Get the number of parameters of the function.

.. function:: gcc_jit_type *\
gcc_jit_function_get_return_type (gcc_jit_function *func)

Get the return type of the function.

The API entrypoints relating to getting info about parameters and return
types:

* :c:func:`gcc_jit_function_get_return_type`

* :c:func:`gcc_jit_function_get_param_count`

were added in :ref:`LIBGCCJIT_ABI_15`; you can test for their presence
using

.. code-block:: c

#ifdef LIBGCCJIT_HAVE_REFLECTION

.. type:: gcc_jit_case

Blocks
------
.. type:: gcc_jit_block
Expand Down
132 changes: 132 additions & 0 deletions gcc/jit/docs/topics/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ Standard types
: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`
Expand Down Expand Up @@ -345,3 +355,125 @@ Function pointer types

Function pointer types can be created using
:c:func:`gcc_jit_context_new_function_ptr_type`.

Reflection API
--------------

.. function:: gcc_jit_type *\
gcc_jit_type_is_array (gcc_jit_type *type)

Get the element type of an array type or NULL if it's not an array.

.. function:: int\
gcc_jit_type_is_bool (gcc_jit_type *type)

Return non-zero if the type is a bool.

.. function:: gcc_jit_function_type *\
gcc_jit_type_is_function_ptr_type (gcc_jit_type *type)

Return the function type if it is one or NULL.

.. function:: gcc_jit_type *\
gcc_jit_function_type_get_return_type (gcc_jit_function_type *function_type)

Given a function type, return its return type.

.. function:: ssize_t\
gcc_jit_function_type_get_param_count (gcc_jit_function_type *function_type)

Given a function type, return its number of parameters.

.. function:: gcc_jit_type *\
gcc_jit_function_type_get_param_type (gcc_jit_function_type *function_type,
size_t index)

Given a function type, return the type of the specified parameter.

.. function:: int\
gcc_jit_type_is_integral (gcc_jit_type *type)

Return non-zero if the type is an integral.

.. function:: gcc_jit_type *\
gcc_jit_type_is_pointer (gcc_jit_type *type)

Return the type pointed by the pointer type or NULL if it's not a pointer.

.. function:: gcc_jit_vector_type *\
gcc_jit_type_is_vector (gcc_jit_type *type)

Given a type, return a dynamic cast to a vector type or NULL.

.. function:: gcc_jit_struct *\
gcc_jit_type_is_struct (gcc_jit_type *type)

Given a type, return a dynamic cast to a struct type or NULL.

.. function:: ssize_t\
gcc_jit_vector_type_get_num_units (gcc_jit_vector_type *vector_type)

Given a vector type, return the number of units it contains.

.. function:: gcc_jit_type *\
gcc_jit_vector_type_get_element_type (gcc_jit_vector_type * vector_type)

Given a vector type, return the type of its elements.

.. function:: gcc_jit_type *\
gcc_jit_type_unqualified (gcc_jit_type *type)

Given a type, return the unqualified type, removing "const", "volatile" and
alignment qualifiers.

.. function:: gcc_jit_field *\
gcc_jit_struct_get_field (gcc_jit_struct *struct_type,
size_t index)

Get a struct field by index.

.. function:: ssize_t\
gcc_jit_struct_get_field_count (gcc_jit_struct *struct_type)

Get the number of fields in the struct.

The API entrypoints related to the reflection API:

* :c:func:`gcc_jit_function_type_get_return_type`

* :c:func:`gcc_jit_function_type_get_param_count`

* :c:func:`gcc_jit_function_type_get_param_type`

* :c:func:`gcc_jit_type_unqualified`

* :c:func:`gcc_jit_type_is_array`

* :c:func:`gcc_jit_type_is_bool`

* :c:func:`gcc_jit_type_is_function_ptr_type`

* :c:func:`gcc_jit_type_is_integral`

* :c:func:`gcc_jit_type_is_pointer`

* :c:func:`gcc_jit_type_is_vector`

* :c:func:`gcc_jit_vector_type_get_element_type`

* :c:func:`gcc_jit_vector_type_get_num_units`

* :c:func:`gcc_jit_struct_get_field`

* :c:func:`gcc_jit_type_is_struct`

* :c:func:`gcc_jit_struct_get_field_count`

were added in :ref:`LIBGCCJIT_ABI_15`; you can test for their presence
using

.. code-block:: c

#ifdef LIBGCCJIT_HAVE_REFLECTION

.. type:: gcc_jit_case
11 changes: 6 additions & 5 deletions gcc/jit/jit-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ builtins_manager::make_primitive_type (enum jit_builtin_type type_id)
case BT_UINT16: return m_ctxt->get_int_type (2, false);
case BT_UINT32: return m_ctxt->get_int_type (4, false);
case BT_UINT64: return m_ctxt->get_int_type (8, false);
case BT_UINT128: return m_ctxt->get_int_type (16, false);
// case BT_WORD:
// case BT_UNWINDWORD:
case BT_FLOAT: return m_ctxt->get_type (GCC_JIT_TYPE_FLOAT);
Expand Down Expand Up @@ -541,11 +542,11 @@ builtins_manager::make_primitive_type (enum jit_builtin_type type_id)
// case BT_DFLOAT128:
// case BT_VALIST_REF:
// case BT_VALIST_ARG:
// case BT_I1:
// case BT_I2:
// case BT_I4:
// case BT_I8:
// case BT_I16:
case BT_I1: return m_ctxt->get_int_type (1, true);
case BT_I2: return m_ctxt->get_int_type (2, true);
case BT_I4: return m_ctxt->get_int_type (4, true);
case BT_I8: return m_ctxt->get_int_type (8, true);
case BT_I16: return m_ctxt->get_int_type (16, true);
// case BT_PTR_CONST_STRING:
}
}
Expand Down
1 change: 1 addition & 0 deletions gcc/jit/jit-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ namespace recording {
class compound_type;
class struct_;
class union_;
class array_type;
class vector_type;
class field;
class bitfield;
Expand Down
Loading