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

Method GetOperandValue

Source/SpireCore/SpirVCodeGen.cpp:3324–3409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3322 CompiledWorld * currentWorld;
3323
3324 int GetOperandValue(ILOperand * op)
3325 {
3326 int id = -1;
3327 if (auto c = dynamic_cast<ILConstOperand*>(op))
3328 {
3329 auto type = c->Type.Ptr();
3330 if (type->IsFloat())
3331 {
3332 id = ctx.AddInstrConstantFloat(c->FloatValues[0]);
3333 }
3334 else if (type->IsInt())
3335 {
3336 id = ctx.AddInstrConstantInt(c->IntValues[0]);
3337 }
3338 else if (type->IsUInt())
3339 {
3340 id = ctx.AddInstrConstantUInt(*((unsigned int*)(&c->IntValues[0])));
3341 }
3342 else if (auto baseType = dynamic_cast<ILBasicType*>(type))
3343 {
3344 if (baseType->Type == ILBaseType::Float2)
3345 {
3346 id = ctx.AddInstrConstantCompositeFloat(c->FloatValues, 2);
3347 }
3348 else if (baseType->Type == ILBaseType::Float3)
3349 {
3350 id = ctx.AddInstrConstantCompositeFloat(c->FloatValues, 3);
3351 }
3352 else if (baseType->Type == ILBaseType::Float4)
3353 {
3354 id = ctx.AddInstrConstantCompositeFloat(c->FloatValues, 4);
3355 }
3356 else if (baseType->Type == ILBaseType::Float3x3)
3357 {
3358 id = ctx.AddInstrConstantMatrix(c->FloatValues, 3);
3359 }
3360 else if (baseType->Type == ILBaseType::Float4x4)
3361 {
3362 id = ctx.AddInstrConstantMatrix(c->FloatValues, 4);
3363 }
3364 else if (baseType->Type == ILBaseType::Int2)
3365 {
3366 id = ctx.AddInstrConstantCompositeInt(c->IntValues, 2);
3367 }
3368 else if (baseType->Type == ILBaseType::Int3)
3369 {
3370 id = ctx.AddInstrConstantCompositeInt(c->IntValues, 3);
3371 }
3372 else if (baseType->Type == ILBaseType::Int4)
3373 {
3374 id = ctx.AddInstrConstantCompositeInt(c->IntValues, 4);
3375 }
3376 else if (baseType->Type == ILBaseType::UInt2)
3377 {
3378 id = ctx.AddInstrConstantCompositeUInt((unsigned int*)c->IntValues, 2);
3379 }
3380 else if (baseType->Type == ILBaseType::UInt3)
3381 {

Callers

nothing calls this directly

Calls 15

IsFloatMethod · 0.80
AddInstrConstantFloatMethod · 0.80
IsIntMethod · 0.80
AddInstrConstantIntMethod · 0.80
IsUIntMethod · 0.80
AddInstrConstantUIntMethod · 0.80
AddInstrConstantBoolMethod · 0.80

Tested by

no test coverage detected