From 193604c837df75ab0c3fa5860f8b234263fe5b50 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Sat, 29 Jun 2019 11:32:26 -0500 Subject: stage1: add @shuffle() shufflevector support I change the semantics of the mask operand, to make it a little more flexible. There is no real danger in this because it is a compile-error if you do it the LLVM way (and there is an appropiate error to tell you this). v2: avoid problems with double-free --- src/ir_print.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/ir_print.cpp') diff --git a/src/ir_print.cpp b/src/ir_print.cpp index f2877b46e6..8561ed4508 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -42,6 +42,8 @@ static const char* ir_instruction_type_str(IrInstruction* instruction) { switch (instruction->id) { case IrInstructionIdInvalid: return "Invalid"; + case IrInstructionIdShuffleVector: + return "Shuffle"; case IrInstructionIdDeclVarSrc: return "DeclVarSrc"; case IrInstructionIdDeclVarGen: @@ -1208,6 +1210,18 @@ static void ir_print_vector_type(IrPrint *irp, IrInstructionVectorType *instruct fprintf(irp->f, ")"); } +static void ir_print_shuffle_vector(IrPrint *irp, IrInstructionShuffleVector *instruction) { + fprintf(irp->f, "@shuffle("); + ir_print_other_instruction(irp, instruction->scalar_type); + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, instruction->a); + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, instruction->b); + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, instruction->mask); + fprintf(irp->f, ")"); +} + static void ir_print_bool_not(IrPrint *irp, IrInstructionBoolNot *instruction) { fprintf(irp->f, "! "); ir_print_other_instruction(irp, instruction->value); @@ -2143,6 +2157,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction, bool case IrInstructionIdVectorType: ir_print_vector_type(irp, (IrInstructionVectorType *)instruction); break; + case IrInstructionIdShuffleVector: + ir_print_shuffle_vector(irp, (IrInstructionShuffleVector *)instruction); + break; case IrInstructionIdBoolNot: ir_print_bool_not(irp, (IrInstructionBoolNot *)instruction); break; -- cgit v1.2.3