aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-13 04:30:41 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-13 04:30:41 -0500
commit3f3630d7e349361116416dce36d2f69d7c3e318c (patch)
tree836ce54c606706f23a0a7524a3628b6e464c051c /src/ir_print.cpp
parent8bb5f54b292efacc03ff8d7cc6f59ae36c24305d (diff)
downloadzig-3f3630d7e349361116416dce36d2f69d7c3e318c.tar.gz
zig-3f3630d7e349361116416dce36d2f69d7c3e318c.zip
IR: implement the rest of the builtin functions
* returnAddress * frameAddress * addWithOverflow * subWithOverflow * mulWithOverflow * shlWithOverflow * alignOf
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 186de8b449..d00ba372b4 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -816,6 +816,45 @@ static void ir_print_breakpoint(IrPrint *irp, IrInstructionBreakpoint *instructi
fprintf(irp->f, "@breakpoint()");
}
+static void ir_print_frame_address(IrPrint *irp, IrInstructionFrameAddress *instruction) {
+ fprintf(irp->f, "@frameAddress()");
+}
+
+static void ir_print_return_address(IrPrint *irp, IrInstructionReturnAddress *instruction) {
+ fprintf(irp->f, "@returnAddress()");
+}
+
+static void ir_print_alignof(IrPrint *irp, IrInstructionAlignOf *instruction) {
+ fprintf(irp->f, "@alignOf(");
+ ir_print_other_instruction(irp, instruction->type_value);
+ fprintf(irp->f, ")");
+}
+
+static void ir_print_overflow_op(IrPrint *irp, IrInstructionOverflowOp *instruction) {
+ switch (instruction->op) {
+ case IrOverflowOpAdd:
+ fprintf(irp->f, "@addWithOverflow(");
+ break;
+ case IrOverflowOpSub:
+ fprintf(irp->f, "@subWithOverflow(");
+ break;
+ case IrOverflowOpMul:
+ fprintf(irp->f, "@mulWithOverflow(");
+ break;
+ case IrOverflowOpShl:
+ fprintf(irp->f, "@shlWithOverflow(");
+ break;
+ }
+ ir_print_other_instruction(irp, instruction->type_value);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->op1);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->op2);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->result_ptr);
+ fprintf(irp->f, ")");
+}
+
static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
ir_print_prefix(irp, instruction);
switch (instruction->id) {
@@ -1016,6 +1055,18 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdBreakpoint:
ir_print_breakpoint(irp, (IrInstructionBreakpoint *)instruction);
break;
+ case IrInstructionIdReturnAddress:
+ ir_print_return_address(irp, (IrInstructionReturnAddress *)instruction);
+ break;
+ case IrInstructionIdFrameAddress:
+ ir_print_frame_address(irp, (IrInstructionFrameAddress *)instruction);
+ break;
+ case IrInstructionIdAlignOf:
+ ir_print_alignof(irp, (IrInstructionAlignOf *)instruction);
+ break;
+ case IrInstructionIdOverflowOp:
+ ir_print_overflow_op(irp, (IrInstructionOverflowOp *)instruction);
+ break;
}
fprintf(irp->f, "\n");
}