diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-26 15:45:50 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-26 15:45:50 -0500 |
| commit | 735cdbfdaca6405d1465ea859032412499c658d8 (patch) | |
| tree | a3b6655d26985adafbf71903c5d5bb7049a45454 /src/ir_print.cpp | |
| parent | aee7ad3de2e3c334ec5aac2d355e4eed086f1cdf (diff) | |
| download | zig-735cdbfdaca6405d1465ea859032412499c658d8.tar.gz zig-735cdbfdaca6405d1465ea859032412499c658d8.zip | |
IR: pass intToPtrCast test
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp index f0dda04c6d..3db8b32e4f 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -98,7 +98,11 @@ static void ir_print_const_value(IrPrint *irp, ConstExprValue *const_val) { } case TypeTableEntryIdPointer: fprintf(irp->f, "&"); - ir_print_const_value(irp, const_ptr_pointee(const_val)); + if (const_val->data.x_ptr.special == ConstPtrSpecialRuntime) { + fprintf(irp->f, "(runtime pointer value)"); + } else { + ir_print_const_value(irp, const_ptr_pointee(const_val)); + } return; case TypeTableEntryIdFn: { @@ -934,6 +938,18 @@ static void ir_print_widen_or_shorten(IrPrint *irp, IrInstructionWidenOrShorten fprintf(irp->f, ")"); } +static void ir_print_ptr_to_int(IrPrint *irp, IrInstructionPtrToInt *instruction) { + fprintf(irp->f, "@ptrToInt("); + ir_print_other_instruction(irp, instruction->target); + fprintf(irp->f, ")"); +} + +static void ir_print_int_to_ptr(IrPrint *irp, IrInstructionIntToPtr *instruction) { + fprintf(irp->f, "@intToPtr("); + ir_print_other_instruction(irp, instruction->target); + fprintf(irp->f, ")"); +} + static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { ir_print_prefix(irp, instruction); switch (instruction->id) { @@ -1179,6 +1195,12 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { case IrInstructionIdWidenOrShorten: ir_print_widen_or_shorten(irp, (IrInstructionWidenOrShorten *)instruction); break; + case IrInstructionIdPtrToInt: + ir_print_ptr_to_int(irp, (IrInstructionPtrToInt *)instruction); + break; + case IrInstructionIdIntToPtr: + ir_print_int_to_ptr(irp, (IrInstructionIntToPtr *)instruction); + break; } fprintf(irp->f, "\n"); } |
