stage1 使用切片表达字符串而非C字符串 提供属性系统
This commit is contained in:
1 parent
a64a96f9a4
commit
72ae6d6994
14 files changed
+685
-1256
No files matched your search
+15
-18
@@ -5,6 +5,8 @@
|
||||
#include "spl_dbg.h"
|
||||
#include "spl_type.h"
|
||||
|
||||
#include "spl_attr.h"
|
||||
|
||||
/* clang-format off */
|
||||
#define SPL_IR_FN_TABLE \
|
||||
X(arith.add, V0, SPL_IR_ARITH_ADD) \
|
||||
@@ -63,6 +65,7 @@
|
||||
X(control.unreachable, V0, SPL_IR_CONTROL_UNREACHABLE) \
|
||||
X(control.trap, V0, SPL_IR_CONTROL_TRAP) \
|
||||
X(dbg.breakpoint, V0, SPL_IR_DBG_BREAKPOINT) \
|
||||
X(dbg.panic, V0, SPL_IR_DBG_PANIC) \
|
||||
|
||||
typedef enum {
|
||||
#ifdef X
|
||||
@@ -82,6 +85,7 @@ typedef usize spl_ir_func_ref_t; /* 0 is error */
|
||||
typedef struct {
|
||||
spl_ir_kind_t kind;
|
||||
spl_dbg_node_t dbg;
|
||||
spl_attr_id_vec_t attrs;
|
||||
union {
|
||||
spl_type_id_t tid;
|
||||
struct {
|
||||
@@ -211,26 +215,18 @@ typedef struct {
|
||||
spl_type_id_t tid;
|
||||
spl_ir_node_ref_t val;
|
||||
} control_ret;
|
||||
|
||||
struct {
|
||||
const char *msg;
|
||||
usize len;
|
||||
} dbg_panic;
|
||||
};
|
||||
} spl_ir_node_t;
|
||||
typedef VEC(spl_ir_node_t) spl_ir_node_vec_t;
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
SPL_IR_ATTR_NONE,
|
||||
SPL_IR_ATTR_LINK, /* 不实现 */
|
||||
SPL_IR_ATTR_ABI, /* 只有 C ABI 支持 */
|
||||
SPL_IR_ATTR_SYMBOL, /* 不实现 */
|
||||
SPL_IR_ATTR_NAKED, /* 不实现 */
|
||||
SPL_IR_ATTR_NOINLINE, /* 不实现 */
|
||||
SPL_IR_ATTR_ALWAYSINLINE, /* 不实现 */
|
||||
} kind;
|
||||
} spl_ir_attr_t;
|
||||
typedef VEC(spl_ir_attr_t) spl_ir_attr_vec_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
spl_ir_attr_t attr;
|
||||
spl_attr_id_vec_t attrs;
|
||||
spl_type_id_t fn_tid;
|
||||
spl_ir_node_vec_t nodes;
|
||||
} spl_ir_func_t;
|
||||
@@ -259,7 +255,7 @@ spl_ir_func_ref_t spl_ir_alloc_fn(spl_ir_t *ir);
|
||||
spl_ir_node_t *spl_ir_node(spl_ir_t *ir, spl_ir_func_ref_t fn_id, spl_ir_node_ref_t node_id);
|
||||
spl_ir_func_t *spl_ir_func(spl_ir_t *ir, spl_ir_func_ref_t fn_id);
|
||||
|
||||
void spl_ir_dump(spl_ir_t *ir, const spl_type_t *ty);
|
||||
void spl_ir_dump(spl_ir_t *ir, const spl_type_t *ty, const spl_attr_t *attr);
|
||||
const char *spl_ir_kind_name(spl_ir_kind_t kind);
|
||||
|
||||
typedef struct {
|
||||
@@ -312,7 +308,7 @@ void spl_ir_builder_init(spl_ir_builder_t *b);
|
||||
void spl_ir_builder_drop(spl_ir_builder_t *b);
|
||||
|
||||
spl_ir_func_ref_t spl_ir_builder_fn_begin(spl_ir_builder_t *b, const char *name,
|
||||
spl_type_id_t fn_tid, spl_ir_attr_t attr);
|
||||
spl_type_id_t fn_tid);
|
||||
void spl_ir_builder_fn_end(spl_ir_builder_t *b);
|
||||
|
||||
usize spl_ir_builder_block_begin(spl_ir_builder_t *b);
|
||||
@@ -370,8 +366,8 @@ spl_ir_node_ref_t spl_ir_builder_type_const_bool(spl_ir_builder_t *b, spl_type_i
|
||||
spl_ir_node_ref_t spl_ir_builder_type_const_int(spl_ir_builder_t *b, spl_type_id_t tid, usize val);
|
||||
spl_ir_node_ref_t spl_ir_builder_type_const_float(spl_ir_builder_t *b, spl_type_id_t tid,
|
||||
double val);
|
||||
spl_ir_node_ref_t spl_ir_builder_type_const_cstr(spl_ir_builder_t *b, spl_type_id_t tid,
|
||||
const char *val);
|
||||
spl_ir_node_ref_t spl_ir_builder_type_const_bytes(spl_ir_builder_t *b, spl_type_id_t tid,
|
||||
const void *data, usize len);
|
||||
spl_ir_node_ref_t spl_ir_builder_type_const_char(spl_ir_builder_t *b, spl_type_id_t tid, char val);
|
||||
spl_ir_node_ref_t spl_ir_builder_type_const_fn(spl_ir_builder_t *b, spl_type_id_t tid,
|
||||
spl_ir_func_ref_t val);
|
||||
@@ -419,5 +415,6 @@ spl_ir_node_ref_t spl_ir_builder_control_unreachable(spl_ir_builder_t *b);
|
||||
spl_ir_node_ref_t spl_ir_builder_control_trap(spl_ir_builder_t *b);
|
||||
|
||||
spl_ir_node_ref_t spl_ir_builder_dbg_breakpoint(spl_ir_builder_t *b);
|
||||
spl_ir_node_ref_t spl_ir_builder_dbg_panic(spl_ir_builder_t *b, const char *msg, usize len);
|
||||
|
||||
#endif /* __SPL_IR_H__ */
|
||||
Reference in new issue
Block a user