aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-11 04:06:07 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-11 04:06:07 -0500
commit8fcb1a141b1f76a0c6b28338723535ec5fbf638b (patch)
tree6789b38ce297bedeb60e15446a5980bc3da18574 /src/ir_print.cpp
parent10cea15cc3061272a0ed05fafe9e762f6454fafc (diff)
downloadzig-8fcb1a141b1f76a0c6b28338723535ec5fbf638b.tar.gz
zig-8fcb1a141b1f76a0c6b28338723535ec5fbf638b.zip
IR: implement fence and cmpxchg builtins
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index d8d41b6ebe..5ef934c61f 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -719,6 +719,26 @@ static void ir_print_embed_file(IrPrint *irp, IrInstructionEmbedFile *instructio
fprintf(irp->f, ")");
}
+static void ir_print_cmpxchg(IrPrint *irp, IrInstructionCmpxchg *instruction) {
+ fprintf(irp->f, "@cmpxchg(");
+ ir_print_other_instruction(irp, instruction->ptr);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->cmp_value);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->new_value);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->success_order_value);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->failure_order_value);
+ fprintf(irp->f, ")");
+}
+
+static void ir_print_fence(IrPrint *irp, IrInstructionFence *instruction) {
+ fprintf(irp->f, "@fence(");
+ ir_print_other_instruction(irp, instruction->order_value);
+ fprintf(irp->f, ")");
+}
+
static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
ir_print_prefix(irp, instruction);
switch (instruction->id) {
@@ -883,6 +903,12 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdEmbedFile:
ir_print_embed_file(irp, (IrInstructionEmbedFile *)instruction);
break;
+ case IrInstructionIdCmpxchg:
+ ir_print_cmpxchg(irp, (IrInstructionCmpxchg *)instruction);
+ break;
+ case IrInstructionIdFence:
+ ir_print_fence(irp, (IrInstructionFence *)instruction);
+ break;
}
fprintf(irp->f, "\n");
}