aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-20 01:50:32 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-20 01:50:32 -0500
commit1f6dacbb2f9a91a20309b271a31e781f11f81819 (patch)
tree418c311fc703a4163ebf16cc90e89346b5113785 /src/codegen.cpp
parentc10ae8622bc07baeea1fb81522b01fc6e953eaf6 (diff)
downloadzig-1f6dacbb2f9a91a20309b271a31e781f11f81819.tar.gz
zig-1f6dacbb2f9a91a20309b271a31e781f11f81819.zip
IR: enum init support
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 5094e7f9ba..e60e641b2a 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -2144,6 +2144,10 @@ static LLVMValueRef ir_render_enum_tag(CodeGen *g, IrExecutable *executable, IrI
return get_handle_value(g, tag_field_ptr, tag_type);
}
+static LLVMValueRef ir_render_init_enum(CodeGen *g, IrExecutable *executable, IrInstructionInitEnum *instruction) {
+ zig_panic("TODO ir_render_init_enum");
+}
+
static void set_debug_location(CodeGen *g, IrInstruction *instruction) {
AstNode *source_node = instruction->source_node;
Scope *scope = instruction->scope;
@@ -2278,6 +2282,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
return ir_render_err_wrap_payload(g, executable, (IrInstructionErrWrapPayload *)instruction);
case IrInstructionIdEnumTag:
return ir_render_enum_tag(g, executable, (IrInstructionEnumTag *)instruction);
+ case IrInstructionIdInitEnum:
+ return ir_render_init_enum(g, executable, (IrInstructionInitEnum *)instruction);
case IrInstructionIdSwitchVar:
zig_panic("TODO render switch var instruction to LLVM");
case IrInstructionIdContainerInitList:
@@ -2497,6 +2503,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, TypeTableEntry *type_entry, ConstE
}
case TypeTableEntryIdVoid:
return nullptr;
+ case TypeTableEntryIdEnumTag:
+ return gen_const_val(g, type_entry->data.enum_tag.int_type, const_val);
case TypeTableEntryIdInvalid:
case TypeTableEntryIdMetaType:
case TypeTableEntryIdUnreachable:
@@ -2876,6 +2884,9 @@ static void do_code_gen(CodeGen *g) {
} else if (instruction->id == IrInstructionIdErrWrapCode) {
IrInstructionErrWrapCode *err_wrap_code_instruction = (IrInstructionErrWrapCode *)instruction;
slot = &err_wrap_code_instruction->tmp_ptr;
+ } else if (instruction->id == IrInstructionIdInitEnum) {
+ IrInstructionInitEnum *init_enum_instruction = (IrInstructionInitEnum *)instruction;
+ slot = &init_enum_instruction->tmp_ptr;
} else {
zig_unreachable();
}
@@ -3793,7 +3804,8 @@ static void get_c_type(CodeGen *g, TypeTableEntry *type_entry, Buf *out_buf) {
case TypeTableEntryIdUnion:
case TypeTableEntryIdFn:
case TypeTableEntryIdTypeDecl:
- zig_panic("TODO");
+ case TypeTableEntryIdEnumTag:
+ zig_panic("TODO implement get_c_type for more types");
case TypeTableEntryIdInvalid:
case TypeTableEntryIdMetaType:
case TypeTableEntryIdBoundFn: