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

Method AddInstrMulAdd

Source/SpireCore/SpirVCodeGen.cpp:2963–2984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2961 }
2962
2963 int AddInstrMulAdd(int operandID, float mul, float add)
2964 {
2965 //return 0.5*op+0.5
2966 int typeID = IDInfos[operandID]().GetTypeID(); //shoudl be float
2967 RefPtr<ILType> typeIL = IDInfos[operandID]().GetILType();
2968
2969 int mul_ID = AddInstrConstantFloat(mul);
2970 mul_ID = ConvertBasicType(mul_ID, IDInfos[mul_ID]().GetILType(), IDInfos[operandID]().GetILType());
2971
2972 int add_ID = AddInstrConstantFloat(add);
2973 add_ID = ConvertBasicType(add_ID, IDInfos[add_ID]().GetILType(), IDInfos[operandID]().GetILType());
2974
2975 ++CurrentID;
2976 //ctx.FunctionBody << LR"(%)" << ctx.CurrentID << LR"( = OpFMul %)" << typeID << LR"( %)" << operandID << LR"( %)" << mul_ID << EndLine;
2977 CodeGen.OpFMul(CurrentID, typeID, operandID, mul_ID);
2978 IDInfos[CurrentID] = IDInfo::CreateIDInfoForValue(CurrentID, typeIL, 0, typeID);
2979 ++CurrentID;
2980 //ctx.FunctionBody << LR"(%)" << ctx.CurrentID << LR"( = OpFAdd %)" << typeID << LR"( %)" << ctx.CurrentID-1 << LR"( %)" << add_ID << EndLine;
2981 CodeGen.OpFAdd(CurrentID, typeID, CurrentID - 1, add_ID);
2982 IDInfos[CurrentID] = IDInfo::CreateIDInfoForValue(CurrentID, typeIL, 0, typeID);
2983 return CurrentID;
2984 }
2985
2986 int ConvertBasicType(int operandID, RefPtr<ILType> srcType, RefPtr<ILType> dstType)
2987 {

Callers 2

PrintExportInstrMethod · 0.80
PrintImportInstrMethod · 0.80

Calls 4

GetTypeIDMethod · 0.80
GetILTypeMethod · 0.80
OpFMulMethod · 0.80
OpFAddMethod · 0.80

Tested by

no test coverage detected