MCPcopy Create free account
hub / github.com/csyonghe/Spire / PrintUnaryInstr

Method PrintUnaryInstr

Source/SpireCore/SpirVCodeGen.cpp:3683–3722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3681 }
3682
3683 void PrintUnaryInstr(UnaryInstruction * instr)
3684 {
3685 auto op0 = instr->Operand.Ptr();
3686 if (instr->Is<LoadInstruction>())
3687 {
3688 ctx.AddInstrLoad((ILOperand*)instr, op0, MemoryAccess::None);
3689 return;
3690 }
3691
3692 if (instr->Is<NotInstruction>())
3693 instr->Type = GetTypeFromString("bool");
3694
3695 int op0ValueID = GetOperandValue(op0);
3696 op0ValueID = ctx.ConvertBasicType(op0ValueID, ctx.IDInfos[op0ValueID]().GetILType(), instr->Type);
3697 RefPtr<ILType> op0ILType = ctx.IDInfos[op0ValueID]().GetILType();
3698
3699 if (instr->Is<Float2IntInstruction>() || instr->Is<Int2FloatInstruction>() || instr->Is<CopyInstruction>())
3700 {
3701 ctx.UpdateValue((ILOperand*)instr, op0ValueID);
3702 return;
3703 }
3704
3705 int instrTypeID = ctx.DefineType(instr->Type);
3706
3707 if (instr->Is<NegInstruction>())
3708 {
3709 if (op0ILType->IsFloat() || op0ILType->IsFloatVector())
3710 ctx.AddInstrFnegate((ILOperand*)instr, instrTypeID, op0ValueID);
3711 else if (op0ILType->IsInt() || op0ILType->IsIntVector())
3712 ctx.AddInstrSnegate((ILOperand*)instr, instrTypeID, op0ValueID);
3713 else if (op0ILType->IsUInt() || op0ILType->IsUIntVector())
3714 throw InvalidOperationException("trying to negate a uint in PrintUnaryInstruction(): " + instr->ToString());
3715 }
3716 else if (instr->Is<BitNotInstruction>())
3717 ctx.AddInstrNot((ILOperand*)instr, instrTypeID, op0ValueID);
3718 else if (instr->Is<NotInstruction>())
3719 ctx.AddInstrLogicalNot((ILOperand*)instr, instrTypeID, op0ValueID);
3720 else
3721 throw InvalidProgramException("unsupported unary instruction.");
3722 }
3723
3724 void PrintBinaryInstr(BinaryInstruction * instr)
3725 {

Callers

nothing calls this directly

Calls 15

GetTypeFromStringFunction · 0.85
AddInstrLoadMethod · 0.80
ConvertBasicTypeMethod · 0.80
GetILTypeMethod · 0.80
UpdateValueMethod · 0.80
DefineTypeMethod · 0.80
IsFloatMethod · 0.80
IsFloatVectorMethod · 0.80
AddInstrFnegateMethod · 0.80
IsIntMethod · 0.80

Tested by

no test coverage detected