aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-11-29 16:34:50 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-11-29 16:34:50 -0500
commit91ef68f9b1121d2a08f175a81f88321664c90a61 (patch)
tree73e2c9cf0b1f24b9855095757e65c4ac981517ef /src/ir_print.cpp
parent9a4da6c8d8d55f47609b8e900e9a4bb1ac34d5e7 (diff)
parent70662830044418fc2d637c166fc100fe72d60fcf (diff)
downloadzig-91ef68f9b1121d2a08f175a81f88321664c90a61.tar.gz
zig-91ef68f9b1121d2a08f175a81f88321664c90a61.zip
Merge remote-tracking branch 'origin/master' into llvm6
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 1c60d68628..55ad3ceb6c 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -290,6 +290,15 @@ static void ir_print_struct_init(IrPrint *irp, IrInstructionStructInit *instruct
fprintf(irp->f, "} // struct init");
}
+static void ir_print_union_init(IrPrint *irp, IrInstructionUnionInit *instruction) {
+ Buf *field_name = instruction->field->name;
+
+ fprintf(irp->f, "%s {", buf_ptr(&instruction->union_type->name));
+ fprintf(irp->f, ".%s = ", buf_ptr(field_name));
+ ir_print_other_instruction(irp, instruction->init_value);
+ fprintf(irp->f, "} // union init");
+}
+
static void ir_print_unreachable(IrPrint *irp, IrInstructionUnreachable *instruction) {
fprintf(irp->f, "unreachable");
}
@@ -359,6 +368,13 @@ static void ir_print_enum_field_ptr(IrPrint *irp, IrInstructionEnumFieldPtr *ins
fprintf(irp->f, ")");
}
+static void ir_print_union_field_ptr(IrPrint *irp, IrInstructionUnionFieldPtr *instruction) {
+ fprintf(irp->f, "@UnionFieldPtr(&");
+ ir_print_other_instruction(irp, instruction->union_ptr);
+ fprintf(irp->f, ".%s", buf_ptr(instruction->field->name));
+ fprintf(irp->f, ")");
+}
+
static void ir_print_set_debug_safety(IrPrint *irp, IrInstructionSetDebugSafety *instruction) {
fprintf(irp->f, "@setDebugSafety(");
ir_print_other_instruction(irp, instruction->scope_value);
@@ -1023,6 +1039,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdStructInit:
ir_print_struct_init(irp, (IrInstructionStructInit *)instruction);
break;
+ case IrInstructionIdUnionInit:
+ ir_print_union_init(irp, (IrInstructionUnionInit *)instruction);
+ break;
case IrInstructionIdUnreachable:
ir_print_unreachable(irp, (IrInstructionUnreachable *)instruction);
break;
@@ -1056,6 +1075,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdEnumFieldPtr:
ir_print_enum_field_ptr(irp, (IrInstructionEnumFieldPtr *)instruction);
break;
+ case IrInstructionIdUnionFieldPtr:
+ ir_print_union_field_ptr(irp, (IrInstructionUnionFieldPtr *)instruction);
+ break;
case IrInstructionIdSetDebugSafety:
ir_print_set_debug_safety(irp, (IrInstructionSetDebugSafety *)instruction);
break;