(root)/
gcc-13.2.0/
gcc/
testsuite/
jit.dg/
test-builtin-types.c
       1  #include <stdlib.h>
       2  #include <stdio.h>
       3  #include <string.h>
       4  #include <time.h>
       5  
       6  #include "libgccjit.h"
       7  
       8  #include "harness.h"
       9  
      10  void
      11  create_code (gcc_jit_context *ctxt, void *user_data)
      12  {
      13    CHECK_NON_NULL (gcc_jit_context_get_builtin_function (ctxt, "__atomic_fetch_add_4"));
      14  
      15    gcc_jit_function *atomic_load = gcc_jit_context_get_builtin_function (ctxt, "__atomic_load_8");
      16  
      17    gcc_jit_type *void_type =
      18      gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
      19    gcc_jit_type *const_void_type =
      20      gcc_jit_type_get_const (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID));
      21    gcc_jit_type *volatile_void_ptr =
      22      gcc_jit_type_get_pointer (gcc_jit_type_get_volatile (const_void_type));
      23    gcc_jit_type *long_type =
      24      gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_LONG);
      25    gcc_jit_type *int_type =
      26      gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
      27    gcc_jit_function *func =
      28      gcc_jit_context_new_function (ctxt, NULL, GCC_JIT_FUNCTION_EXPORTED, void_type, "atomics", 0, NULL, 0);
      29  
      30    gcc_jit_lvalue *variable = gcc_jit_function_new_local (func, NULL, long_type, "variable");
      31    gcc_jit_rvalue *builtin_args[2];
      32    gcc_jit_rvalue *param1 = gcc_jit_lvalue_get_address(variable, NULL);
      33    builtin_args[0] = gcc_jit_context_new_cast(ctxt, NULL, param1, volatile_void_ptr);
      34    builtin_args[1] = gcc_jit_context_new_rvalue_from_long(ctxt, int_type, 0);
      35    gcc_jit_context_new_call (ctxt, NULL, atomic_load, 2, builtin_args);
      36  }
      37  
      38  void
      39  verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
      40  {
      41    /* Verify that no errors were emitted.  */
      42    CHECK_NON_NULL (result);
      43  }