From: Rhys Weatherley Date: Sun, 2 May 2004 23:41:50 +0000 (+0000) Subject: Add more instances of JIT_NOTHROW to the headers; add some special X-Git-Tag: r.0.0.2~37 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=39313ed057d8965baba6f4bbe9a1b7cf5d1cf80c;p=francis%2Flibjit.git Add more instances of JIT_NOTHROW to the headers; add some special meta tags for types. --- diff --git a/ChangeLog b/ChangeLog index 402abb9..6718c91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,12 @@ * tools/gen-apply.c: improve the maintainability of the apply macros. + * include/jit/jit-block.h, include/jit/jit-context.h, + include/jit/jit-dump.h, include/jit/jit-elf.h, include/jit/jit-init.h, + include/jit/jit-meta.h, include/jit/jit-type.h, include/jit/jit-util.h, + jit/jit-type.c, jit/jit-value.c: add more instances of JIT_NOTHROW + to the headers; add some special meta tags for types. + 2004-05-01 Rhys Weatherley * jit/jit-apply-x86.c, jit/jit-rules-x86.c, tools/gen-apply.c: diff --git a/include/jit/jit-block.h b/include/jit/jit-block.h index 886ad52..d51dcd3 100644 --- a/include/jit/jit-block.h +++ b/include/jit/jit-block.h @@ -27,17 +27,20 @@ extern "C" { #endif -jit_function_t jit_block_get_function(jit_block_t block); -jit_context_t jit_block_get_context(jit_block_t block); -jit_label_t jit_block_get_label(jit_block_t block); -jit_block_t jit_block_next(jit_function_t func, jit_block_t previous); -jit_block_t jit_block_previous(jit_function_t func, jit_block_t previous); -jit_block_t jit_block_from_label(jit_function_t func, jit_label_t label); +jit_function_t jit_block_get_function(jit_block_t block) JIT_NOTHROW; +jit_context_t jit_block_get_context(jit_block_t block) JIT_NOTHROW; +jit_label_t jit_block_get_label(jit_block_t block) JIT_NOTHROW; +jit_block_t jit_block_next + (jit_function_t func, jit_block_t previous) JIT_NOTHROW; +jit_block_t jit_block_previous + (jit_function_t func, jit_block_t previous) JIT_NOTHROW; +jit_block_t jit_block_from_label + (jit_function_t func, jit_label_t label) JIT_NOTHROW; int jit_block_set_meta(jit_block_t block, int type, void *data, - jit_meta_free_func free_data); -void *jit_block_get_meta(jit_block_t block, int type); -void jit_block_free_meta(jit_block_t block, int type); -int jit_block_is_reachable(jit_block_t block); + jit_meta_free_func free_data) JIT_NOTHROW; +void *jit_block_get_meta(jit_block_t block, int type) JIT_NOTHROW; +void jit_block_free_meta(jit_block_t block, int type) JIT_NOTHROW; +int jit_block_is_reachable(jit_block_t block) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/include/jit/jit-context.h b/include/jit/jit-context.h index 6f52800..3acedeb 100644 --- a/include/jit/jit-context.h +++ b/include/jit/jit-context.h @@ -27,19 +27,20 @@ extern "C" { #endif -jit_context_t jit_context_create(void); -void jit_context_destroy(jit_context_t context); -int jit_context_supports_threads(jit_context_t context); -void jit_context_build_start(jit_context_t context); -void jit_context_build_end(jit_context_t context); +jit_context_t jit_context_create(void) JIT_NOTHROW; +void jit_context_destroy(jit_context_t context) JIT_NOTHROW; +int jit_context_supports_threads(jit_context_t context) JIT_NOTHROW; +void jit_context_build_start(jit_context_t context) JIT_NOTHROW; +void jit_context_build_end(jit_context_t context) JIT_NOTHROW; int jit_context_set_meta (jit_context_t context, int type, void *data, - jit_meta_free_func free_data); + jit_meta_free_func free_data) JIT_NOTHROW; int jit_context_set_meta_numeric - (jit_context_t context, int type, jit_nuint data); -void *jit_context_get_meta(jit_context_t context, int type); -jit_nuint jit_context_get_meta_numeric(jit_context_t context, int type); -void jit_context_free_meta(jit_context_t context, int type); + (jit_context_t context, int type, jit_nuint data) JIT_NOTHROW; +void *jit_context_get_meta(jit_context_t context, int type) JIT_NOTHROW; +jit_nuint jit_context_get_meta_numeric + (jit_context_t context, int type) JIT_NOTHROW; +void jit_context_free_meta(jit_context_t context, int type) JIT_NOTHROW; /* * Standard meta values for builtin configurable options. diff --git a/include/jit/jit-dump.h b/include/jit/jit-dump.h index d036f32..ae6711e 100644 --- a/include/jit/jit-dump.h +++ b/include/jit/jit-dump.h @@ -28,11 +28,14 @@ extern "C" { #endif -void jit_dump_type(FILE *stream, jit_type_t type); -void jit_dump_value(FILE *stream, jit_function_t func, - jit_value_t value, const char *prefix); -void jit_dump_insn(FILE *stream, jit_function_t func, jit_insn_t insn); -void jit_dump_function(FILE *stream, jit_function_t func, const char *name); +void jit_dump_type(FILE *stream, jit_type_t type) JIT_NOTHROW; +void jit_dump_value + (FILE *stream, jit_function_t func, + jit_value_t value, const char *prefix) JIT_NOTHROW; +void jit_dump_insn + (FILE *stream, jit_function_t func, jit_insn_t insn) JIT_NOTHROW; +void jit_dump_function + (FILE *stream, jit_function_t func, const char *name) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/include/jit/jit-elf.h b/include/jit/jit-elf.h index eff30ed..84d78d4 100644 --- a/include/jit/jit-elf.h +++ b/include/jit/jit-elf.h @@ -52,30 +52,38 @@ typedef struct jit_writeelf *jit_writeelf_t; /* * External function declarations. */ -int jit_readelf_open(jit_readelf_t *readelf, const char *filename, int flags); -void jit_readelf_close(jit_readelf_t readelf); -const char *jit_readelf_get_name(jit_readelf_t readelf); -void *jit_readelf_get_symbol(jit_readelf_t readelf, const char *name); +int jit_readelf_open + (jit_readelf_t *readelf, const char *filename, int flags) JIT_NOTHROW; +void jit_readelf_close(jit_readelf_t readelf) JIT_NOTHROW; +const char *jit_readelf_get_name(jit_readelf_t readelf) JIT_NOTHROW; +void *jit_readelf_get_symbol + (jit_readelf_t readelf, const char *name) JIT_NOTHROW; void *jit_readelf_get_section - (jit_readelf_t readelf, const char *name, jit_nuint *size); + (jit_readelf_t readelf, const char *name, jit_nuint *size) JIT_NOTHROW; void *jit_readelf_get_section_by_type - (jit_readelf_t readelf, jit_int type, jit_nuint *size); -void *jit_readelf_map_vaddr(jit_readelf_t readelf, jit_nuint vaddr); -unsigned int jit_readelf_num_needed(jit_readelf_t readelf); -const char *jit_readelf_get_needed(jit_readelf_t readelf, unsigned int index); -void jit_readelf_add_to_context(jit_readelf_t readelf, jit_context_t context); -int jit_readelf_resolve_all(jit_context_t context, int print_failures); + (jit_readelf_t readelf, jit_int type, jit_nuint *size) JIT_NOTHROW; +void *jit_readelf_map_vaddr + (jit_readelf_t readelf, jit_nuint vaddr) JIT_NOTHROW; +unsigned int jit_readelf_num_needed(jit_readelf_t readelf) JIT_NOTHROW; +const char *jit_readelf_get_needed + (jit_readelf_t readelf, unsigned int index) JIT_NOTHROW; +void jit_readelf_add_to_context + (jit_readelf_t readelf, jit_context_t context) JIT_NOTHROW; +int jit_readelf_resolve_all + (jit_context_t context, int print_failures) JIT_NOTHROW; -jit_writeelf_t jit_writeelf_create(const char *library_name); -void jit_writeelf_destroy(jit_writeelf_t writeelf); -int jit_writeelf_write(jit_writeelf_t writeelf, const char *filename); +jit_writeelf_t jit_writeelf_create(const char *library_name) JIT_NOTHROW; +void jit_writeelf_destroy(jit_writeelf_t writeelf) JIT_NOTHROW; +int jit_writeelf_write + (jit_writeelf_t writeelf, const char *filename) JIT_NOTHROW; int jit_writeelf_add_function - (jit_writeelf_t writeelf, jit_function_t func, const char *name); + (jit_writeelf_t writeelf, jit_function_t func, + const char *name) JIT_NOTHROW; int jit_writeelf_add_needed - (jit_writeelf_t writeelf, const char *library_name); + (jit_writeelf_t writeelf, const char *library_name) JIT_NOTHROW; int jit_writeelf_write_section (jit_writeelf_t writeelf, const char *name, jit_int type, - const void *buf, unsigned int len, int discardable); + const void *buf, unsigned int len, int discardable) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/include/jit/jit-init.h b/include/jit/jit-init.h index e05215d..efe0601 100644 --- a/include/jit/jit-init.h +++ b/include/jit/jit-init.h @@ -21,12 +21,14 @@ #ifndef _JIT_INIT_H #define _JIT_INIT_H +#include + #ifdef __cplusplus extern "C" { #endif -void jit_init(void); -int jit_uses_interpreter(void); +void jit_init(void) JIT_NOTHROW; +int jit_uses_interpreter(void) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/include/jit/jit-meta.h b/include/jit/jit-meta.h index b113a79..75c8732 100644 --- a/include/jit/jit-meta.h +++ b/include/jit/jit-meta.h @@ -21,17 +21,20 @@ #ifndef _JIT_META_H #define _JIT_META_H +#include + #ifdef __cplusplus extern "C" { #endif typedef struct _jit_meta *jit_meta_t; -int jit_meta_set(jit_meta_t *list, int type, void *data, - jit_meta_free_func free_data, jit_function_t pool_owner); -void *jit_meta_get(jit_meta_t list, int type); -void jit_meta_free(jit_meta_t *list, int type); -void jit_meta_destroy(jit_meta_t *list); +int jit_meta_set + (jit_meta_t *list, int type, void *data, + jit_meta_free_func free_data, jit_function_t pool_owner) JIT_NOTHROW; +void *jit_meta_get(jit_meta_t list, int type) JIT_NOTHROW; +void jit_meta_free(jit_meta_t *list, int type) JIT_NOTHROW; +void jit_meta_destroy(jit_meta_t *list) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/include/jit/jit-type.h b/include/jit/jit-type.h index 324f14c..12ecab2 100644 --- a/include/jit/jit-type.h +++ b/include/jit/jit-type.h @@ -65,6 +65,16 @@ extern jit_type_t const jit_type_sys_float; extern jit_type_t const jit_type_sys_double; extern jit_type_t const jit_type_sys_long_double; +/* + * Special tag types. + */ +#define JIT_TYPETAG_NAME 10000 +#define JIT_TYPETAG_STRUCT_NAME 10001 +#define JIT_TYPETAG_CONST 10002 +#define JIT_TYPETAG_VOLATILE 10003 +#define JIT_TYPETAG_REFERENCE 10004 +#define JIT_TYPETAG_OUTPUT 10005 + /* * ABI types for function signatures. */ @@ -80,54 +90,60 @@ typedef enum /* * External function declarations. */ -jit_type_t jit_type_copy(jit_type_t type); -void jit_type_free(jit_type_t type); -jit_type_t jit_type_create_struct(jit_type_t *fields, unsigned int num_fields, - int incref); -jit_type_t jit_type_create_union(jit_type_t *fields, unsigned int num_fields, - int incref); -jit_type_t jit_type_create_signature(jit_abi_t abi, jit_type_t return_type, - jit_type_t *params, - unsigned int num_params, int incref); -jit_type_t jit_type_create_pointer(jit_type_t type, int incref); -jit_type_t jit_type_create_tagged(jit_type_t type, int kind, void *data, - jit_meta_free_func free_func, int incref); -int jit_type_set_names(jit_type_t type, char **names, unsigned int num_names); -void jit_type_set_size_and_alignment(jit_type_t type, jit_nint size, - jit_nint alignment); -void jit_type_set_offset(jit_type_t type, unsigned int field_index, - jit_nuint offset); -jit_nuint jit_type_get_size(jit_type_t type); -jit_nuint jit_type_get_alignment(jit_type_t type); -unsigned int jit_type_num_fields(jit_type_t type); -jit_type_t jit_type_get_field(jit_type_t type, unsigned int field_index); -jit_nuint jit_type_get_offset(jit_type_t type, unsigned int field_index); -const char *jit_type_get_name(jit_type_t type, unsigned int index); +jit_type_t jit_type_copy(jit_type_t type) JIT_NOTHROW; +void jit_type_free(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_create_struct + (jit_type_t *fields, unsigned int num_fields, int incref) JIT_NOTHROW; +jit_type_t jit_type_create_union + (jit_type_t *fields, unsigned int num_fields, int incref) JIT_NOTHROW; +jit_type_t jit_type_create_signature + (jit_abi_t abi, jit_type_t return_type, jit_type_t *params, + unsigned int num_params, int incref) JIT_NOTHROW; +jit_type_t jit_type_create_pointer(jit_type_t type, int incref) JIT_NOTHROW; +jit_type_t jit_type_create_tagged + (jit_type_t type, int kind, void *data, + jit_meta_free_func free_func, int incref) JIT_NOTHROW; +int jit_type_set_names + (jit_type_t type, char **names, unsigned int num_names) JIT_NOTHROW; +void jit_type_set_size_and_alignment + (jit_type_t type, jit_nint size, jit_nint alignment) JIT_NOTHROW; +void jit_type_set_offset + (jit_type_t type, unsigned int field_index, jit_nuint offset) JIT_NOTHROW; +jit_nuint jit_type_get_size(jit_type_t type) JIT_NOTHROW; +jit_nuint jit_type_get_alignment(jit_type_t type) JIT_NOTHROW; +unsigned int jit_type_num_fields(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_get_field + (jit_type_t type, unsigned int field_index) JIT_NOTHROW; +jit_nuint jit_type_get_offset + (jit_type_t type, unsigned int field_index) JIT_NOTHROW; +const char *jit_type_get_name(jit_type_t type, unsigned int index) JIT_NOTHROW; #define JIT_INVALID_NAME (~((unsigned int)0)) -unsigned int jit_type_find_name(jit_type_t type, const char *name); -unsigned int jit_type_num_params(jit_type_t type); -jit_type_t jit_type_get_return(jit_type_t type); -jit_type_t jit_type_get_param(jit_type_t type, unsigned int param_index); -jit_abi_t jit_type_get_abi(jit_type_t type); -jit_type_t jit_type_get_ref(jit_type_t type); -jit_type_t jit_type_get_tagged_type(jit_type_t type); -void jit_type_set_tagged_type(jit_type_t type, jit_type_t underlying, - int incref); -int jit_type_get_tagged_kind(jit_type_t type); -void *jit_type_get_tagged_data(jit_type_t type); -void jit_type_set_tagged_data(jit_type_t type, void *data, - jit_meta_free_func free_func); -int jit_type_is_primitive(jit_type_t type); -int jit_type_is_struct(jit_type_t type); -int jit_type_is_union(jit_type_t type); -int jit_type_is_signature(jit_type_t type); -int jit_type_is_pointer(jit_type_t type); -int jit_type_is_tagged(jit_type_t type); -jit_nuint jit_type_best_alignment(void); -jit_type_t jit_type_normalize(jit_type_t type); -jit_type_t jit_type_remove_tags(jit_type_t type); -jit_type_t jit_type_promote_int(jit_type_t type); -int jit_type_return_via_pointer(jit_type_t type); +unsigned int jit_type_find_name(jit_type_t type, const char *name) JIT_NOTHROW; +unsigned int jit_type_num_params(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_get_return(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_get_param + (jit_type_t type, unsigned int param_index) JIT_NOTHROW; +jit_abi_t jit_type_get_abi(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_get_ref(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_get_tagged_type(jit_type_t type) JIT_NOTHROW; +void jit_type_set_tagged_type + (jit_type_t type, jit_type_t underlying, int incref) JIT_NOTHROW; +int jit_type_get_tagged_kind(jit_type_t type) JIT_NOTHROW; +void *jit_type_get_tagged_data(jit_type_t type) JIT_NOTHROW; +void jit_type_set_tagged_data + (jit_type_t type, void *data, jit_meta_free_func free_func) JIT_NOTHROW; +int jit_type_is_primitive(jit_type_t type) JIT_NOTHROW; +int jit_type_is_struct(jit_type_t type) JIT_NOTHROW; +int jit_type_is_union(jit_type_t type) JIT_NOTHROW; +int jit_type_is_signature(jit_type_t type) JIT_NOTHROW; +int jit_type_is_pointer(jit_type_t type) JIT_NOTHROW; +int jit_type_is_tagged(jit_type_t type) JIT_NOTHROW; +jit_nuint jit_type_best_alignment(void) JIT_NOTHROW; +jit_type_t jit_type_normalize(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_remove_tags(jit_type_t type) JIT_NOTHROW; +jit_type_t jit_type_promote_int(jit_type_t type) JIT_NOTHROW; +int jit_type_return_via_pointer(jit_type_t type) JIT_NOTHROW; +int jit_type_has_tag(jit_type_t type, int kind) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/include/jit/jit-util.h b/include/jit/jit-util.h index ea9a056..167487d 100644 --- a/include/jit/jit-util.h +++ b/include/jit/jit-util.h @@ -30,58 +30,64 @@ extern "C" { /* * Memory allocation routines. */ -void *jit_malloc(unsigned int size); -void *jit_calloc(unsigned int num, unsigned int size); -void *jit_realloc(void *ptr, unsigned int size); -void jit_free(void *ptr); -void *jit_malloc_exec(unsigned int size); -void jit_free_exec(void *ptr, unsigned int size); -void jit_flush_exec(void *ptr, unsigned int size); -unsigned int jit_exec_page_size(void); +void *jit_malloc(unsigned int size) JIT_NOTHROW; +void *jit_calloc(unsigned int num, unsigned int size) JIT_NOTHROW; +void *jit_realloc(void *ptr, unsigned int size) JIT_NOTHROW; +void jit_free(void *ptr) JIT_NOTHROW; +void *jit_malloc_exec(unsigned int size) JIT_NOTHROW; +void jit_free_exec(void *ptr, unsigned int size) JIT_NOTHROW; +void jit_flush_exec(void *ptr, unsigned int size) JIT_NOTHROW; +unsigned int jit_exec_page_size(void) JIT_NOTHROW; #define jit_new(type) ((type *)jit_malloc(sizeof(type))) #define jit_cnew(type) ((type *)jit_calloc(1, sizeof(type))) /* * Memory set/copy/compare routines. */ -void *jit_memset(void *dest, int ch, unsigned int len); -void *jit_memcpy(void *dest, const void *src, unsigned int len); -void *jit_memmove(void *dest, const void *src, unsigned int len); -int jit_memcmp(const void *s1, const void *s2, unsigned int len); -void *jit_memchr(const void *str, int ch, unsigned int len); +void *jit_memset(void *dest, int ch, unsigned int len) JIT_NOTHROW; +void *jit_memcpy(void *dest, const void *src, unsigned int len) JIT_NOTHROW; +void *jit_memmove(void *dest, const void *src, unsigned int len) JIT_NOTHROW; +int jit_memcmp(const void *s1, const void *s2, unsigned int len) JIT_NOTHROW; +void *jit_memchr(const void *str, int ch, unsigned int len) JIT_NOTHROW; /* * String routines. Note: jit_stricmp uses fixed ASCII rules for case * comparison, whereas jit_stricoll uses localized rules. */ -unsigned int jit_strlen(const char *str); -char *jit_strcpy(char *dest, const char *src); -char *jit_strcat(char *dest, const char *src); -char *jit_strncpy(char *dest, const char *src, unsigned int len); -char *jit_strdup(const char *str); -char *jit_strndup(const char *str, unsigned int len); -int jit_strcmp(const char *str1, const char *str2); -int jit_strncmp(const char *str1, const char *str2, unsigned int len); -int jit_stricmp(const char *str1, const char *str2); -int jit_strnicmp(const char *str1, const char *str2, unsigned int len); -int jit_strcoll(const char *str1, const char *str2); -int jit_strncoll(const char *str1, const char *str2, unsigned int len); -int jit_stricoll(const char *str1, const char *str2); -int jit_strnicoll(const char *str1, const char *str2, unsigned int len); -char *jit_strchr(const char *str, int ch); -char *jit_strrchr(const char *str, int ch); -int jit_sprintf(char *str, const char *format, ...); -int jit_snprintf(char *str, unsigned int len, const char *format, ...); +unsigned int jit_strlen(const char *str) JIT_NOTHROW; +char *jit_strcpy(char *dest, const char *src) JIT_NOTHROW; +char *jit_strcat(char *dest, const char *src) JIT_NOTHROW; +char *jit_strncpy(char *dest, const char *src, unsigned int len) JIT_NOTHROW; +char *jit_strdup(const char *str) JIT_NOTHROW; +char *jit_strndup(const char *str, unsigned int len) JIT_NOTHROW; +int jit_strcmp(const char *str1, const char *str2) JIT_NOTHROW; +int jit_strncmp + (const char *str1, const char *str2, unsigned int len) JIT_NOTHROW; +int jit_stricmp(const char *str1, const char *str2) JIT_NOTHROW; +int jit_strnicmp + (const char *str1, const char *str2, unsigned int len) JIT_NOTHROW; +int jit_strcoll(const char *str1, const char *str2) JIT_NOTHROW; +int jit_strncoll + (const char *str1, const char *str2, unsigned int len) JIT_NOTHROW; +int jit_stricoll(const char *str1, const char *str2) JIT_NOTHROW; +int jit_strnicoll + (const char *str1, const char *str2, unsigned int len) JIT_NOTHROW; +char *jit_strchr(const char *str, int ch) JIT_NOTHROW; +char *jit_strrchr(const char *str, int ch) JIT_NOTHROW; +int jit_sprintf(char *str, const char *format, ...) JIT_NOTHROW; +int jit_snprintf + (char *str, unsigned int len, const char *format, ...) JIT_NOTHROW; /* * Dynamic library routines. */ typedef void *jit_dynlib_handle_t; -jit_dynlib_handle_t jit_dynlib_open(const char *name); -void jit_dynlib_close(jit_dynlib_handle_t handle); -void *jit_dynlib_get_symbol(jit_dynlib_handle_t handle, const char *symbol); -const char *jit_dynlib_get_suffix(void); -void jit_dynlib_set_debug(int flag); +jit_dynlib_handle_t jit_dynlib_open(const char *name) JIT_NOTHROW; +void jit_dynlib_close(jit_dynlib_handle_t handle) JIT_NOTHROW; +void *jit_dynlib_get_symbol + (jit_dynlib_handle_t handle, const char *symbol) JIT_NOTHROW; +const char *jit_dynlib_get_suffix(void) JIT_NOTHROW; +void jit_dynlib_set_debug(int flag) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/jit/jit-type.c b/jit/jit-type.c index 9a5554d..9c8b489 100644 --- a/jit/jit-type.c +++ b/jit/jit-type.c @@ -603,6 +603,46 @@ jit_type_t jit_type_create_pointer(jit_type_t type, int incref) * tag a type multiple times. The order in which multiple tags are * applied is irrelevant to @code{libjit}, although it may be relevant * to the higher-level program. + * + * Tag kinds of 10000 or greater are reserved for @code{libjit} itself. + * The following special tag kinds are currently provided in the + * base implementation: + * + * @table @code + * @vindex JIT_TYPETAG_NAME + * @item JIT_TYPETAG_NAME + * The @code{data} pointer is a @code{char *} string indicating a friendly + * name to display for the type. + * + * @vindex JIT_TYPETAG_STRUCT_NAME + * @item JIT_TYPETAG_STRUCT_NAME + * The @code{data} pointer is a @code{char *} string indicating a friendly + * name to display for a @code{struct} or @code{union} type. This is + * for languages like C that have separate naming scopes for typedef's and + * structures. + * + * @vindex JIT_TYPETAG_CONST + * @item JIT_TYPETAG_CONST + * The underlying value is assumed to have @code{const} semantics. + * The @code{libjit} library doesn't enforce such semantics: it is + * up to the front-end to only use constant values in appopriate contexts. + * + * @vindex JIT_TYPETAG_VOLATILE + * @item JIT_TYPETAG_VOLATILE + * The underlying value is assumed to be volatile. The @code{libjit} + * library will automatically call @code{jit_value_set_volatile} when a + * value is constructed using this type. + * + * @vindex JIT_TYPETAG_REFERENCE + * @item JIT_TYPETAG_REFERENCE + * The underlying value is a pointer, but it is assumed to refer to a + * pass-by-reference parameter. + * + * @vindex JIT_TYPETAG_OUTPUT + * @item JIT_TYPETAG_OUTPUT + * This is similar to @code{JIT_TYPETAG_REFERENCE}, except that the + * underlying parameter is assumed to be output-only. + * @end table * @end deftypefun @*/ jit_type_t jit_type_create_tagged(jit_type_t type, int kind, void *data, @@ -1321,3 +1361,22 @@ int jit_type_return_via_pointer(jit_type_t type) } return 1; } + +/*@ + * @deftypefun int jit_type_has_tag (jit_type_t type, int kind) + * Determine if @code{type} has a specific kind of tag. This will + * resolve multiple levels of tagging. + * @end deftypefun +@*/ +int jit_type_has_tag(jit_type_t type, int kind) +{ + while(type != 0 && type->kind >= JIT_TYPE_FIRST_TAGGED) + { + if(type->kind == (JIT_TYPE_FIRST_TAGGED + kind)) + { + return 1; + } + type = type->sub_type; + } + return 0; +} diff --git a/jit/jit-value.c b/jit/jit-value.c index 8bb7268..781c304 100644 --- a/jit/jit-value.c +++ b/jit/jit-value.c @@ -227,6 +227,10 @@ jit_value_t jit_value_create(jit_function_t func, jit_type_t type) return 0; } value->is_temporary = 1; + if(jit_type_has_tag(type, JIT_TYPETAG_VOLATILE)) + { + value->is_volatile = 1; + } return value; }