| 14113 | } |
| 14114 | |
| 14115 | BfIRValue 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 | |
| 14139 | BfIRValue BfModule::CreateIndexedValue(BfType* elementType, BfIRValue value, int indexValue, bool isElementIndex) |
| 14140 | { |
no test coverage detected