From ef63bc9cca6370f03d76a2a19dd7cdd7e23270d4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 12 Dec 2016 00:31:35 -0500 Subject: IR: implement memcpy, memset, and slice expression --- src/ir_print.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/ir_print.cpp') 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"); } -- cgit v1.2.3