MCPcopy Create free account
hub / github.com/beefytech/Beef / CreateIndexedValue

Method CreateIndexedValue

IDEHelper/Compiler/BfModule.cpp:14115–14137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14113}
14114
14115BfIRValue BfModule::CreateIndexedValue(BfType* elementType, BfIRValue value, BfIRValue indexValue, bool isElementIndex)
14116{
14117 if (isElementIndex)
14118 return mBfIRBuilder->CreateInBoundsGEP(value, GetConstValue(0), indexValue);
14119 else
14120 return mBfIRBuilder->CreateInBoundsGEP(value, indexValue);
14121
14122// if (elementType->IsSizeAligned())
14123// {
14124// if (isElementIndex)
14125// return mBfIRBuilder->CreateInBoundsGEP(value, GetConstValue(0), indexValue);
14126// else
14127// return mBfIRBuilder->CreateInBoundsGEP(value, indexValue);
14128// }
14129//
14130// auto ptrType = CreatePointerType(elementType);
14131// auto ofsVal = mBfIRBuilder->CreateNumericCast(indexValue, true, BfTypeCode_IntPtr);
14132// auto ofsScaledVal = mBfIRBuilder->CreateMul(ofsVal, mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, elementType->GetStride()));
14133// auto i8PtrType = mBfIRBuilder->GetPointerTo(mBfIRBuilder->GetPrimitiveType(BfTypeCode_Int8));
14134// BfIRValue origPtrValue = mBfIRBuilder->CreateBitCast(value, i8PtrType);
14135// BfIRValue newPtrValue = mBfIRBuilder->CreateInBoundsGEP(origPtrValue, ofsScaledVal);
14136// return mBfIRBuilder->CreateBitCast(newPtrValue, mBfIRBuilder->MapType(ptrType));
14137}
14138
14139BfIRValue BfModule::CreateIndexedValue(BfType* elementType, BfIRValue value, int indexValue, bool isElementIndex)
14140{

Callers 5

CreateCallMethod · 0.80
HandleMethod · 0.80
InitializedSizedArrayMethod · 0.80

Calls 2

CreateInBoundsGEPMethod · 0.80
IsSizeAlignedMethod · 0.80

Tested by

no test coverage detected