| 4336 | } |
| 4337 | |
| 4338 | BfIRValue BfIRBuilder::ConstToMemory(BfIRValue constVal) |
| 4339 | { |
| 4340 | auto constant = GetConstant(constVal); |
| 4341 | BfIRValue* value = NULL; |
| 4342 | if (mConstMemMap.TryGetValue(constVal.mId, &value)) |
| 4343 | return *value; |
| 4344 | |
| 4345 | BfIRType constType; |
| 4346 | if (constant->mConstType == BfConstType_Agg) |
| 4347 | constType = ((BfConstantAgg*)constant)->mType; |
| 4348 | else if (constant->mConstType == BfConstType_AggZero) |
| 4349 | constType = constant->mIRType; |
| 4350 | else if (constant->mTypeCode == BfTypeCode_NullPtr) |
| 4351 | constType = constant->mIRType; |
| 4352 | else |
| 4353 | BF_FATAL("Invalid const type for ConstToMemory"); |
| 4354 | auto memVal = CreateGlobalVariable(constType, true, BfIRLinkageType_Internal, constVal, StrFormat("__constMem%d", constVal.mId)); |
| 4355 | mConstMemMap[constVal.mId] = memVal; |
| 4356 | return memVal; |
| 4357 | } |
| 4358 | |
| 4359 | BfIRValue BfIRBuilder::GetConfigConst(BfIRConfigConst constType, BfTypeCode typeCode) |
| 4360 | { |
no test coverage detected