aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-11-20 02:11:36 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-11-20 02:11:36 -0500
commitb47e2fa0604a5c785d9ed7d16c8086ecf99357f7 (patch)
tree03b78e69349eaa6c355b5bbcef693bd3fdae9817 /src/ir_print.cpp
parent6c8b919d17fd456671710087c199bfd7d5a13c38 (diff)
downloadzig-b47e2fa0604a5c785d9ed7d16c8086ecf99357f7.tar.gz
zig-b47e2fa0604a5c785d9ed7d16c8086ecf99357f7.zip
IR: support sizeOf builtin
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 7ae1794a28..c65334d0d7 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -36,7 +36,8 @@ static void ir_print_const_value(IrPrint *irp, TypeTableEntry *type_entry, Const
}
switch (type_entry->id) {
case TypeTableEntryIdInvalid:
- zig_unreachable();
+ fprintf(irp->f, "(invalid)");
+ break;
case TypeTableEntryIdVoid:
fprintf(irp->f, "{}");
break;
@@ -490,6 +491,12 @@ static void ir_print_compile_var(IrPrint *irp, IrInstructionCompileVar *instruct
fprintf(irp->f, ")");
}
+static void ir_print_size_of(IrPrint *irp, IrInstructionSizeOf *instruction) {
+ fprintf(irp->f, "@sizeOf(");
+ ir_print_other_instruction(irp, instruction->type_value);
+ fprintf(irp->f, ")");
+}
+
static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
ir_print_prefix(irp, instruction);
switch (instruction->id) {
@@ -582,6 +589,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdCompileVar:
ir_print_compile_var(irp, (IrInstructionCompileVar *)instruction);
break;
+ case IrInstructionIdSizeOf:
+ ir_print_size_of(irp, (IrInstructionSizeOf *)instruction);
+ break;
case IrInstructionIdSwitchBr:
zig_panic("TODO print more IR instructions");
}