forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libgccjit: Add support for creating temporary variables
gcc/jit/ChangeLog: * docs/topics/compatibility.rst (LIBGCCJIT_ABI_26): New ABI tag. * docs/topics/functions.rst: Document gcc_jit_function_new_temp. * jit-playback.cc (new_local): Add new is_temp parameter. * jit-playback.h: Add new is_temp parameter. * jit-recording.cc (recording::function::new_temp): New method. (recording::local::replay_into): Support temporary variables. (recording::local::write_reproducer): Support temporary variables. * jit-recording.h (new_temp): New method. (m_is_temp): New field. * libgccjit.cc (gcc_jit_function_new_temp): New function. * libgccjit.h (gcc_jit_function_new_temp): New function. * libgccjit.map: New function. gcc/testsuite/ChangeLog: * jit.dg/all-non-failing-tests.h: Mention test-temp.c. * jit.dg/test-temp.c: New test.
- Loading branch information
Showing
11 changed files
with
205 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
||
#include "libgccjit.h" | ||
|
||
#define TEST_COMPILING_TO_FILE | ||
#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER | ||
#define OUTPUT_FILENAME "output-of-test-test-temp.c.s" | ||
#include "harness.h" | ||
|
||
void | ||
create_code (gcc_jit_context *ctxt, void *user_data) | ||
{ | ||
/* Let's try to inject the equivalent of: | ||
int | ||
func () | ||
{ | ||
int temp = 10; | ||
return temp; | ||
} | ||
*/ | ||
gcc_jit_type *int_type = | ||
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); | ||
|
||
gcc_jit_function *func = | ||
gcc_jit_context_new_function (ctxt, | ||
NULL, | ||
GCC_JIT_FUNCTION_EXPORTED, | ||
int_type, | ||
"func", | ||
0, NULL, 0); | ||
|
||
gcc_jit_block *initial = | ||
gcc_jit_function_new_block (func, "initial"); | ||
|
||
gcc_jit_lvalue *temp = | ||
gcc_jit_function_new_temp (func, NULL, int_type); | ||
|
||
gcc_jit_rvalue *ten = | ||
gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 10); | ||
gcc_jit_block_add_assignment (initial, NULL, temp, ten); | ||
|
||
gcc_jit_block_end_with_return(initial, NULL, | ||
gcc_jit_lvalue_as_rvalue (temp)); | ||
} | ||
|
||
void | ||
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) | ||
{ | ||
CHECK_NON_NULL (result); | ||
} | ||
|
||
/* { dg-final { jit-verify-output-file-was-created "" } } */ | ||
/* { dg-final { jit-verify-assembler-output-not "JITTMP" } } */ |