mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Ternary Expr; lbAddr extra; Phi node support
This commit is contained in:
+991
-147
File diff suppressed because it is too large
Load Diff
+38
-1
@@ -49,6 +49,8 @@ struct lbModule {
|
|||||||
LLVMContextRef ctx;
|
LLVMContextRef ctx;
|
||||||
CheckerInfo *info;
|
CheckerInfo *info;
|
||||||
|
|
||||||
|
gbMutex mutex;
|
||||||
|
|
||||||
Map<LLVMTypeRef> types; // Key: Type *
|
Map<LLVMTypeRef> types; // Key: Type *
|
||||||
|
|
||||||
Map<lbValue> values; // Key: Entity *
|
Map<lbValue> values; // Key: Entity *
|
||||||
@@ -77,6 +79,9 @@ struct lbBlock {
|
|||||||
LLVMBasicBlockRef block;
|
LLVMBasicBlockRef block;
|
||||||
Scope *scope;
|
Scope *scope;
|
||||||
isize scope_index;
|
isize scope_index;
|
||||||
|
|
||||||
|
Array<lbBlock *> preds;
|
||||||
|
Array<lbBlock *> succs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lbBranchBlocks {
|
struct lbBranchBlocks {
|
||||||
@@ -106,6 +111,28 @@ enum lbDeferExitKind {
|
|||||||
lbDeferExit_Branch,
|
lbDeferExit_Branch,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum lbDeferKind {
|
||||||
|
lbDefer_Node,
|
||||||
|
lbDefer_Instr,
|
||||||
|
lbDefer_Proc,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct lbDefer {
|
||||||
|
lbDeferKind kind;
|
||||||
|
isize scope_index;
|
||||||
|
isize context_stack_count;
|
||||||
|
lbBlock * block;
|
||||||
|
union {
|
||||||
|
Ast *stmt;
|
||||||
|
// NOTE(bill): 'instr' will be copied every time to create a new one
|
||||||
|
lbValue instr;
|
||||||
|
struct {
|
||||||
|
lbValue deferred;
|
||||||
|
Array<lbValue> result_as_args;
|
||||||
|
} proc;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
struct lbTargetList {
|
struct lbTargetList {
|
||||||
lbTargetList *prev;
|
lbTargetList *prev;
|
||||||
bool is_block;
|
bool is_block;
|
||||||
@@ -138,6 +165,7 @@ struct lbProcedure {
|
|||||||
|
|
||||||
lbAddr return_ptr;
|
lbAddr return_ptr;
|
||||||
Array<lbValue> params;
|
Array<lbValue> params;
|
||||||
|
Array<lbDefer> defer_stmts;
|
||||||
Array<lbBlock *> blocks;
|
Array<lbBlock *> blocks;
|
||||||
Array<lbBranchBlocks> branch_blocks;
|
Array<lbBranchBlocks> branch_blocks;
|
||||||
Scope * curr_scope;
|
Scope * curr_scope;
|
||||||
@@ -176,7 +204,10 @@ LLVMTypeRef lb_type(lbModule *m, Type *type);
|
|||||||
lbBlock *lb_create_block(lbProcedure *p, char const *name);
|
lbBlock *lb_create_block(lbProcedure *p, char const *name);
|
||||||
|
|
||||||
lbValue lb_const_nil(lbModule *m, Type *type);
|
lbValue lb_const_nil(lbModule *m, Type *type);
|
||||||
|
lbValue lb_const_undef(lbModule *m, Type *type);
|
||||||
lbValue lb_const_value(lbModule *m, Type *type, ExactValue value);
|
lbValue lb_const_value(lbModule *m, Type *type, ExactValue value);
|
||||||
|
lbValue lb_const_bool(lbModule *m, Type *type, bool value);
|
||||||
|
lbValue lb_const_int(lbModule *m, Type *type, u64 value);
|
||||||
|
|
||||||
|
|
||||||
lbAddr lb_addr(lbValue addr);
|
lbAddr lb_addr(lbValue addr);
|
||||||
@@ -200,7 +231,7 @@ lbValue lb_emit_array_epi(lbProcedure *p, lbValue value, i32 index);
|
|||||||
|
|
||||||
lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type);
|
lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type);
|
||||||
|
|
||||||
|
void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block);
|
||||||
|
|
||||||
lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t);
|
lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t);
|
||||||
lbValue lb_build_call_expr(lbProcedure *p, Ast *expr);
|
lbValue lb_build_call_expr(lbProcedure *p, Ast *expr);
|
||||||
@@ -212,6 +243,12 @@ lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e=nullptr, bool zero_ini
|
|||||||
|
|
||||||
lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t);
|
lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t);
|
||||||
|
|
||||||
|
lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right);
|
||||||
|
lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> const &args, ProcInlining inlining = ProcInlining_none, bool use_return_ptr_hint = false);
|
||||||
|
|
||||||
|
lbValue lb_typeid(lbModule *m, Type *type, Type *typeid_type=t_typeid);
|
||||||
|
|
||||||
|
lbValue lb_address_from_load_or_generate_local(lbProcedure *p, lbValue value);
|
||||||
|
|
||||||
enum lbCallingConventionKind {
|
enum lbCallingConventionKind {
|
||||||
lbCallingConvention_C = 0,
|
lbCallingConvention_C = 0,
|
||||||
|
|||||||
+1
-1
@@ -1280,7 +1280,7 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
if (!lb_init_generator(&gen, &checker)) {
|
if (!lb_init_generator(&gen, &checker)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
lb_generate_module(&gen);
|
lb_generate_code(&gen);
|
||||||
|
|
||||||
if (build_context.show_timings) {
|
if (build_context.show_timings) {
|
||||||
show_timings(&checker, timings);
|
show_timings(&checker, timings);
|
||||||
|
|||||||
+1
-1
@@ -904,7 +904,7 @@ Token tokenizer_get_token(Tokenizer *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (token.kind == Token_Ident && token.string == "notin") {
|
if (token.kind == Token_Ident && token.string == "notin") {
|
||||||
token.kind = Token_not_in;
|
token.kind = Token_not_in;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3421,7 +3421,13 @@ gbString write_type_to_string(gbString str, Type *type) {
|
|||||||
str = gb_string_appendc(str, ")");
|
str = gb_string_appendc(str, ")");
|
||||||
if (type->Proc.results) {
|
if (type->Proc.results) {
|
||||||
str = gb_string_appendc(str, " -> ");
|
str = gb_string_appendc(str, " -> ");
|
||||||
|
if (type->Proc.results->Tuple.variables.count > 1) {
|
||||||
|
str = gb_string_appendc(str, "(");
|
||||||
|
}
|
||||||
str = write_type_to_string(str, type->Proc.results);
|
str = write_type_to_string(str, type->Proc.results);
|
||||||
|
if (type->Proc.results->Tuple.variables.count > 1) {
|
||||||
|
str = gb_string_appendc(str, ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user