diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-12 00:31:35 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-12 00:31:35 -0500 |
| commit | ef63bc9cca6370f03d76a2a19dd7cdd7e23270d4 (patch) | |
| tree | fca2d675e920c9809d7a7b3d9ed858e44589d286 /src/ir_print.cpp | |
| parent | fb2157063060682a314cb8f2e34efc7989646455 (diff) | |
| download | zig-ef63bc9cca6370f03d76a2a19dd7cdd7e23270d4.tar.gz zig-ef63bc9cca6370f03d76a2a19dd7cdd7e23270d4.zip | |
IR: implement memcpy, memset, and slice expression
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp index 1adebca1fa..1c62dc13fd 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -774,6 +774,38 @@ static void ir_print_bool_not(IrPrint *irp, IrInstructionBoolNot *instruction) { ir_print_other_instruction(irp, instruction->value); } +static void ir_print_memset(IrPrint *irp, IrInstructionMemset *instruction) { + fprintf(irp->f, "@memset("); + ir_print_other_instruction(irp, instruction->dest_ptr); + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, instruction->byte); + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, instruction->count); + fprintf(irp->f, ")"); +} + +static void ir_print_memcpy(IrPrint *irp, IrInstructionMemcpy *instruction) { + fprintf(irp->f, "@memcpy("); + ir_print_other_instruction(irp, instruction->dest_ptr); + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, instruction->src_ptr); + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, instruction->count); + fprintf(irp->f, ")"); +} + +static void ir_print_slice(IrPrint *irp, IrInstructionSlice *instruction) { + ir_print_other_instruction(irp, instruction->ptr); + fprintf(irp->f, "["); + ir_print_other_instruction(irp, instruction->start); + fprintf(irp->f, "..."); + if (instruction->end) + ir_print_other_instruction(irp, instruction->end); + fprintf(irp->f, "]"); + if (instruction->is_const) + fprintf(irp->f, "const"); +} + static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { ir_print_prefix(irp, instruction); switch (instruction->id) { @@ -959,6 +991,15 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { case IrInstructionIdBoolNot: ir_print_bool_not(irp, (IrInstructionBoolNot *)instruction); break; + case IrInstructionIdMemset: + ir_print_memset(irp, (IrInstructionMemset *)instruction); + break; + case IrInstructionIdMemcpy: + ir_print_memcpy(irp, (IrInstructionMemcpy *)instruction); + break; + case IrInstructionIdSlice: + ir_print_slice(irp, (IrInstructionSlice *)instruction); + break; } fprintf(irp->f, "\n"); } |
