Ternary Expr; lbAddr extra; Phi node support

This commit is contained in:
gingerBill
2020-02-06 23:33:41 +00:00
parent 09e1cf0737
commit 7d9600b740
5 changed files with 1037 additions and 150 deletions
+991 -147
View File
File diff suppressed because it is too large Load Diff
+38 -1
View File
@@ -49,6 +49,8 @@ struct lbModule {
LLVMContextRef ctx;
CheckerInfo *info;
gbMutex mutex;
Map<LLVMTypeRef> types; // Key: Type *
Map<lbValue> values; // Key: Entity *
@@ -77,6 +79,9 @@ struct lbBlock {
LLVMBasicBlockRef block;
Scope *scope;
isize scope_index;
Array<lbBlock *> preds;
Array<lbBlock *> succs;
};
struct lbBranchBlocks {
@@ -106,6 +111,28 @@ enum lbDeferExitKind {
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 {
lbTargetList *prev;
bool is_block;
@@ -138,6 +165,7 @@ struct lbProcedure {
lbAddr return_ptr;
Array<lbValue> params;
Array<lbDefer> defer_stmts;
Array<lbBlock *> blocks;
Array<lbBranchBlocks> branch_blocks;
Scope * curr_scope;
@@ -176,7 +204,10 @@ LLVMTypeRef lb_type(lbModule *m, Type *type);
lbBlock *lb_create_block(lbProcedure *p, char const *name);
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_bool(lbModule *m, Type *type, bool value);
lbValue lb_const_int(lbModule *m, Type *type, u64 value);
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);
void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block);
lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t);
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_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 {
lbCallingConvention_C = 0,
+1 -1
View File
@@ -1280,7 +1280,7 @@ int main(int arg_count, char const **arg_ptr) {
if (!lb_init_generator(&gen, &checker)) {
return 1;
}
lb_generate_module(&gen);
lb_generate_code(&gen);
if (build_context.show_timings) {
show_timings(&checker, timings);
+1 -1
View File
@@ -904,7 +904,7 @@ Token tokenizer_get_token(Tokenizer *t) {
}
if (token.kind == Token_Ident && token.string == "notin") {
token.kind = Token_not_in;
token.kind = Token_not_in;
}
}
+6
View File
@@ -3421,7 +3421,13 @@ gbString write_type_to_string(gbString str, Type *type) {
str = gb_string_appendc(str, ")");
if (type->Proc.results) {
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);
if (type->Proc.results->Tuple.variables.count > 1) {
str = gb_string_appendc(str, ")");
}
}
break;