diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-15 13:15:50 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-15 13:15:50 +0100 |
| commit | e2e5641a450f4d7ea67eae468f1bd479361ec198 (patch) | |
| tree | 98574548de1b1c43ae3d5d409733f5fc3262f669 /src/tilde | |
| parent | ca442defbbaae4269ff947dfc14059f69a5cdaec (diff) | |
Update TB; Fix calling nullptr TB_Node* problems
Diffstat (limited to 'src/tilde')
| -rw-r--r-- | src/tilde/tb.h | 56 | ||||
| -rw-r--r-- | src/tilde/tb.lib | bin | 4295348 -> 4120106 bytes |
2 files changed, 26 insertions, 30 deletions
diff --git a/src/tilde/tb.h b/src/tilde/tb.h index 0f0aaf4c6..8b698ff30 100644 --- a/src/tilde/tb.h +++ b/src/tilde/tb.h @@ -439,7 +439,7 @@ struct TB_Node { typedef struct { // TB_BRANCH // avoid empty structs with flexible members int64_t _; - int64_t keys[/* input_count - 1 */]; + int64_t keys[]; } TB_NodeBranch; typedef struct { // TB_PROJ @@ -538,19 +538,6 @@ typedef struct { TB_Node* value; } TB_SwitchEntry; -typedef struct TB_Loop { - // refers to another entry in TB_LoopInfo... unless it's -1 - ptrdiff_t parent_loop; - - TB_Node* header; - TB_Node* backedge; -} TB_Loop; - -typedef struct TB_LoopInfo { - size_t count; - TB_Loop* loops; -} TB_LoopInfo; - typedef enum { TB_EXECUTABLE_UNKNOWN, TB_EXECUTABLE_PE, @@ -648,7 +635,7 @@ TB_API void tb_module_destroy(TB_Module* m); // When targetting windows & thread local storage, you'll need to bind a tls index // which is usually just a global that the runtime support has initialized, if you // dont and the tls_index is used, it'll crash -TB_API void tb_module_set_tls_index(TB_Module* m, const char* name); +TB_API void tb_module_set_tls_index(TB_Module* m, ptrdiff_t len, const char* name); // You don't need to manually call this unless you want to resolve locations before // exporting. @@ -756,7 +743,7 @@ TB_API TB_External* tb_next_external(TB_External* e); TB_API TB_ExternalType tb_extern_get_type(TB_External* e); TB_Global* tb_extern_transmute(TB_External* e, TB_DebugType* dbg_type, TB_Linkage linkage); -TB_API TB_External* tb_extern_create(TB_Module* m, const char* name, TB_ExternalType type); +TB_API TB_External* tb_extern_create(TB_Module* m, ptrdiff_t len, const char* name, TB_ExternalType type); TB_API TB_FileID tb_file_create(TB_Module* m, const char* path); // Called once you're done with TB operations on a thread (or i guess when it's @@ -798,7 +785,7 @@ TB_API TB_FunctionPrototype* tb_prototype_create(TB_Module* m, TB_CallingConv cc //////////////////////////////// // Globals //////////////////////////////// -TB_API TB_Global* tb_global_create(TB_Module* m, const char* name, TB_DebugType* dbg_type, TB_Linkage linkage); +TB_API TB_Global* tb_global_create(TB_Module* m, ptrdiff_t len, const char* name, TB_DebugType* dbg_type, TB_Linkage linkage); // allocate space for the global TB_API void tb_global_set_storage(TB_Module* m, TB_ModuleSection* section, TB_Global* global, size_t size, size_t align, size_t max_objects); @@ -818,8 +805,11 @@ TB_API TB_ModuleSection* tb_module_get_tls(TB_Module* m); //////////////////////////////// // Function Attributes //////////////////////////////// +TB_API void tb_node_append_attrib(TB_Node* n, TB_Attrib* a); + // These are parts of a function that describe metadata for instructions -TB_API void tb_function_attrib_variable(TB_Function* f, TB_Node* n, const char* name, TB_DebugType* type); +TB_API TB_Attrib* tb_function_attrib_variable(TB_Function* f, ptrdiff_t len, const char* name, TB_DebugType* type); +TB_API TB_Attrib* tb_function_attrib_scope(TB_Function* f, TB_Attrib* parent_scope); //////////////////////////////// // Debug info Generation @@ -830,9 +820,9 @@ TB_API TB_DebugType* tb_debug_get_integer(TB_Module* m, bool is_signed, int bits TB_API TB_DebugType* tb_debug_get_float(TB_Module* m, TB_FloatFormat fmt); TB_API TB_DebugType* tb_debug_create_ptr(TB_Module* m, TB_DebugType* base); TB_API TB_DebugType* tb_debug_create_array(TB_Module* m, TB_DebugType* base, size_t count); -TB_API TB_DebugType* tb_debug_create_struct(TB_Module* m, const char* tag); -TB_API TB_DebugType* tb_debug_create_union(TB_Module* m, const char* tag); -TB_API TB_DebugType* tb_debug_create_field(TB_Module* m, TB_DebugType* type, const char* name, TB_CharUnits offset); +TB_API TB_DebugType* tb_debug_create_struct(TB_Module* m, ptrdiff_t len, const char* tag); +TB_API TB_DebugType* tb_debug_create_union(TB_Module* m, ptrdiff_t len, const char* tag); +TB_API TB_DebugType* tb_debug_create_field(TB_Module* m, TB_DebugType* type, ptrdiff_t len, const char* name, TB_CharUnits offset); TB_API void tb_debug_complete_record(TB_DebugType* type, TB_DebugType** members, size_t count, TB_CharUnits size, TB_CharUnits align); //////////////////////////////// @@ -869,12 +859,14 @@ TB_API void tb_inst_set_location(TB_Function* f, TB_FileID file, int line); TB_API TB_DataType tb_vector_type(TB_DataTypeEnum type, int width); // if section is NULL, default to .text -TB_API TB_Function* tb_function_create(TB_Module* m, const char* name, TB_Linkage linkage, TB_ComdatType comdat); +TB_API TB_Function* tb_function_create(TB_Module* m, ptrdiff_t len, const char* name, TB_Linkage linkage, TB_ComdatType comdat); TB_API void* tb_function_get_jit_pos(TB_Function* f); +// if len is -1, it's null terminated +TB_API void tb_symbol_set_name(TB_Symbol* s, ptrdiff_t len, const char* name); + TB_API void tb_symbol_bind_ptr(TB_Symbol* s, void* ptr); -TB_API void tb_symbol_set_name(TB_Symbol* s, const char* name); TB_API const char* tb_symbol_get_name(TB_Symbol* s); // if arena is NULL, defaults to module arena which is freed on tb_free_thread_resources @@ -915,7 +907,6 @@ TB_API TB_Node* tb_inst_load(TB_Function* f, TB_DataType dt, TB_Node* addr, TB_C TB_API void tb_inst_store(TB_Function* f, TB_DataType dt, TB_Node* addr, TB_Node* val, TB_CharUnits align, bool is_volatile); TB_API TB_Node* tb_inst_bool(TB_Function* f, bool imm); -TB_API TB_Node* tb_inst_ptr(TB_Function* f, uint64_t imm); TB_API TB_Node* tb_inst_sint(TB_Function* f, TB_DataType dt, int64_t imm); TB_API TB_Node* tb_inst_uint(TB_Function* f, TB_DataType dt, uint64_t imm); TB_API TB_Node* tb_inst_float32(TB_Function* f, float imm); @@ -923,9 +914,12 @@ TB_API TB_Node* tb_inst_float64(TB_Function* f, double imm); TB_API TB_Node* tb_inst_cstring(TB_Function* f, const char* str); TB_API TB_Node* tb_inst_string(TB_Function* f, size_t len, const char* str); -// Broadcasts 'val' across 'count' elements starting 'dst' +// write 'val' over 'count' bytes on 'dst' TB_API void tb_inst_memset(TB_Function* f, TB_Node* dst, TB_Node* val, TB_Node* count, TB_CharUnits align, bool is_volatile); +// zero 'count' bytes on 'dst' +TB_API void tb_inst_memzero(TB_Function* f, TB_Node* dst, TB_Node* val, TB_Node* count, TB_CharUnits align, bool is_volatile); + // performs a copy of 'count' elements from one memory location to another // both locations cannot overlap. TB_API void tb_inst_memcpy(TB_Function* f, TB_Node* dst, TB_Node* src, TB_Node* count, TB_CharUnits align, bool is_volatile); @@ -1052,13 +1046,15 @@ TB_API TB_FuncOpt* tb_funcopt_enter(TB_Function* f, TB_Arena* arena); TB_API void tb_funcopt_exit(TB_FuncOpt* opt); TB_API bool tb_funcopt_peephole(TB_FuncOpt* opt); -TB_API bool tb_funcopt_mem2reg(TB_FuncOpt* f); -TB_API bool tb_funcopt_loop(TB_FuncOpt* f); +TB_API bool tb_funcopt_mem2reg(TB_FuncOpt* opt); +TB_API bool tb_funcopt_loop(TB_FuncOpt* opt); -TB_API void tb_funcopt_kill(TB_FuncOpt* restrict queue, TB_Node* n); +// isn't an optimization, just does the name flat form of IR printing +TB_API bool tb_funcopt_print(TB_FuncOpt* opt); -TB_API bool tb_funcopt_mark(TB_FuncOpt* restrict queue, TB_Node* n); -TB_API void tb_funcopt_mark_users(TB_FuncOpt* restrict queue, TB_Node* n); +TB_API void tb_funcopt_kill(TB_FuncOpt* opt, TB_Node* n); +TB_API bool tb_funcopt_mark(TB_FuncOpt* opt, TB_Node* n); +TB_API void tb_funcopt_mark_users(TB_FuncOpt* opt, TB_Node* n); //////////////////////////////// // IR access diff --git a/src/tilde/tb.lib b/src/tilde/tb.lib Binary files differindex a1f893968..a6ac5cbff 100644 --- a/src/tilde/tb.lib +++ b/src/tilde/tb.lib |