Debian Codegraph @

gcc/testsuite/jit.dg/test-temp.c

raw
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdint.h>
5
6 #include "libgccjit.h"
7
8 #define TEST_COMPILING_TO_FILE
9 #define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER
10 #define OUTPUT_FILENAME "output-of-test-test-temp.c.s"
11 #include "harness.h"
12
13 void
14 create_code (gcc_jit_context *ctxt, void *user_data)
15 {
16 /* Let's try to inject the equivalent of:
17 int
18 func ()
19 {
20 int temp = 10;
21 return temp;
22 }
23 */
24 gcc_jit_type *int_type =
25 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
26
27 gcc_jit_function *func =
28 gcc_jit_context_new_function (ctxt,
29 NULL,
30 GCC_JIT_FUNCTION_EXPORTED,
31 int_type,
32 "func",
33 0, NULL, 0);
34
35 gcc_jit_block *initial =
36 gcc_jit_function_new_block (func, "initial");
37
38 gcc_jit_lvalue *temp =
39 gcc_jit_function_new_temp (func, NULL, int_type);
40
41 gcc_jit_rvalue *ten =
42 gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 10);
43 gcc_jit_block_add_assignment (initial, NULL, temp, ten);
44
45 gcc_jit_block_end_with_return(initial, NULL,
46 gcc_jit_lvalue_as_rvalue (temp));
47 }
48
49 void
50 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
51 {
52 CHECK_NON_NULL (result);
53 }
54
55 /* { dg-final { jit-verify-output-file-was-created "" } } */
56 /* { dg-final { jit-verify-assembler-output-not "JITTMP" } } */