mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 02:29:18 +00:00
[FastISel][AArch64] Don't bail during simple GEP instruction selection.
The generic FastISel code would bail, because it can't emit a sign-extend for AArch64. This copies the code over and uses AArch64 specific emit functions. This is not ideal and 'computeAddress' should handles this, so it can fold the address computation into the memory operation. I plan to clean up 'computeAddress' anyways, so I will add that in a future commit. Related to rdar://problem/18962471. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221923 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
01ab7a869d
commit
add7c56be5
@ -151,6 +151,7 @@ private:
|
|||||||
const Value *Cond);
|
const Value *Cond);
|
||||||
bool optimizeIntExtLoad(const Instruction *I, MVT RetVT, MVT SrcVT);
|
bool optimizeIntExtLoad(const Instruction *I, MVT RetVT, MVT SrcVT);
|
||||||
bool optimizeSelect(const SelectInst *SI);
|
bool optimizeSelect(const SelectInst *SI);
|
||||||
|
std::pair<unsigned, bool> getRegForGEPIndex(const Value *Idx);
|
||||||
|
|
||||||
// Emit helper routines.
|
// Emit helper routines.
|
||||||
unsigned emitAddSub(bool UseAdd, MVT RetVT, const Value *LHS,
|
unsigned emitAddSub(bool UseAdd, MVT RetVT, const Value *LHS,
|
||||||
@ -4725,6 +4726,28 @@ bool AArch64FastISel::selectSDiv(const Instruction *I) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is mostly a copy of the existing FastISel getRegForGEPIndex code. We
|
||||||
|
/// have to duplicate it for AArch64, because otherwise we would fail during the
|
||||||
|
/// sign-extend emission.
|
||||||
|
std::pair<unsigned, bool> AArch64FastISel::getRegForGEPIndex(const Value *Idx) {
|
||||||
|
unsigned IdxN = getRegForValue(Idx);
|
||||||
|
if (IdxN == 0)
|
||||||
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
|
return std::pair<unsigned, bool>(0, false);
|
||||||
|
|
||||||
|
bool IdxNIsKill = hasTrivialKill(Idx);
|
||||||
|
|
||||||
|
// If the index is smaller or larger than intptr_t, truncate or extend it.
|
||||||
|
MVT PtrVT = TLI.getPointerTy();
|
||||||
|
EVT IdxVT = EVT::getEVT(Idx->getType(), /*HandleUnknown=*/false);
|
||||||
|
if (IdxVT.bitsLT(PtrVT)) {
|
||||||
|
IdxN = emitIntExt(IdxVT.getSimpleVT(), IdxN, PtrVT, /*IsZExt=*/false);
|
||||||
|
IdxNIsKill = true;
|
||||||
|
} else if (IdxVT.bitsGT(PtrVT))
|
||||||
|
llvm_unreachable("AArch64 FastISel doesn't support types larger than i64");
|
||||||
|
return std::pair<unsigned, bool>(IdxN, IdxNIsKill);
|
||||||
|
}
|
||||||
|
|
||||||
/// This is mostly a copy of the existing FastISel GEP code, but we have to
|
/// This is mostly a copy of the existing FastISel GEP code, but we have to
|
||||||
/// duplicate it for AArch64, because otherwise we would bail out even for
|
/// duplicate it for AArch64, because otherwise we would bail out even for
|
||||||
/// simple cases. This is because the standard fastEmit functions don't cover
|
/// simple cases. This is because the standard fastEmit functions don't cover
|
||||||
|
@ -39,3 +39,11 @@ define i32* @test_array4(i32* %a) {
|
|||||||
ret i32* %1
|
ret i32* %1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define i32* @test_array5(i32* %a, i32 %i) {
|
||||||
|
; CHECK-LABEL: test_array5
|
||||||
|
; CHECK: sxtw [[REG1:x[0-9]+]], w1
|
||||||
|
; CHECK-NEXT: orr [[REG2:x[0-9]+]], xzr, #0x4
|
||||||
|
; CHECK-NEXT: madd {{x[0-9]+}}, [[REG1]], [[REG2]], x0
|
||||||
|
%1 = getelementptr inbounds i32* %a, i32 %i
|
||||||
|
ret i32* %1
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user