libstdc++: Simplify std::any to fix -Wdeprecated-declarations warning
[official-gcc.git] / gcc / jit / libgccjit.h
blob1d5be27374ec1daaf659f225e90289bd0c3760b1
1 /* A pure C API to enable client code to embed GCC as a JIT-compiler.
2 Copyright (C) 2013-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef LIBGCCJIT_H
21 #define LIBGCCJIT_H
23 #include <stdio.h>
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
29 /**********************************************************************
30 Data structures.
31 **********************************************************************/
32 /* All structs within the API are opaque. */
34 /* A gcc_jit_context encapsulates the state of a compilation.
35 You can set up options on it, and add types, functions and code, using
36 the API below.
38 Invoking gcc_jit_context_compile on it gives you a gcc_jit_result *
39 (or NULL), representing in-memory machine code.
41 You can call gcc_jit_context_compile repeatedly on one context, giving
42 multiple independent results.
44 Similarly, you can call gcc_jit_context_compile_to_file on a context
45 to compile to disk.
47 Eventually you can call gcc_jit_context_release to clean up the
48 context; any in-memory results created from it are still usable, and
49 should be cleaned up via gcc_jit_result_release. */
50 typedef struct gcc_jit_context gcc_jit_context;
52 /* A gcc_jit_result encapsulates the result of an in-memory compilation. */
53 typedef struct gcc_jit_result gcc_jit_result;
55 /* An object created within a context. Such objects are automatically
56 cleaned up when the context is released.
58 The class hierarchy looks like this:
60 +- gcc_jit_object
61 +- gcc_jit_location
62 +- gcc_jit_type
63 +- gcc_jit_struct
64 +- gcc_jit_function_type
65 +- gcc_jit_vector_type
66 +- gcc_jit_field
67 +- gcc_jit_function
68 +- gcc_jit_block
69 +- gcc_jit_rvalue
70 +- gcc_jit_lvalue
71 +- gcc_jit_param
72 +- gcc_jit_case
73 +- gcc_jit_extended_asm
75 typedef struct gcc_jit_object gcc_jit_object;
77 /* A gcc_jit_location encapsulates a source code location, so that
78 you can (optionally) associate locations in your language with
79 statements in the JIT-compiled code, allowing the debugger to
80 single-step through your language.
82 Note that to do so, you also need to enable
83 GCC_JIT_BOOL_OPTION_DEBUGINFO
84 on the gcc_jit_context.
86 gcc_jit_location instances are optional; you can always pass
87 NULL. */
88 typedef struct gcc_jit_location gcc_jit_location;
90 /* A gcc_jit_type encapsulates a type e.g. "int" or a "struct foo*". */
91 typedef struct gcc_jit_type gcc_jit_type;
93 /* A gcc_jit_field encapsulates a field within a struct; it is used
94 when creating a struct type (using gcc_jit_context_new_struct_type).
95 Fields cannot be shared between structs. */
96 typedef struct gcc_jit_field gcc_jit_field;
98 /* A gcc_jit_struct encapsulates a struct type, either one that we have
99 the layout for, or an opaque type. */
100 typedef struct gcc_jit_struct gcc_jit_struct;
102 /* A gcc_jit_function_type encapsulates a function type. */
103 typedef struct gcc_jit_function_type gcc_jit_function_type;
105 /* A gcc_jit_vector_type encapsulates a vector type. */
106 typedef struct gcc_jit_vector_type gcc_jit_vector_type;
108 /* A gcc_jit_function encapsulates a function: either one that you're
109 creating yourself, or a reference to one that you're dynamically
110 linking to within the rest of the process. */
111 typedef struct gcc_jit_function gcc_jit_function;
113 /* A gcc_jit_block encapsulates a "basic block" of statements within a
114 function (i.e. with one entry point and one exit point).
116 Every block within a function must be terminated with a conditional,
117 a branch, or a return.
119 The blocks within a function form a directed graph.
121 The entrypoint to the function is the first block created within
124 All of the blocks in a function must be reachable via some path from
125 the first block.
127 It's OK to have more than one "return" from a function (i.e. multiple
128 blocks that terminate by returning). */
129 typedef struct gcc_jit_block gcc_jit_block;
131 /* A gcc_jit_rvalue is an expression within your code, with some type. */
132 typedef struct gcc_jit_rvalue gcc_jit_rvalue;
134 /* A gcc_jit_lvalue is a storage location within your code (e.g. a
135 variable, a parameter, etc). It is also a gcc_jit_rvalue; use
136 gcc_jit_lvalue_as_rvalue to cast. */
137 typedef struct gcc_jit_lvalue gcc_jit_lvalue;
139 /* A gcc_jit_param is a function parameter, used when creating a
140 gcc_jit_function. It is also a gcc_jit_lvalue (and thus also an
141 rvalue); use gcc_jit_param_as_lvalue to convert. */
142 typedef struct gcc_jit_param gcc_jit_param;
144 /* A gcc_jit_case is for use when building multiway branches via
145 gcc_jit_block_end_with_switch and represents a range of integer
146 values (or an individual integer value) together with an associated
147 destination block. */
148 typedef struct gcc_jit_case gcc_jit_case;
150 /* A gcc_jit_extended_asm represents an assembly language statement,
151 analogous to an extended "asm" statement in GCC's C front-end: a series
152 of low-level instructions inside a function that convert inputs to
153 outputs. */
154 typedef struct gcc_jit_extended_asm gcc_jit_extended_asm;
156 /* Acquire a JIT-compilation context. */
157 extern gcc_jit_context *
158 gcc_jit_context_acquire (void);
160 /* Release the context. After this call, it's no longer valid to use
161 the ctxt. */
162 extern void
163 gcc_jit_context_release (gcc_jit_context *ctxt);
165 /* Options present in the initial release of libgccjit.
166 These were handled using enums. */
168 /* Options taking string values. */
169 enum gcc_jit_str_option
171 /* The name of the program, for use as a prefix when printing error
172 messages to stderr. If NULL, or default, "libgccjit.so" is used. */
173 GCC_JIT_STR_OPTION_PROGNAME,
175 GCC_JIT_NUM_STR_OPTIONS
178 /* Options taking int values. */
179 enum gcc_jit_int_option
181 /* How much to optimize the code.
182 Valid values are 0-3, corresponding to GCC's command-line options
183 -O0 through -O3.
185 The default value is 0 (unoptimized). */
186 GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
188 GCC_JIT_NUM_INT_OPTIONS
191 /* Options taking boolean values.
192 These all default to "false". */
193 enum gcc_jit_bool_option
195 /* If true, gcc_jit_context_compile will attempt to do the right
196 thing so that if you attach a debugger to the process, it will
197 be able to inspect variables and step through your code.
199 Note that you can't step through code unless you set up source
200 location information for the code (by creating and passing in
201 gcc_jit_location instances). */
202 GCC_JIT_BOOL_OPTION_DEBUGINFO,
204 /* If true, gcc_jit_context_compile will dump its initial "tree"
205 representation of your code to stderr (before any
206 optimizations). */
207 GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE,
209 /* If true, gcc_jit_context_compile will dump the "gimple"
210 representation of your code to stderr, before any optimizations
211 are performed. The dump resembles C code. */
212 GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE,
214 /* If true, gcc_jit_context_compile will dump the final
215 generated code to stderr, in the form of assembly language. */
216 GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE,
218 /* If true, gcc_jit_context_compile will print information to stderr
219 on the actions it is performing, followed by a profile showing
220 the time taken and memory usage of each phase.
222 GCC_JIT_BOOL_OPTION_DUMP_SUMMARY,
224 /* If true, gcc_jit_context_compile will dump copious
225 amount of information on what it's doing to various
226 files within a temporary directory. Use
227 GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES (see below) to
228 see the results. The files are intended to be human-readable,
229 but the exact files and their formats are subject to change.
231 GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING,
233 /* If true, libgccjit will aggressively run its garbage collector, to
234 shake out bugs (greatly slowing down the compile). This is likely
235 to only be of interest to developers *of* the library. It is
236 used when running the selftest suite. */
237 GCC_JIT_BOOL_OPTION_SELFCHECK_GC,
239 /* If true, gcc_jit_context_release will not clean up
240 intermediate files written to the filesystem, and will display
241 their location on stderr. */
242 GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
244 GCC_JIT_NUM_BOOL_OPTIONS
247 /* Set a string option on the given context.
249 The context takes a copy of the string, so the
250 (const char *) buffer is not needed anymore after the call
251 returns. */
252 extern void
253 gcc_jit_context_set_str_option (gcc_jit_context *ctxt,
254 enum gcc_jit_str_option opt,
255 const char *value);
257 /* Set an int option on the given context. */
258 extern void
259 gcc_jit_context_set_int_option (gcc_jit_context *ctxt,
260 enum gcc_jit_int_option opt,
261 int value);
263 /* Set a boolean option on the given context.
265 Zero is "false" (the default), non-zero is "true". */
266 extern void
267 gcc_jit_context_set_bool_option (gcc_jit_context *ctxt,
268 enum gcc_jit_bool_option opt,
269 int value);
271 /* Options added after the initial release of libgccjit.
272 These are handled by providing an entrypoint per option,
273 rather than by extending the enum gcc_jit_*_option,
274 so that client code that use these new options can be identified
275 from binary metadata. */
277 /* By default, libgccjit will issue an error about unreachable blocks
278 within a function.
280 This option can be used to disable that error.
282 This entrypoint was added in LIBGCCJIT_ABI_2; you can test for
283 its presence using
284 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_set_bool_allow_unreachable_blocks
287 extern void
288 gcc_jit_context_set_bool_allow_unreachable_blocks (gcc_jit_context *ctxt,
289 int bool_value);
291 /* Pre-canned feature macro to indicate the presence of
292 gcc_jit_context_set_bool_allow_unreachable_blocks. This can be
293 tested for with #ifdef. */
294 #define LIBGCCJIT_HAVE_gcc_jit_context_set_bool_allow_unreachable_blocks
296 /* By default, libgccjit will print errors to stderr.
298 This option can be used to disable the printing.
300 This entrypoint was added in LIBGCCJIT_ABI_23; you can test for
301 its presence using
302 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_set_bool_print_errors_to_stderr
305 extern void
306 gcc_jit_context_set_bool_print_errors_to_stderr (gcc_jit_context *ctxt,
307 int enabled);
309 /* Pre-canned feature macro to indicate the presence of
310 gcc_jit_context_set_bool_print_errors_to_stderr. This can be
311 tested for with #ifdef. */
312 #define LIBGCCJIT_HAVE_gcc_jit_context_set_bool_print_errors_to_stderr
314 /* Implementation detail:
315 libgccjit internally generates assembler, and uses "driver" code
316 for converting it to other formats (e.g. shared libraries).
318 By default, libgccjit will use an embedded copy of the driver
319 code.
321 This option can be used to instead invoke an external driver executable
322 as a subprocess.
324 This entrypoint was added in LIBGCCJIT_ABI_5; you can test for
325 its presence using
326 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_set_bool_use_external_driver
329 extern void
330 gcc_jit_context_set_bool_use_external_driver (gcc_jit_context *ctxt,
331 int bool_value);
333 /* Pre-canned feature macro to indicate the presence of
334 gcc_jit_context_set_bool_use_external_driver. This can be
335 tested for with #ifdef. */
336 #define LIBGCCJIT_HAVE_gcc_jit_context_set_bool_use_external_driver
338 /* Add an arbitrary gcc command-line option to the context.
339 The context takes a copy of the string, so the
340 (const char *) optname is not needed anymore after the call
341 returns.
343 Note that only some options are likely to be meaningful; there is no
344 "frontend" within libgccjit, so typically only those affecting
345 optimization and code-generation are likely to be useful.
347 This entrypoint was added in LIBGCCJIT_ABI_1; you can test for
348 its presence using
349 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option
352 extern void
353 gcc_jit_context_add_command_line_option (gcc_jit_context *ctxt,
354 const char *optname);
356 /* Pre-canned feature-test macro for detecting the presence of
357 gcc_jit_context_add_command_line_option within libgccjit.h. */
359 #define LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option
361 /* Add an arbitrary gcc driver option to the context.
362 The context takes a copy of the string, so the
363 (const char *) optname is not needed anymore after the call
364 returns.
366 Note that only some options are likely to be meaningful; there is no
367 "frontend" within libgccjit, so typically only those affecting
368 assembler and linker are likely to be useful.
370 This entrypoint was added in LIBGCCJIT_ABI_11; you can test for
371 its presence using
372 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option
374 extern void
375 gcc_jit_context_add_driver_option (gcc_jit_context *ctxt,
376 const char *optname);
378 /* Pre-canned feature-test macro for detecting the presence of
379 gcc_jit_context_add_driver_option within libgccjit.h. */
381 #define LIBGCCJIT_HAVE_gcc_jit_context_add_driver_option
383 /* Compile the context to in-memory machine code.
385 This can be called more that once on a given context,
386 although any errors that occur will block further compilation. */
388 extern gcc_jit_result *
389 gcc_jit_context_compile (gcc_jit_context *ctxt);
391 /* Kinds of ahead-of-time compilation, for use with
392 gcc_jit_context_compile_to_file. */
394 enum gcc_jit_output_kind
396 /* Compile the context to an assembler file. */
397 GCC_JIT_OUTPUT_KIND_ASSEMBLER,
399 /* Compile the context to an object file. */
400 GCC_JIT_OUTPUT_KIND_OBJECT_FILE,
402 /* Compile the context to a dynamic library. */
403 GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY,
405 /* Compile the context to an executable. */
406 GCC_JIT_OUTPUT_KIND_EXECUTABLE
409 /* Compile the context to a file of the given kind.
411 This can be called more that once on a given context,
412 although any errors that occur will block further compilation. */
414 extern void
415 gcc_jit_context_compile_to_file (gcc_jit_context *ctxt,
416 enum gcc_jit_output_kind output_kind,
417 const char *output_path);
419 /* To help with debugging: dump a C-like representation to the given path,
420 describing what's been set up on the context.
422 If "update_locations" is true, then also set up gcc_jit_location
423 information throughout the context, pointing at the dump file as if it
424 were a source file. This may be of use in conjunction with
425 GCC_JIT_BOOL_OPTION_DEBUGINFO to allow stepping through the code in a
426 debugger. */
427 extern void
428 gcc_jit_context_dump_to_file (gcc_jit_context *ctxt,
429 const char *path,
430 int update_locations);
432 /* To help with debugging; enable ongoing logging of the context's
433 activity to the given FILE *.
435 The caller remains responsible for closing "logfile".
437 Params "flags" and "verbosity" are reserved for future use, and
438 must both be 0 for now. */
439 extern void
440 gcc_jit_context_set_logfile (gcc_jit_context *ctxt,
441 FILE *logfile,
442 int flags,
443 int verbosity);
445 /* To be called after any API call, this gives the first error message
446 that occurred on the context.
448 The returned string is valid for the rest of the lifetime of the
449 context.
451 If no errors occurred, this will be NULL. */
452 extern const char *
453 gcc_jit_context_get_first_error (gcc_jit_context *ctxt);
455 /* To be called after any API call, this gives the last error message
456 that occurred on the context.
458 If no errors occurred, this will be NULL.
460 If non-NULL, the returned string is only guaranteed to be valid until
461 the next call to libgccjit relating to this context. */
462 extern const char *
463 gcc_jit_context_get_last_error (gcc_jit_context *ctxt);
465 /* Locate a given function within the built machine code.
466 This will need to be cast to a function pointer of the
467 correct type before it can be called. */
468 extern void *
469 gcc_jit_result_get_code (gcc_jit_result *result,
470 const char *funcname);
472 /* Locate a given global within the built machine code.
473 It must have been created using GCC_JIT_GLOBAL_EXPORTED.
474 This is a ptr to the global, so e.g. for an int this is an int *. */
475 extern void *
476 gcc_jit_result_get_global (gcc_jit_result *result,
477 const char *name);
479 /* Once we're done with the code, this unloads the built .so file.
480 This cleans up the result; after calling this, it's no longer
481 valid to use the result. */
482 extern void
483 gcc_jit_result_release (gcc_jit_result *result);
486 /**********************************************************************
487 Functions for creating "contextual" objects.
489 All objects created by these functions share the lifetime of the context
490 they are created within, and are automatically cleaned up for you when
491 you call gcc_jit_context_release on the context.
493 Note that this means you can't use references to them after you've
494 released their context.
496 All (const char *) string arguments passed to these functions are
497 copied, so you don't need to keep them around.
499 You create code by adding a sequence of statements to blocks.
500 **********************************************************************/
502 /**********************************************************************
503 The base class of "contextual" object.
504 **********************************************************************/
505 /* Which context is "obj" within? */
506 extern gcc_jit_context *
507 gcc_jit_object_get_context (gcc_jit_object *obj);
509 /* Get a human-readable description of this object.
510 The string buffer is created the first time this is called on a given
511 object, and persists until the object's context is released. */
512 extern const char *
513 gcc_jit_object_get_debug_string (gcc_jit_object *obj);
515 /**********************************************************************
516 Debugging information.
517 **********************************************************************/
519 /* Creating source code locations for use by the debugger.
520 Line and column numbers are 1-based. */
521 extern gcc_jit_location *
522 gcc_jit_context_new_location (gcc_jit_context *ctxt,
523 const char *filename,
524 int line,
525 int column);
527 /* Upcasting from location to object. */
528 extern gcc_jit_object *
529 gcc_jit_location_as_object (gcc_jit_location *loc);
532 /**********************************************************************
533 Types.
534 **********************************************************************/
536 /* Upcasting from type to object. */
537 extern gcc_jit_object *
538 gcc_jit_type_as_object (gcc_jit_type *type);
540 /* Access to specific types. */
541 enum gcc_jit_types
543 /* C's "void" type. */
544 GCC_JIT_TYPE_VOID,
546 /* "void *". */
547 GCC_JIT_TYPE_VOID_PTR,
549 /* C++'s bool type; also C99's "_Bool" type, aka "bool" if using
550 stdbool.h. */
551 GCC_JIT_TYPE_BOOL,
553 /* Various integer types. */
555 /* C's "char" (of some signedness) and the variants where the
556 signedness is specified. */
557 GCC_JIT_TYPE_CHAR,
558 GCC_JIT_TYPE_SIGNED_CHAR,
559 GCC_JIT_TYPE_UNSIGNED_CHAR,
561 /* C's "short" and "unsigned short". */
562 GCC_JIT_TYPE_SHORT, /* signed */
563 GCC_JIT_TYPE_UNSIGNED_SHORT,
565 /* C's "int" and "unsigned int". */
566 GCC_JIT_TYPE_INT, /* signed */
567 GCC_JIT_TYPE_UNSIGNED_INT,
569 /* C's "long" and "unsigned long". */
570 GCC_JIT_TYPE_LONG, /* signed */
571 GCC_JIT_TYPE_UNSIGNED_LONG,
573 /* C99's "long long" and "unsigned long long". */
574 GCC_JIT_TYPE_LONG_LONG, /* signed */
575 GCC_JIT_TYPE_UNSIGNED_LONG_LONG,
577 /* Floating-point types */
579 GCC_JIT_TYPE_FLOAT,
580 GCC_JIT_TYPE_DOUBLE,
581 GCC_JIT_TYPE_LONG_DOUBLE,
583 /* C type: (const char *). */
584 GCC_JIT_TYPE_CONST_CHAR_PTR,
586 /* The C "size_t" type. */
587 GCC_JIT_TYPE_SIZE_T,
589 /* C type: (FILE *) */
590 GCC_JIT_TYPE_FILE_PTR,
592 /* Complex numbers. */
593 GCC_JIT_TYPE_COMPLEX_FLOAT,
594 GCC_JIT_TYPE_COMPLEX_DOUBLE,
595 GCC_JIT_TYPE_COMPLEX_LONG_DOUBLE,
597 /* Sized integer types. */
598 GCC_JIT_TYPE_UINT8_T,
599 GCC_JIT_TYPE_UINT16_T,
600 GCC_JIT_TYPE_UINT32_T,
601 GCC_JIT_TYPE_UINT64_T,
602 GCC_JIT_TYPE_UINT128_T,
603 GCC_JIT_TYPE_INT8_T,
604 GCC_JIT_TYPE_INT16_T,
605 GCC_JIT_TYPE_INT32_T,
606 GCC_JIT_TYPE_INT64_T,
607 GCC_JIT_TYPE_INT128_T,
609 GCC_JIT_TYPE_BFLOAT16,
612 extern gcc_jit_type *
613 gcc_jit_context_get_type (gcc_jit_context *ctxt,
614 enum gcc_jit_types type_);
616 /* Get the integer type of the given size and signedness. */
617 extern gcc_jit_type *
618 gcc_jit_context_get_int_type (gcc_jit_context *ctxt,
619 int num_bytes, int is_signed);
621 /* Constructing new types. */
623 /* Given type "T", get type "T*". */
624 extern gcc_jit_type *
625 gcc_jit_type_get_pointer (gcc_jit_type *type);
627 /* Given type "T", get type "const T". */
628 extern gcc_jit_type *
629 gcc_jit_type_get_const (gcc_jit_type *type);
631 /* Given type "T", get type "volatile T". */
632 extern gcc_jit_type *
633 gcc_jit_type_get_volatile (gcc_jit_type *type);
635 #define LIBGCCJIT_HAVE_gcc_jit_type_get_restrict
637 /* Given type "T", get type "restrict T".
638 This API entrypoint was added in LIBGCCJIT_ABI_25; you can test for its
639 presence using
640 #ifdef LIBGCCJIT_HAVE_gcc_jit_type_get_restrict */
641 extern gcc_jit_type *
642 gcc_jit_type_get_restrict (gcc_jit_type *type);
644 #define LIBGCCJIT_HAVE_SIZED_INTEGERS
646 /* Given types LTYPE and RTYPE, return non-zero if they are compatible.
647 This API entrypoint was added in LIBGCCJIT_ABI_20; you can test for its
648 presence using
649 #ifdef LIBGCCJIT_HAVE_SIZED_INTEGERS */
650 extern int
651 gcc_jit_compatible_types (gcc_jit_type *ltype,
652 gcc_jit_type *rtype);
654 /* Given type "T", get its size.
655 This API entrypoint was added in LIBGCCJIT_ABI_20; you can test for its
656 presence using
657 #ifdef LIBGCCJIT_HAVE_SIZED_INTEGERS */
658 extern ssize_t
659 gcc_jit_type_get_size (gcc_jit_type *type);
661 /* Given type "T", get type "T[N]" (for a constant N). */
662 extern gcc_jit_type *
663 gcc_jit_context_new_array_type (gcc_jit_context *ctxt,
664 gcc_jit_location *loc,
665 gcc_jit_type *element_type,
666 int num_elements);
668 /* Struct-handling. */
670 /* Create a field, for use within a struct or union. */
671 extern gcc_jit_field *
672 gcc_jit_context_new_field (gcc_jit_context *ctxt,
673 gcc_jit_location *loc,
674 gcc_jit_type *type,
675 const char *name);
677 #define LIBGCCJIT_HAVE_gcc_jit_context_new_bitfield
679 /* Create a bit field, for use within a struct or union.
681 This API entrypoint was added in LIBGCCJIT_ABI_12; you can test for its
682 presence using
683 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitfield
685 extern gcc_jit_field *
686 gcc_jit_context_new_bitfield (gcc_jit_context *ctxt,
687 gcc_jit_location *loc,
688 gcc_jit_type *type,
689 int width,
690 const char *name);
692 /* Upcasting from field to object. */
693 extern gcc_jit_object *
694 gcc_jit_field_as_object (gcc_jit_field *field);
696 /* Create a struct type from an array of fields. */
697 extern gcc_jit_struct *
698 gcc_jit_context_new_struct_type (gcc_jit_context *ctxt,
699 gcc_jit_location *loc,
700 const char *name,
701 int num_fields,
702 gcc_jit_field **fields);
704 /* Create an opaque struct type. */
705 extern gcc_jit_struct *
706 gcc_jit_context_new_opaque_struct (gcc_jit_context *ctxt,
707 gcc_jit_location *loc,
708 const char *name);
710 /* Upcast a struct to a type. */
711 extern gcc_jit_type *
712 gcc_jit_struct_as_type (gcc_jit_struct *struct_type);
714 /* Populating the fields of a formerly-opaque struct type.
715 This can only be called once on a given struct type. */
716 extern void
717 gcc_jit_struct_set_fields (gcc_jit_struct *struct_type,
718 gcc_jit_location *loc,
719 int num_fields,
720 gcc_jit_field **fields);
722 /* Get a field by index. */
723 extern gcc_jit_field *
724 gcc_jit_struct_get_field (gcc_jit_struct *struct_type,
725 size_t index);
727 /* Get the number of fields. */
728 extern size_t
729 gcc_jit_struct_get_field_count (gcc_jit_struct *struct_type);
731 /* Unions work similarly to structs. */
732 extern gcc_jit_type *
733 gcc_jit_context_new_union_type (gcc_jit_context *ctxt,
734 gcc_jit_location *loc,
735 const char *name,
736 int num_fields,
737 gcc_jit_field **fields);
739 /* Function pointers. */
741 extern gcc_jit_type *
742 gcc_jit_context_new_function_ptr_type (gcc_jit_context *ctxt,
743 gcc_jit_location *loc,
744 gcc_jit_type *return_type,
745 int num_params,
746 gcc_jit_type **param_types,
747 int is_variadic);
749 /**********************************************************************
750 Constructing functions.
751 **********************************************************************/
752 /* Create a function param. */
753 extern gcc_jit_param *
754 gcc_jit_context_new_param (gcc_jit_context *ctxt,
755 gcc_jit_location *loc,
756 gcc_jit_type *type,
757 const char *name);
759 /* Upcasting from param to object. */
760 extern gcc_jit_object *
761 gcc_jit_param_as_object (gcc_jit_param *param);
763 /* Upcasting from param to lvalue. */
764 extern gcc_jit_lvalue *
765 gcc_jit_param_as_lvalue (gcc_jit_param *param);
767 /* Upcasting from param to rvalue. */
768 extern gcc_jit_rvalue *
769 gcc_jit_param_as_rvalue (gcc_jit_param *param);
771 /* Kinds of function. */
772 enum gcc_jit_function_kind
774 /* Function is defined by the client code and visible
775 by name outside of the JIT. */
776 GCC_JIT_FUNCTION_EXPORTED,
778 /* Function is defined by the client code, but is invisible
779 outside of the JIT. Analogous to a "static" function. */
780 GCC_JIT_FUNCTION_INTERNAL,
782 /* Function is not defined by the client code; we're merely
783 referring to it. Analogous to using an "extern" function from a
784 header file. */
785 GCC_JIT_FUNCTION_IMPORTED,
787 /* Function is only ever inlined into other functions, and is
788 invisible outside of the JIT.
790 Analogous to prefixing with "inline" and adding
791 __attribute__((always_inline)).
793 Inlining will only occur when the optimization level is
794 above 0; when optimization is off, this is essentially the
795 same as GCC_JIT_FUNCTION_INTERNAL. */
796 GCC_JIT_FUNCTION_ALWAYS_INLINE
799 /* Thread local storage model. */
800 enum gcc_jit_tls_model
802 GCC_JIT_TLS_MODEL_NONE,
803 GCC_JIT_TLS_MODEL_GLOBAL_DYNAMIC,
804 GCC_JIT_TLS_MODEL_LOCAL_DYNAMIC,
805 GCC_JIT_TLS_MODEL_INITIAL_EXEC,
806 GCC_JIT_TLS_MODEL_LOCAL_EXEC,
809 /* Create a function. */
810 extern gcc_jit_function *
811 gcc_jit_context_new_function (gcc_jit_context *ctxt,
812 gcc_jit_location *loc,
813 enum gcc_jit_function_kind kind,
814 gcc_jit_type *return_type,
815 const char *name,
816 int num_params,
817 gcc_jit_param **params,
818 int is_variadic);
820 /* Create a reference to a builtin function (sometimes called
821 intrinsic functions). */
822 extern gcc_jit_function *
823 gcc_jit_context_get_builtin_function (gcc_jit_context *ctxt,
824 const char *name);
826 /* Upcasting from function to object. */
827 extern gcc_jit_object *
828 gcc_jit_function_as_object (gcc_jit_function *func);
830 /* Get a specific param of a function by index. */
831 extern gcc_jit_param *
832 gcc_jit_function_get_param (gcc_jit_function *func, int index);
834 /* Emit the function in graphviz format. */
835 extern void
836 gcc_jit_function_dump_to_dot (gcc_jit_function *func,
837 const char *path);
839 /* Create a block.
841 The name can be NULL, or you can give it a meaningful name, which
842 may show up in dumps of the internal representation, and in error
843 messages. */
844 extern gcc_jit_block *
845 gcc_jit_function_new_block (gcc_jit_function *func,
846 const char *name);
848 /* Upcasting from block to object. */
849 extern gcc_jit_object *
850 gcc_jit_block_as_object (gcc_jit_block *block);
852 /* Which function is this block within? */
853 extern gcc_jit_function *
854 gcc_jit_block_get_function (gcc_jit_block *block);
856 /**********************************************************************
857 lvalues, rvalues and expressions.
858 **********************************************************************/
859 enum gcc_jit_global_kind
861 /* Global is defined by the client code and visible
862 by name outside of this JIT context via gcc_jit_result_get_global. */
863 GCC_JIT_GLOBAL_EXPORTED,
865 /* Global is defined by the client code, but is invisible
866 outside of this JIT context. Analogous to a "static" global. */
867 GCC_JIT_GLOBAL_INTERNAL,
869 /* Global is not defined by the client code; we're merely
870 referring to it. Analogous to using an "extern" global from a
871 header file. */
872 GCC_JIT_GLOBAL_IMPORTED
875 extern gcc_jit_lvalue *
876 gcc_jit_context_new_global (gcc_jit_context *ctxt,
877 gcc_jit_location *loc,
878 enum gcc_jit_global_kind kind,
879 gcc_jit_type *type,
880 const char *name);
882 #define LIBGCCJIT_HAVE_CTORS
884 /* Create a constructor for a struct as an rvalue.
886 Returns NULL on error. The two parameter arrays are copied and
887 do not have to outlive the context.
889 `type` specifies what the constructor will build and has to be
890 a struct.
892 `num_values` specifies the number of elements in `values`.
894 `fields` need to have the same length as `values`, or be NULL.
896 If `fields` is null, the values are applied in definition order.
898 Otherwise, each field in `fields` specifies which field in the struct to
899 set to the corresponding value in `values`. `fields` and `values`
900 are paired by index.
902 Each value has to have the same unqualified type as the field
903 it is applied to.
905 A NULL value element in `values` is a shorthand for zero initialization
906 of the corresponding field.
908 The fields in `fields` have to be in definition order, but there
909 can be gaps. Any field in the struct that is not specified in
910 `fields` will be zeroed.
912 The fields in `fields` need to be the same objects that were used
913 to create the struct.
915 If `num_values` is 0, the array parameters will be
916 ignored and zero initialization will be used.
918 The constructor rvalue can be used for assignment to locals.
919 It can be used to initialize global variables with
920 gcc_jit_global_set_initializer_rvalue. It can also be used as a
921 temporary value for function calls and return values.
923 The constructor can contain nested constructors.
925 This entrypoint was added in LIBGCCJIT_ABI_19; you can test for its
926 presence using:
927 #ifdef LIBGCCJIT_HAVE_CTORS
930 extern gcc_jit_rvalue *
931 gcc_jit_context_new_struct_constructor (gcc_jit_context *ctxt,
932 gcc_jit_location *loc,
933 gcc_jit_type *type,
934 size_t num_values,
935 gcc_jit_field **fields,
936 gcc_jit_rvalue **values);
938 /* Create a constructor for a union as an rvalue.
940 Returns NULL on error.
942 `type` specifies what the constructor will build and has to be
943 an union.
945 `field` specifies which field to set. If it is NULL, the first
946 field in the union will be set. `field` need to be the same
947 object that were used to create the union.
949 `value` specifies what value to set the corresponding field to.
950 If `value` is NULL, zero initialization will be used.
952 Each value has to have the same unqualified type as the field
953 it is applied to.
955 `field` need to be the same objects that were used
956 to create the union.
958 The constructor rvalue can be used for assignment to locals.
959 It can be used to initialize global variables with
960 gcc_jit_global_set_initializer_rvalue. It can also be used as a
961 temporary value for function calls and return values.
963 The constructor can contain nested constructors.
965 This entrypoint was added in LIBGCCJIT_ABI_19; you can test for its
966 presence using:
967 #ifdef LIBGCCJIT_HAVE_CTORS
970 extern gcc_jit_rvalue *
971 gcc_jit_context_new_union_constructor (gcc_jit_context *ctxt,
972 gcc_jit_location *loc,
973 gcc_jit_type *type,
974 gcc_jit_field *field,
975 gcc_jit_rvalue *value);
977 /* Create a constructor for an array as an rvalue.
979 Returns NULL on error. `values` are copied and
980 do not have to outlive the context.
982 `type` specifies what the constructor will build and has to be
983 an array.
985 `num_values` specifies the number of elements in `values` and
986 it can't have more elements than the array type.
988 Each value in `values` sets the corresponding value in the array.
989 If the array type itself has more elements than `values`, the
990 left-over elements will be zeroed.
992 Each value in `values` need to be the same unqualified type as the
993 array type's element type.
995 If `num_values` is 0, the `values` parameter will be
996 ignored and zero initialization will be used.
998 Note that a string literal rvalue can't be used to construct a char
999 array. It needs one rvalue for each char.
1001 This entrypoint was added in LIBGCCJIT_ABI_19; you can test for its
1002 presence using:
1003 #ifdef LIBGCCJIT_HAVE_CTORS
1006 extern gcc_jit_rvalue *
1007 gcc_jit_context_new_array_constructor (gcc_jit_context *ctxt,
1008 gcc_jit_location *loc,
1009 gcc_jit_type *type,
1010 size_t num_values,
1011 gcc_jit_rvalue **values);
1013 /* Set the initial value of a global of any type with an rvalue.
1015 The rvalue needs to be a constant expression, e.g. no function calls.
1017 The global can't have the 'kind' GCC_JIT_GLOBAL_IMPORTED.
1019 Use together with gcc_jit_context_new_constructor () to
1020 initialize structs, unions and arrays.
1022 On success, returns the 'global' parameter unchanged. Otherwise, NULL.
1024 'values' is copied and does not have to outlive the context.
1026 This entrypoint was added in LIBGCCJIT_ABI_19; you can test for its
1027 presence using:
1028 #ifdef LIBGCCJIT_HAVE_CTORS
1031 extern gcc_jit_lvalue *
1032 gcc_jit_global_set_initializer_rvalue (gcc_jit_lvalue *global,
1033 gcc_jit_rvalue *init_value);
1035 #define LIBGCCJIT_HAVE_gcc_jit_global_set_initializer
1037 /* Set an initial value for a global, which must be an array of
1038 integral type. Return the global itself.
1040 This API entrypoint was added in LIBGCCJIT_ABI_14; you can test for its
1041 presence using
1042 #ifdef LIBGCCJIT_HAVE_gcc_jit_global_set_initializer
1045 extern gcc_jit_lvalue *
1046 gcc_jit_global_set_initializer (gcc_jit_lvalue *global,
1047 const void *blob,
1048 size_t num_bytes);
1050 /* Upcasting. */
1051 extern gcc_jit_object *
1052 gcc_jit_lvalue_as_object (gcc_jit_lvalue *lvalue);
1054 extern gcc_jit_rvalue *
1055 gcc_jit_lvalue_as_rvalue (gcc_jit_lvalue *lvalue);
1057 extern gcc_jit_object *
1058 gcc_jit_rvalue_as_object (gcc_jit_rvalue *rvalue);
1060 extern gcc_jit_type *
1061 gcc_jit_rvalue_get_type (gcc_jit_rvalue *rvalue);
1063 /* Integer constants. */
1064 extern gcc_jit_rvalue *
1065 gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt,
1066 gcc_jit_type *numeric_type,
1067 int value);
1069 extern gcc_jit_rvalue *
1070 gcc_jit_context_new_rvalue_from_long (gcc_jit_context *ctxt,
1071 gcc_jit_type *numeric_type,
1072 long value);
1074 extern gcc_jit_rvalue *
1075 gcc_jit_context_zero (gcc_jit_context *ctxt,
1076 gcc_jit_type *numeric_type);
1078 extern gcc_jit_rvalue *
1079 gcc_jit_context_one (gcc_jit_context *ctxt,
1080 gcc_jit_type *numeric_type);
1082 /* Floating-point constants. */
1083 extern gcc_jit_rvalue *
1084 gcc_jit_context_new_rvalue_from_double (gcc_jit_context *ctxt,
1085 gcc_jit_type *numeric_type,
1086 double value);
1088 /* Pointers. */
1089 extern gcc_jit_rvalue *
1090 gcc_jit_context_new_rvalue_from_ptr (gcc_jit_context *ctxt,
1091 gcc_jit_type *pointer_type,
1092 void *value);
1094 extern gcc_jit_rvalue *
1095 gcc_jit_context_null (gcc_jit_context *ctxt,
1096 gcc_jit_type *pointer_type);
1098 #define LIBGCCJIT_HAVE_gcc_jit_context_new_sizeof
1100 /* Generates an rvalue that is equal to the size of type.
1102 This API entrypoint was added in LIBGCCJIT_ABI_27; you can test for its
1103 presence using
1104 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_sizeof */
1106 extern gcc_jit_rvalue *
1107 gcc_jit_context_new_sizeof (gcc_jit_context *ctxt,
1108 gcc_jit_type *type);
1110 #define LIBGCCJIT_HAVE_gcc_jit_context_new_alignof
1112 /* Generates an rvalue that is equal to the alignment of type.
1114 This API entrypoint was added in LIBGCCJIT_ABI_38; you can test for its
1115 presence using
1116 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_alignof */
1118 extern gcc_jit_rvalue *
1119 gcc_jit_context_new_alignof (gcc_jit_context *ctxt,
1120 gcc_jit_type *type);
1123 /* String literals. */
1124 extern gcc_jit_rvalue *
1125 gcc_jit_context_new_string_literal (gcc_jit_context *ctxt,
1126 const char *value);
1128 enum gcc_jit_unary_op
1130 /* Negate an arithmetic value; analogous to:
1131 -(EXPR)
1132 in C. */
1133 GCC_JIT_UNARY_OP_MINUS,
1135 /* Bitwise negation of an integer value (one's complement); analogous
1137 ~(EXPR)
1138 in C. */
1139 GCC_JIT_UNARY_OP_BITWISE_NEGATE,
1141 /* Logical negation of an arithmetic or pointer value; analogous to:
1142 !(EXPR)
1143 in C. */
1144 GCC_JIT_UNARY_OP_LOGICAL_NEGATE,
1146 /* Absolute value of an arithmetic expression; analogous to:
1147 abs (EXPR)
1148 in C. */
1149 GCC_JIT_UNARY_OP_ABS
1153 extern gcc_jit_rvalue *
1154 gcc_jit_context_new_unary_op (gcc_jit_context *ctxt,
1155 gcc_jit_location *loc,
1156 enum gcc_jit_unary_op op,
1157 gcc_jit_type *result_type,
1158 gcc_jit_rvalue *rvalue);
1160 enum gcc_jit_binary_op
1162 /* Addition of arithmetic values; analogous to:
1163 (EXPR_A) + (EXPR_B)
1164 in C.
1165 For pointer addition, use gcc_jit_context_new_array_access. */
1166 GCC_JIT_BINARY_OP_PLUS,
1168 /* Subtraction of arithmetic values; analogous to:
1169 (EXPR_A) - (EXPR_B)
1170 in C. */
1171 GCC_JIT_BINARY_OP_MINUS,
1173 /* Multiplication of a pair of arithmetic values; analogous to:
1174 (EXPR_A) * (EXPR_B)
1175 in C. */
1176 GCC_JIT_BINARY_OP_MULT,
1178 /* Quotient of division of arithmetic values; analogous to:
1179 (EXPR_A) / (EXPR_B)
1180 in C.
1181 The result type affects the kind of division: if the result type is
1182 integer-based, then the result is truncated towards zero, whereas
1183 a floating-point result type indicates floating-point division. */
1184 GCC_JIT_BINARY_OP_DIVIDE,
1186 /* Remainder of division of arithmetic values; analogous to:
1187 (EXPR_A) % (EXPR_B)
1188 in C. */
1189 GCC_JIT_BINARY_OP_MODULO,
1191 /* Bitwise AND; analogous to:
1192 (EXPR_A) & (EXPR_B)
1193 in C. */
1194 GCC_JIT_BINARY_OP_BITWISE_AND,
1196 /* Bitwise exclusive OR; analogous to:
1197 (EXPR_A) ^ (EXPR_B)
1198 in C. */
1199 GCC_JIT_BINARY_OP_BITWISE_XOR,
1201 /* Bitwise inclusive OR; analogous to:
1202 (EXPR_A) | (EXPR_B)
1203 in C. */
1204 GCC_JIT_BINARY_OP_BITWISE_OR,
1206 /* Logical AND; analogous to:
1207 (EXPR_A) && (EXPR_B)
1208 in C. */
1209 GCC_JIT_BINARY_OP_LOGICAL_AND,
1211 /* Logical OR; analogous to:
1212 (EXPR_A) || (EXPR_B)
1213 in C. */
1214 GCC_JIT_BINARY_OP_LOGICAL_OR,
1216 /* Left shift; analogous to:
1217 (EXPR_A) << (EXPR_B)
1218 in C. */
1219 GCC_JIT_BINARY_OP_LSHIFT,
1221 /* Right shift; analogous to:
1222 (EXPR_A) >> (EXPR_B)
1223 in C. */
1224 GCC_JIT_BINARY_OP_RSHIFT
1227 extern gcc_jit_rvalue *
1228 gcc_jit_context_new_binary_op (gcc_jit_context *ctxt,
1229 gcc_jit_location *loc,
1230 enum gcc_jit_binary_op op,
1231 gcc_jit_type *result_type,
1232 gcc_jit_rvalue *a, gcc_jit_rvalue *b);
1234 /* (Comparisons are treated as separate from "binary_op" to save
1235 you having to specify the result_type). */
1237 enum gcc_jit_comparison
1239 /* (EXPR_A) == (EXPR_B). */
1240 GCC_JIT_COMPARISON_EQ,
1242 /* (EXPR_A) != (EXPR_B). */
1243 GCC_JIT_COMPARISON_NE,
1245 /* (EXPR_A) < (EXPR_B). */
1246 GCC_JIT_COMPARISON_LT,
1248 /* (EXPR_A) <=(EXPR_B). */
1249 GCC_JIT_COMPARISON_LE,
1251 /* (EXPR_A) > (EXPR_B). */
1252 GCC_JIT_COMPARISON_GT,
1254 /* (EXPR_A) >= (EXPR_B). */
1255 GCC_JIT_COMPARISON_GE
1258 extern gcc_jit_rvalue *
1259 gcc_jit_context_new_comparison (gcc_jit_context *ctxt,
1260 gcc_jit_location *loc,
1261 enum gcc_jit_comparison op,
1262 gcc_jit_rvalue *a, gcc_jit_rvalue *b);
1264 /* Function calls. */
1266 /* Call of a specific function. */
1267 extern gcc_jit_rvalue *
1268 gcc_jit_context_new_call (gcc_jit_context *ctxt,
1269 gcc_jit_location *loc,
1270 gcc_jit_function *func,
1271 int numargs , gcc_jit_rvalue **args);
1273 /* Call through a function pointer. */
1274 extern gcc_jit_rvalue *
1275 gcc_jit_context_new_call_through_ptr (gcc_jit_context *ctxt,
1276 gcc_jit_location *loc,
1277 gcc_jit_rvalue *fn_ptr,
1278 int numargs, gcc_jit_rvalue **args);
1280 /* Type-coercion.
1282 Currently only a limited set of conversions are possible:
1283 int <-> float
1284 int <-> bool */
1285 extern gcc_jit_rvalue *
1286 gcc_jit_context_new_cast (gcc_jit_context *ctxt,
1287 gcc_jit_location *loc,
1288 gcc_jit_rvalue *rvalue,
1289 gcc_jit_type *type);
1291 #define LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast
1293 /* Reinterpret a value as another type.
1295 The types must be of the same size.
1297 This API entrypoint was added in LIBGCCJIT_ABI_21; you can test for its
1298 presence using
1299 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_bitcast */
1300 extern gcc_jit_rvalue *
1301 gcc_jit_context_new_bitcast (gcc_jit_context *ctxt,
1302 gcc_jit_location *loc,
1303 gcc_jit_rvalue *rvalue,
1304 gcc_jit_type *type);
1306 #define LIBGCCJIT_HAVE_ALIGNMENT
1308 /* Set the alignment of a variable.
1310 This API entrypoint was added in LIBGCCJIT_ABI_24; you can test for its
1311 presence using
1312 #ifdef LIBGCCJIT_HAVE_ALIGNMENT */
1313 extern void
1314 gcc_jit_lvalue_set_alignment (gcc_jit_lvalue *lvalue,
1315 unsigned bytes);
1317 /* Get the alignment of a variable.
1319 This API entrypoint was added in LIBGCCJIT_ABI_24; you can test for its
1320 presence using
1321 #ifdef LIBGCCJIT_HAVE_ALIGNMENT */
1322 extern unsigned
1323 gcc_jit_lvalue_get_alignment (gcc_jit_lvalue *lvalue);
1325 extern gcc_jit_lvalue *
1326 gcc_jit_context_new_array_access (gcc_jit_context *ctxt,
1327 gcc_jit_location *loc,
1328 gcc_jit_rvalue *ptr,
1329 gcc_jit_rvalue *index);
1331 /* Field access is provided separately for both lvalues and rvalues. */
1333 /* Accessing a field of an lvalue of struct type, analogous to:
1334 (EXPR).field = ...;
1335 in C. */
1336 extern gcc_jit_lvalue *
1337 gcc_jit_lvalue_access_field (gcc_jit_lvalue *struct_or_union,
1338 gcc_jit_location *loc,
1339 gcc_jit_field *field);
1341 /* Accessing a field of an rvalue of struct type, analogous to:
1342 (EXPR).field
1343 in C. */
1344 extern gcc_jit_rvalue *
1345 gcc_jit_rvalue_access_field (gcc_jit_rvalue *struct_or_union,
1346 gcc_jit_location *loc,
1347 gcc_jit_field *field);
1349 /* Accessing a field of an rvalue of pointer type, analogous to:
1350 (EXPR)->field
1351 in C, itself equivalent to (*EXPR).FIELD */
1352 extern gcc_jit_lvalue *
1353 gcc_jit_rvalue_dereference_field (gcc_jit_rvalue *ptr,
1354 gcc_jit_location *loc,
1355 gcc_jit_field *field);
1357 /* Dereferencing a pointer; analogous to:
1358 *(EXPR)
1360 extern gcc_jit_lvalue *
1361 gcc_jit_rvalue_dereference (gcc_jit_rvalue *rvalue,
1362 gcc_jit_location *loc);
1364 /* Taking the address of an lvalue; analogous to:
1365 &(EXPR)
1366 in C. */
1367 extern gcc_jit_rvalue *
1368 gcc_jit_lvalue_get_address (gcc_jit_lvalue *lvalue,
1369 gcc_jit_location *loc);
1371 #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model
1373 /* Set the thread-local storage model of a global variable
1375 This API entrypoint was added in LIBGCCJIT_ABI_17; you can test for its
1376 presence using
1377 #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_tls_model */
1378 extern void
1379 gcc_jit_lvalue_set_tls_model (gcc_jit_lvalue *lvalue,
1380 enum gcc_jit_tls_model model);
1382 #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section
1384 /* Set the link section of a global variable; analogous to:
1385 __attribute__((section(".section_name")))
1386 in C.
1388 This API entrypoint was added in LIBGCCJIT_ABI_18; you can test for its
1389 presence using
1390 #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_link_section
1392 extern void
1393 gcc_jit_lvalue_set_link_section (gcc_jit_lvalue *lvalue,
1394 const char *section_name);
1396 #define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_register_name
1398 /* Make this variable a register variable and set its register name.
1400 This API entrypoint was added in LIBGCCJIT_ABI_22; you can test for its
1401 presence using
1402 #ifdef LIBGCCJIT_HAVE_gcc_jit_lvalue_set_register_name
1404 void
1405 gcc_jit_lvalue_set_register_name (gcc_jit_lvalue *lvalue,
1406 const char *reg_name);
1408 extern gcc_jit_lvalue *
1409 gcc_jit_function_new_local (gcc_jit_function *func,
1410 gcc_jit_location *loc,
1411 gcc_jit_type *type,
1412 const char *name);
1414 /**********************************************************************
1415 Statement-creation.
1416 **********************************************************************/
1418 /* Add evaluation of an rvalue, discarding the result
1419 (e.g. a function call that "returns" void).
1421 This is equivalent to this C code:
1423 (void)expression;
1425 extern void
1426 gcc_jit_block_add_eval (gcc_jit_block *block,
1427 gcc_jit_location *loc,
1428 gcc_jit_rvalue *rvalue);
1430 /* Add evaluation of an rvalue, assigning the result to the given
1431 lvalue.
1433 This is roughly equivalent to this C code:
1435 lvalue = rvalue;
1437 extern void
1438 gcc_jit_block_add_assignment (gcc_jit_block *block,
1439 gcc_jit_location *loc,
1440 gcc_jit_lvalue *lvalue,
1441 gcc_jit_rvalue *rvalue);
1443 /* Add evaluation of an rvalue, using the result to modify an
1444 lvalue.
1446 This is analogous to "+=" and friends:
1448 lvalue += rvalue;
1449 lvalue *= rvalue;
1450 lvalue /= rvalue;
1451 etc */
1452 extern void
1453 gcc_jit_block_add_assignment_op (gcc_jit_block *block,
1454 gcc_jit_location *loc,
1455 gcc_jit_lvalue *lvalue,
1456 enum gcc_jit_binary_op op,
1457 gcc_jit_rvalue *rvalue);
1459 /* Add a no-op textual comment to the internal representation of the
1460 code. It will be optimized away, but will be visible in the dumps
1461 seen via
1462 GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE
1464 GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE,
1465 and thus may be of use when debugging how your project's internal
1466 representation gets converted to the libgccjit IR. */
1467 extern void
1468 gcc_jit_block_add_comment (gcc_jit_block *block,
1469 gcc_jit_location *loc,
1470 const char *text);
1472 /* Terminate a block by adding evaluation of an rvalue, branching on the
1473 result to the appropriate successor block.
1475 This is roughly equivalent to this C code:
1477 if (boolval)
1478 goto on_true;
1479 else
1480 goto on_false;
1482 block, boolval, on_true, and on_false must be non-NULL. */
1483 extern void
1484 gcc_jit_block_end_with_conditional (gcc_jit_block *block,
1485 gcc_jit_location *loc,
1486 gcc_jit_rvalue *boolval,
1487 gcc_jit_block *on_true,
1488 gcc_jit_block *on_false);
1490 /* Terminate a block by adding a jump to the given target block.
1492 This is roughly equivalent to this C code:
1494 goto target;
1496 extern void
1497 gcc_jit_block_end_with_jump (gcc_jit_block *block,
1498 gcc_jit_location *loc,
1499 gcc_jit_block *target);
1501 /* Terminate a block by adding evaluation of an rvalue, returning the value.
1503 This is roughly equivalent to this C code:
1505 return expression;
1507 extern void
1508 gcc_jit_block_end_with_return (gcc_jit_block *block,
1509 gcc_jit_location *loc,
1510 gcc_jit_rvalue *rvalue);
1512 /* Terminate a block by adding a valueless return, for use within a function
1513 with "void" return type.
1515 This is equivalent to this C code:
1517 return;
1519 extern void
1520 gcc_jit_block_end_with_void_return (gcc_jit_block *block,
1521 gcc_jit_location *loc);
1523 /* Create a new gcc_jit_case instance for use in a switch statement.
1524 min_value and max_value must be constants of integer type.
1526 This API entrypoint was added in LIBGCCJIT_ABI_3; you can test for its
1527 presence using
1528 #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS
1530 extern gcc_jit_case *
1531 gcc_jit_context_new_case (gcc_jit_context *ctxt,
1532 gcc_jit_rvalue *min_value,
1533 gcc_jit_rvalue *max_value,
1534 gcc_jit_block *dest_block);
1536 /* Upcasting from case to object.
1538 This API entrypoint was added in LIBGCCJIT_ABI_3; you can test for its
1539 presence using
1540 #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS
1543 extern gcc_jit_object *
1544 gcc_jit_case_as_object (gcc_jit_case *case_);
1546 /* Terminate a block by adding evalation of an rvalue, then performing
1547 a multiway branch.
1549 This is roughly equivalent to this C code:
1551 switch (expr)
1553 default:
1554 goto default_block;
1556 case C0.min_value ... C0.max_value:
1557 goto C0.dest_block;
1559 case C1.min_value ... C1.max_value:
1560 goto C1.dest_block;
1562 ...etc...
1564 case C[N - 1].min_value ... C[N - 1].max_value:
1565 goto C[N - 1].dest_block;
1568 block, expr, default_block and cases must all be non-NULL.
1570 expr must be of the same integer type as all of the min_value
1571 and max_value within the cases.
1573 num_cases must be >= 0.
1575 The ranges of the cases must not overlap (or have duplicate
1576 values).
1578 This API entrypoint was added in LIBGCCJIT_ABI_3; you can test for its
1579 presence using
1580 #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS
1583 extern void
1584 gcc_jit_block_end_with_switch (gcc_jit_block *block,
1585 gcc_jit_location *loc,
1586 gcc_jit_rvalue *expr,
1587 gcc_jit_block *default_block,
1588 int num_cases,
1589 gcc_jit_case **cases);
1591 /* Pre-canned feature macro to indicate the presence of
1592 gcc_jit_block_end_with_switch, gcc_jit_case_as_object, and
1593 gcc_jit_context_new_case.
1595 This can be tested for with #ifdef. */
1596 #define LIBGCCJIT_HAVE_SWITCH_STATEMENTS
1598 /**********************************************************************
1599 Nested contexts.
1600 **********************************************************************/
1602 /* Given an existing JIT context, create a child context.
1604 The child inherits a copy of all option-settings from the parent.
1606 The child can reference objects created within the parent, but not
1607 vice-versa.
1609 The lifetime of the child context must be bounded by that of the
1610 parent: you should release a child context before releasing the parent
1611 context.
1613 If you use a function from a parent context within a child context,
1614 you have to compile the parent context before you can compile the
1615 child context, and the gcc_jit_result of the parent context must
1616 outlive the gcc_jit_result of the child context.
1618 This allows caching of shared initializations. For example, you could
1619 create types and declarations of global functions in a parent context
1620 once within a process, and then create child contexts whenever a
1621 function or loop becomes hot. Each such child context can be used for
1622 JIT-compiling just one function or loop, but can reference types
1623 and helper functions created within the parent context.
1625 Contexts can be arbitrarily nested, provided the above rules are
1626 followed, but it's probably not worth going above 2 or 3 levels, and
1627 there will likely be a performance hit for such nesting. */
1629 extern gcc_jit_context *
1630 gcc_jit_context_new_child_context (gcc_jit_context *parent_ctxt);
1632 /**********************************************************************
1633 Implementation support.
1634 **********************************************************************/
1636 /* Write C source code into "path" that can be compiled into a
1637 self-contained executable (i.e. with libgccjit as the only dependency).
1638 The generated code will attempt to replay the API calls that have been
1639 made into the given context.
1641 This may be useful when debugging the library or client code, for
1642 reducing a complicated recipe for reproducing a bug into a simpler
1643 form.
1645 Typically you need to supply the option "-Wno-unused-variable" when
1646 compiling the generated file (since the result of each API call is
1647 assigned to a unique variable within the generated C source, and not
1648 all are necessarily then used). */
1650 extern void
1651 gcc_jit_context_dump_reproducer_to_file (gcc_jit_context *ctxt,
1652 const char *path);
1654 /* Enable the dumping of a specific set of internal state from the
1655 compilation, capturing the result in-memory as a buffer.
1657 Parameter "dumpname" corresponds to the equivalent gcc command-line
1658 option, without the "-fdump-" prefix.
1659 For example, to get the equivalent of "-fdump-tree-vrp1", supply
1660 "tree-vrp1".
1661 The context directly stores the dumpname as a (const char *), so the
1662 passed string must outlive the context.
1664 gcc_jit_context_compile and gcc_jit_context_to_file
1665 will capture the dump as a dynamically-allocated buffer, writing
1666 it to ``*out_ptr``.
1668 The caller becomes responsible for calling
1669 free (*out_ptr)
1670 each time that gcc_jit_context_compile or gcc_jit_context_to_file
1671 are called. *out_ptr will be written to, either with the address of a
1672 buffer, or with NULL if an error occurred.
1674 This API entrypoint is likely to be less stable than the others.
1675 In particular, both the precise dumpnames, and the format and content
1676 of the dumps are subject to change.
1678 It exists primarily for writing the library's own test suite. */
1680 extern void
1681 gcc_jit_context_enable_dump (gcc_jit_context *ctxt,
1682 const char *dumpname,
1683 char **out_ptr);
1685 /**********************************************************************
1686 Timing support.
1687 **********************************************************************/
1689 /* The timing API was added in LIBGCCJIT_ABI_4; you can test for its
1690 presence using
1691 #ifdef LIBGCCJIT_HAVE_TIMING_API
1693 #define LIBGCCJIT_HAVE_TIMING_API
1695 typedef struct gcc_jit_timer gcc_jit_timer;
1697 /* Create a gcc_jit_timer instance, and start timing.
1699 This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
1700 presence using
1701 #ifdef LIBGCCJIT_HAVE_TIMING_API
1703 extern gcc_jit_timer *
1704 gcc_jit_timer_new (void);
1706 /* Release a gcc_jit_timer instance.
1708 This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
1709 presence using
1710 #ifdef LIBGCCJIT_HAVE_TIMING_API
1712 extern void
1713 gcc_jit_timer_release (gcc_jit_timer *timer);
1715 /* Associate a gcc_jit_timer instance with a context.
1717 This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
1718 presence using
1719 #ifdef LIBGCCJIT_HAVE_TIMING_API
1721 extern void
1722 gcc_jit_context_set_timer (gcc_jit_context *ctxt,
1723 gcc_jit_timer *timer);
1725 /* Get the timer associated with a context (if any).
1727 This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
1728 presence using
1729 #ifdef LIBGCCJIT_HAVE_TIMING_API
1732 extern gcc_jit_timer *
1733 gcc_jit_context_get_timer (gcc_jit_context *ctxt);
1735 /* Push the given item onto the timing stack.
1737 This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
1738 presence using
1739 #ifdef LIBGCCJIT_HAVE_TIMING_API
1742 extern void
1743 gcc_jit_timer_push (gcc_jit_timer *timer,
1744 const char *item_name);
1746 /* Pop the top item from the timing stack.
1748 This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
1749 presence using
1750 #ifdef LIBGCCJIT_HAVE_TIMING_API
1753 extern void
1754 gcc_jit_timer_pop (gcc_jit_timer *timer,
1755 const char *item_name);
1757 /* Print timing information to the given stream about activity since
1758 the timer was started.
1760 This API entrypoint was added in LIBGCCJIT_ABI_4; you can test for its
1761 presence using
1762 #ifdef LIBGCCJIT_HAVE_TIMING_API
1765 extern void
1766 gcc_jit_timer_print (gcc_jit_timer *timer,
1767 FILE *f_out);
1770 #define LIBGCCJIT_HAVE_gcc_jit_rvalue_set_bool_require_tail_call
1772 /* Mark/clear a call as needing tail-call optimization.
1774 This API entrypoint was added in LIBGCCJIT_ABI_6; you can test for its
1775 presence using
1776 #ifdef LIBGCCJIT_HAVE_gcc_jit_rvalue_set_bool_require_tail_call
1778 extern void
1779 gcc_jit_rvalue_set_bool_require_tail_call (gcc_jit_rvalue *call,
1780 int require_tail_call);
1782 #define LIBGCCJIT_HAVE_gcc_jit_type_get_aligned
1784 /* Given type "T", get type:
1786 T __attribute__ ((aligned (ALIGNMENT_IN_BYTES)))
1788 The alignment must be a power of two.
1790 This API entrypoint was added in LIBGCCJIT_ABI_7; you can test for its
1791 presence using
1792 #ifdef LIBGCCJIT_HAVE_gcc_jit_type_get_aligned
1794 extern gcc_jit_type *
1795 gcc_jit_type_get_aligned (gcc_jit_type *type,
1796 size_t alignment_in_bytes);
1798 #define LIBGCCJIT_HAVE_gcc_jit_type_get_vector
1800 /* Given type "T", get type:
1802 T __attribute__ ((vector_size (sizeof(T) * num_units))
1804 T must be integral/floating point; num_units must be a power of two.
1806 This API entrypoint was added in LIBGCCJIT_ABI_8; you can test for its
1807 presence using
1808 #ifdef LIBGCCJIT_HAVE_gcc_jit_type_get_vector
1810 extern gcc_jit_type *
1811 gcc_jit_type_get_vector (gcc_jit_type *type, size_t num_units);
1814 #define LIBGCCJIT_HAVE_gcc_jit_function_get_address
1816 /* Get the address of a function as an rvalue, of function pointer
1817 type.
1819 This API entrypoint was added in LIBGCCJIT_ABI_9; you can test for its
1820 presence using
1821 #ifdef LIBGCCJIT_HAVE_gcc_jit_function_get_address
1823 extern gcc_jit_rvalue *
1824 gcc_jit_function_get_address (gcc_jit_function *fn,
1825 gcc_jit_location *loc);
1828 #define LIBGCCJIT_HAVE_gcc_jit_context_new_rvalue_from_vector
1830 /* Build a vector rvalue from an array of elements.
1832 "vec_type" should be a vector type, created using gcc_jit_type_get_vector.
1834 This API entrypoint was added in LIBGCCJIT_ABI_10; you can test for its
1835 presence using
1836 #ifdef LIBGCCJIT_HAVE_gcc_jit_context_new_rvalue_from_vector
1838 extern gcc_jit_rvalue *
1839 gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt,
1840 gcc_jit_location *loc,
1841 gcc_jit_type *vec_type,
1842 size_t num_elements,
1843 gcc_jit_rvalue **elements);
1845 #define LIBGCCJIT_HAVE_gcc_jit_version
1847 /* Functions to retrieve libgccjit version.
1848 Analogous to __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ in C code.
1850 These API entrypoints were added in LIBGCCJIT_ABI_13; you can test for their
1851 presence using
1852 #ifdef LIBGCCJIT_HAVE_gcc_jit_version
1854 extern int
1855 gcc_jit_version_major (void);
1856 extern int
1857 gcc_jit_version_minor (void);
1858 extern int
1859 gcc_jit_version_patchlevel (void);
1861 /**********************************************************************
1862 Asm support.
1863 **********************************************************************/
1865 /* Functions for adding inline assembler code, analogous to GCC's
1866 "extended asm" syntax.
1868 See https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html
1870 These API entrypoints were added in LIBGCCJIT_ABI_15; you can test for their
1871 presence using
1872 #ifdef LIBGCCJIT_HAVE_ASM_STATEMENTS
1875 #define LIBGCCJIT_HAVE_ASM_STATEMENTS
1877 /* Create a gcc_jit_extended_asm for an extended asm statement
1878 with no control flow (i.e. without the goto qualifier).
1880 The asm_template parameter corresponds to the AssemblerTemplate
1881 within C's extended asm syntax. It must be non-NULL. */
1883 extern gcc_jit_extended_asm *
1884 gcc_jit_block_add_extended_asm (gcc_jit_block *block,
1885 gcc_jit_location *loc,
1886 const char *asm_template);
1888 /* Create a gcc_jit_extended_asm for an extended asm statement
1889 that may perform jumps, and use it to terminate the given block.
1890 This is equivalent to the "goto" qualifier in C's extended asm
1891 syntax. */
1893 extern gcc_jit_extended_asm *
1894 gcc_jit_block_end_with_extended_asm_goto (gcc_jit_block *block,
1895 gcc_jit_location *loc,
1896 const char *asm_template,
1897 int num_goto_blocks,
1898 gcc_jit_block **goto_blocks,
1899 gcc_jit_block *fallthrough_block);
1901 /* Upcasting from extended asm to object. */
1903 extern gcc_jit_object *
1904 gcc_jit_extended_asm_as_object (gcc_jit_extended_asm *ext_asm);
1906 /* Set whether the gcc_jit_extended_asm has side-effects, equivalent to
1907 the "volatile" qualifier in C's extended asm syntax. */
1909 extern void
1910 gcc_jit_extended_asm_set_volatile_flag (gcc_jit_extended_asm *ext_asm,
1911 int flag);
1913 /* Set the equivalent of the "inline" qualifier in C's extended asm
1914 syntax. */
1916 extern void
1917 gcc_jit_extended_asm_set_inline_flag (gcc_jit_extended_asm *ext_asm,
1918 int flag);
1920 /* Add an output operand to the extended asm statement.
1921 "asm_symbolic_name" can be NULL.
1922 "constraint" and "dest" must be non-NULL.
1923 This function can't be called on an "asm goto" as such instructions
1924 can't have outputs */
1926 extern void
1927 gcc_jit_extended_asm_add_output_operand (gcc_jit_extended_asm *ext_asm,
1928 const char *asm_symbolic_name,
1929 const char *constraint,
1930 gcc_jit_lvalue *dest);
1932 /* Add an input operand to the extended asm statement.
1933 "asm_symbolic_name" can be NULL.
1934 "constraint" and "src" must be non-NULL. */
1936 extern void
1937 gcc_jit_extended_asm_add_input_operand (gcc_jit_extended_asm *ext_asm,
1938 const char *asm_symbolic_name,
1939 const char *constraint,
1940 gcc_jit_rvalue *src);
1942 /* Add "victim" to the list of registers clobbered by the extended
1943 asm statement. It must be non-NULL. */
1945 extern void
1946 gcc_jit_extended_asm_add_clobber (gcc_jit_extended_asm *ext_asm,
1947 const char *victim);
1949 /* Add "asm_stmts", a set of top-level asm statements, analogous to
1950 those created by GCC's "basic" asm syntax in C at file scope. */
1952 extern void
1953 gcc_jit_context_add_top_level_asm (gcc_jit_context *ctxt,
1954 gcc_jit_location *loc,
1955 const char *asm_stmts);
1957 #define LIBGCCJIT_HAVE_REFLECTION
1959 /* Reflection functions to get the number of parameters, return type of
1960 a function and whether a type is a bool from the C API.
1962 This API entrypoint was added in LIBGCCJIT_ABI_16; you can test for its
1963 presence using
1964 #ifdef LIBGCCJIT_HAVE_REFLECTION
1966 /* Get the return type of a function. */
1967 extern gcc_jit_type *
1968 gcc_jit_function_get_return_type (gcc_jit_function *func);
1970 /* Get the number of params of a function. */
1971 extern size_t
1972 gcc_jit_function_get_param_count (gcc_jit_function *func);
1974 /* Get the element type of an array type or NULL if it's not an array. */
1975 extern gcc_jit_type *
1976 gcc_jit_type_dyncast_array (gcc_jit_type *type);
1978 /* Return non-zero if the type is a bool. */
1979 extern int
1980 gcc_jit_type_is_bool (gcc_jit_type *type);
1982 /* Return the function type if it is one or NULL. */
1983 extern gcc_jit_function_type *
1984 gcc_jit_type_dyncast_function_ptr_type (gcc_jit_type *type);
1986 /* Given a function type, return its return type. */
1987 extern gcc_jit_type *
1988 gcc_jit_function_type_get_return_type (gcc_jit_function_type *function_type);
1990 /* Given a function type, return its number of parameters. */
1991 extern size_t
1992 gcc_jit_function_type_get_param_count (gcc_jit_function_type *function_type);
1994 /* Given a function type, return the type of the specified parameter. */
1995 extern gcc_jit_type *
1996 gcc_jit_function_type_get_param_type (gcc_jit_function_type *function_type,
1997 size_t index);
1999 /* Return non-zero if the type is an integral. */
2000 extern int
2001 gcc_jit_type_is_integral (gcc_jit_type *type);
2003 /* Return the type pointed by the pointer type or NULL if it's not a
2004 * pointer. */
2005 extern gcc_jit_type *
2006 gcc_jit_type_is_pointer (gcc_jit_type *type);
2008 /* Given a type, return a dynamic cast to a vector type or NULL. */
2009 extern gcc_jit_vector_type *
2010 gcc_jit_type_dyncast_vector (gcc_jit_type *type);
2012 /* Given a type, return a dynamic cast to a struct type or NULL. */
2013 extern gcc_jit_struct *
2014 gcc_jit_type_is_struct (gcc_jit_type *type);
2016 /* Given a vector type, return the number of units it contains. */
2017 extern size_t
2018 gcc_jit_vector_type_get_num_units (gcc_jit_vector_type *vector_type);
2020 /* Given a vector type, return the type of its elements. */
2021 extern gcc_jit_type *
2022 gcc_jit_vector_type_get_element_type (gcc_jit_vector_type *vector_type);
2024 /* Given a type, return the unqualified type, removing "const", "volatile"
2025 * and alignment qualifiers. */
2026 extern gcc_jit_type *
2027 gcc_jit_type_unqualified (gcc_jit_type *type);
2029 #define LIBGCCJIT_HAVE_ATTRIBUTES
2031 /* Function attributes. */
2032 enum gcc_jit_fn_attribute
2034 GCC_JIT_FN_ATTRIBUTE_ALIAS,
2035 GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
2036 GCC_JIT_FN_ATTRIBUTE_INLINE,
2037 GCC_JIT_FN_ATTRIBUTE_NOINLINE,
2038 GCC_JIT_FN_ATTRIBUTE_TARGET,
2039 GCC_JIT_FN_ATTRIBUTE_USED,
2040 GCC_JIT_FN_ATTRIBUTE_VISIBILITY,
2041 GCC_JIT_FN_ATTRIBUTE_COLD,
2042 GCC_JIT_FN_ATTRIBUTE_RETURNS_TWICE,
2043 GCC_JIT_FN_ATTRIBUTE_PURE,
2044 GCC_JIT_FN_ATTRIBUTE_CONST,
2045 GCC_JIT_FN_ATTRIBUTE_WEAK,
2046 GCC_JIT_FN_ATTRIBUTE_NONNULL,
2048 /* Maximum value of this enum, should always be last. */
2049 GCC_JIT_FN_ATTRIBUTE_MAX,
2052 /* Add an attribute to a function. */
2053 extern void
2054 gcc_jit_function_add_attribute (gcc_jit_function *func,
2055 enum gcc_jit_fn_attribute attribute);
2057 extern void
2058 gcc_jit_function_add_string_attribute (gcc_jit_function *func,
2059 enum gcc_jit_fn_attribute attribute,
2060 const char* value);
2062 extern void
2063 gcc_jit_function_add_integer_array_attribute (
2064 gcc_jit_function *func,
2065 enum gcc_jit_fn_attribute attribute,
2066 const int* value,
2067 size_t length);
2069 /* Variable attributes. */
2070 enum gcc_jit_variable_attribute
2072 GCC_JIT_VARIABLE_ATTRIBUTE_VISIBILITY,
2074 /* Maximum value of this enum, should always be last. */
2075 GCC_JIT_VARIABLE_ATTRIBUTE_MAX,
2078 /* Add a string attribute to a variable. */
2079 extern void
2080 gcc_jit_lvalue_add_string_attribute (gcc_jit_lvalue *variable,
2081 enum gcc_jit_variable_attribute attribute,
2082 const char* value);
2084 #ifdef __cplusplus
2086 #endif /* __cplusplus */
2088 #endif /* LIBGCCJIT_H */