aboutsummaryrefslogtreecommitdiff
path: root/src/tilde
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-07-22 07:56:13 +0100
committergingerBill <bill@gingerbill.org>2023-07-22 07:56:13 +0100
commite5f9458905f27b027403a5a0b94cc7762984a08e (patch)
tree04fd5d4c3a0f6aef47bcfe4e025537a388f75734 /src/tilde
parentec0a9a5f8a68e03650958acca19f96b3dfd4744e (diff)
Update Tilde to get procedure passing rules
Diffstat (limited to 'src/tilde')
-rw-r--r--src/tilde/tb.h62
-rw-r--r--src/tilde/tb.libbin4158782 -> 4162738 bytes
2 files changed, 43 insertions, 19 deletions
diff --git a/src/tilde/tb.h b/src/tilde/tb.h
index c2dc3922b..048fce598 100644
--- a/src/tilde/tb.h
+++ b/src/tilde/tb.h
@@ -210,9 +210,6 @@ typedef enum TB_NodeTypeEnum {
// projection
TB_PROJ,
- // metadata
- TB_KEEPALIVE,
-
TB_CALL, // normal call
TB_SCALL, // system call
@@ -640,14 +637,32 @@ TB_API void tb_module_set_tls_index(TB_Module* m, ptrdiff_t len, const char* nam
TB_API void tb_module_layout_sections(TB_Module* m);
////////////////////////////////
-// Exporter
+// Compiled code introspection
////////////////////////////////
+enum { TB_ASSEMBLY_CHUNK_CAP = 4*1024 - sizeof(size_t[2]) };
+
+typedef struct TB_Assembly TB_Assembly;
+struct TB_Assembly {
+ TB_Assembly* next;
+
+ // nice chunk of text here
+ size_t length;
+ char data[];
+};
// this is where the machine code and other relevant pieces go.
typedef struct TB_FunctionOutput TB_FunctionOutput;
// returns NULL if it fails
-TB_API TB_FunctionOutput* tb_module_compile_function(TB_Module* m, TB_Function* f, TB_ISelMode isel_mode);
+TB_API TB_FunctionOutput* tb_module_compile_function(TB_Module* m, TB_Function* f, TB_ISelMode isel_mode, bool emit_asm);
+
+TB_API uint8_t* tb_output_get_code(TB_FunctionOutput* out, size_t* out_length);
+
+// returns NULL if no assembly was generated
+TB_API TB_Assembly* tb_output_get_asm(TB_FunctionOutput* out);
+
+// this is relative to the start of the function (the start of the prologue)
+TB_API TB_Safepoint* tb_safepoint_get(TB_Function* f, uint32_t relative_ip);
////////////////////////////////
// Exporter
@@ -780,6 +795,27 @@ struct TB_FunctionPrototype {
// matching signatures.
TB_API TB_FunctionPrototype* tb_prototype_create(TB_Module* m, TB_CallingConv cc, size_t param_count, const TB_PrototypeParam* params, size_t return_count, const TB_PrototypeParam* returns, bool has_varargs);
+// same as tb_function_set_prototype except it will handle lowering from types like the TB_DebugType
+// into the correct ABI and exposing sane looking nodes to the parameters.
+//
+// returns the parameters
+TB_API TB_Node** tb_function_set_prototype_from_dbg(TB_Function* f, TB_DebugType* dbg, TB_Arena* arena, size_t* out_param_count);
+TB_API TB_FunctionPrototype* tb_prototype_from_dbg(TB_Module* m, TB_DebugType* dbg);
+
+// used for ABI parameter passing
+typedef enum {
+ // needs a direct value
+ TB_PASSING_DIRECT,
+
+ // needs an address to the value
+ TB_PASSING_INDIRECT,
+
+ // doesn't use this parameter
+ TB_PASSING_IGNORE,
+} TB_PassingRule;
+
+TB_API TB_PassingRule tb_get_passing_rule_from_dbg(TB_Module* mod, TB_DebugType* param_type, bool is_return);
+
////////////////////////////////
// Globals
////////////////////////////////
@@ -829,6 +865,8 @@ TB_API void tb_debug_record_end(TB_DebugType* type, TB_CharUnits size, TB_CharUn
TB_API TB_DebugType* tb_debug_create_func(TB_Module* m, TB_CallingConv cc, size_t param_count, size_t return_count, bool has_varargs);
+TB_API TB_DebugType* tb_debug_field_type(TB_DebugType* type);
+
// you'll need to fill these if you make a function
TB_API TB_DebugType** tb_debug_func_params(TB_DebugType* type);
TB_API TB_DebugType** tb_debug_func_returns(TB_DebugType* type);
@@ -840,12 +878,6 @@ TB_API TB_DebugType** tb_debug_func_returns(TB_DebugType* type);
#define TB_FOR_INPUT_IN_NODE(it, parent) for (TB_Node **it = parent->inputs, **__end = it + (parent)->input_count; it != __end; it++)
////////////////////////////////
-// Compiled code introspection
-////////////////////////////////
-// this is relative to the start of the function (the start of the prologue)
-TB_API TB_Safepoint* tb_safepoint_get(TB_Function* f, uint32_t relative_ip);
-
-////////////////////////////////
// Symbols
////////////////////////////////
TB_API bool tb_symbol_is_comdat(const TB_Symbol* s);
@@ -879,13 +911,6 @@ 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 const char* tb_symbol_get_name(TB_Symbol* s);
-// same as tb_function_set_prototype except it will handle lowering from types like the TB_DebugType
-// into the correct ABI and exposing sane looking nodes to the parameters.
-//
-// returns the parameters
-TB_API TB_Node** tb_function_set_prototype_from_dbg(TB_Function* f, TB_DebugType* dbg, TB_Arena* arena, size_t* out_param_count);
-TB_API TB_FunctionPrototype* tb_prototype_from_dbg(TB_Module* m, TB_DebugType* dbg);
-
// if arena is NULL, defaults to module arena which is freed on tb_free_thread_resources
TB_API void tb_function_set_prototype(TB_Function* f, TB_FunctionPrototype* p, TB_Arena* arena);
TB_API TB_FunctionPrototype* tb_function_get_prototype(TB_Function* f);
@@ -903,7 +928,6 @@ TB_API void tb_inst_set_region_name(TB_Node* n, ptrdiff_t len, const char* name)
TB_API void tb_inst_unreachable(TB_Function* f);
TB_API void tb_inst_debugbreak(TB_Function* f);
TB_API void tb_inst_trap(TB_Function* f);
-TB_API void tb_inst_keep_alive(TB_Function* f, TB_Node* src);
TB_API TB_Node* tb_inst_poison(TB_Function* f);
TB_API TB_Node* tb_inst_param(TB_Function* f, int param_id);
diff --git a/src/tilde/tb.lib b/src/tilde/tb.lib
index 5a1cd67dd..b9b9dbd44 100644
--- a/src/tilde/tb.lib
+++ b/src/tilde/tb.lib
Binary files differ