diff options
author | Antoni Boucher <bouanto@zoho.com> | 2021-12-11 16:42:54 -0500 |
---|---|---|
committer | Antoni Boucher <bouanto@zoho.com> | 2021-12-11 17:19:35 -0500 |
commit | 611fdb0fc5b95ee15215e2e3679834f311919096 (patch) | |
tree | 5cfe5aab38a044eb1519b9cf75d9beacde394989 /gcc/jit | |
parent | 7e913caad081ea85da4f257265f2d3383cdbe8d5 (diff) | |
download | gcc-611fdb0fc5b95ee15215e2e3679834f311919096.zip gcc-611fdb0fc5b95ee15215e2e3679834f311919096.tar.gz gcc-611fdb0fc5b95ee15215e2e3679834f311919096.tar.bz2 |
libgccjit: Add support for types used by atomic builtins [PR96066] [PR96067]
2021-12-11 Antoni Boucher <bouanto@zoho.com>
gcc/jit/
PR target/96066
PR target/96067
* jit-builtins.c: Implement missing types for builtins.
* jit-recording.c:: Allow sending a volatile const void * as
argument.
* jit-recording.h: New functions (is_volatile, is_const) and
allow comparing qualified types.
gcc/testsuite/
PR target/96066
PR target/96067
* jit.dg/all-non-failing-tests.h: Add test-builtin-types.c.
* jit.dg/test-builtin-types.c
* jit.dg/test-error-bad-assignment.c
* jit.dg/test-fuzzer.c: Add fuzzing for type qualifiers.
Signed-off-by: Antoni Boucher <bouanto@zoho.com>
Diffstat (limited to 'gcc/jit')
-rw-r--r-- | gcc/jit/jit-builtins.c | 10 | ||||
-rw-r--r-- | gcc/jit/jit-recording.c | 9 | ||||
-rw-r--r-- | gcc/jit/jit-recording.h | 20 |
3 files changed, 32 insertions, 7 deletions
diff --git a/gcc/jit/jit-builtins.c b/gcc/jit/jit-builtins.c index 1ea96f4..c279dd8 100644 --- a/gcc/jit/jit-builtins.c +++ b/gcc/jit/jit-builtins.c @@ -541,11 +541,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: } } diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c index 117ff70..2eecf44 100644 --- a/gcc/jit/jit-recording.c +++ b/gcc/jit/jit-recording.c @@ -2598,8 +2598,13 @@ recording::memento_of_get_pointer::accepts_writes_from (type *rtype) return false; /* It's OK to assign to a (const T *) from a (T *). */ - return m_other_type->unqualified () - ->accepts_writes_from (rtype_points_to); + if (m_other_type->unqualified ()->accepts_writes_from (rtype_points_to)) + { + return true; + } + + /* It's OK to assign to a (volatile const T *) from a (volatile const T *). */ + return m_other_type->is_same_type_as (rtype_points_to); } /* Implementation of pure virtual hook recording::memento::replay_into diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 4a994fe..3163ff6 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -545,6 +545,8 @@ public: virtual bool is_float () const = 0; virtual bool is_bool () const = 0; virtual type *is_pointer () = 0; + virtual type *is_volatile () { return NULL; } + virtual type *is_const () { return NULL; } virtual type *is_array () = 0; virtual struct_ *is_struct () { return NULL; } virtual bool is_void () const { return false; } @@ -687,6 +689,15 @@ public: /* Strip off the "const", giving the underlying type. */ type *unqualified () FINAL OVERRIDE { return m_other_type; } + virtual bool is_same_type_as (type *other) + { + if (!other->is_const ()) + return false; + return m_other_type->is_same_type_as (other->is_const ()); + } + + virtual type *is_const () { return m_other_type; } + void replay_into (replayer *) FINAL OVERRIDE; private: @@ -701,9 +712,18 @@ public: memento_of_get_volatile (type *other_type) : decorated_type (other_type) {} + virtual bool is_same_type_as (type *other) + { + if (!other->is_volatile ()) + return false; + return m_other_type->is_same_type_as (other->is_volatile ()); + } + /* Strip off the "volatile", giving the underlying type. */ type *unqualified () FINAL OVERRIDE { return m_other_type; } + virtual type *is_volatile () { return m_other_type; } + void replay_into (replayer *) FINAL OVERRIDE; private: |