mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-05 14:34:55 +00:00
MVT::getMVT uses iPTR for pointer types, while we need the actual
intptr_t type in this case. FastISel can now select simple getelementptr instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ad3460c3c9
commit
7a0e6593d0
@ -74,7 +74,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Type *Ty = I->getOperand(0)->getType();
|
const Type *Ty = I->getOperand(0)->getType();
|
||||||
MVT VT = MVT::getMVT(Ty, /*HandleUnknown=*/false);
|
MVT::SimpleValueType VT = TLI.getPointerTy().getSimpleVT();
|
||||||
for (GetElementPtrInst::op_iterator OI = I->op_begin()+1, E = I->op_end();
|
for (GetElementPtrInst::op_iterator OI = I->op_begin()+1, E = I->op_end();
|
||||||
OI != E; ++OI) {
|
OI != E; ++OI) {
|
||||||
Value *Idx = *OI;
|
Value *Idx = *OI;
|
||||||
@ -85,7 +85,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
|||||||
uint64_t Offs = TD.getStructLayout(StTy)->getElementOffset(Field);
|
uint64_t Offs = TD.getStructLayout(StTy)->getElementOffset(Field);
|
||||||
// FIXME: This can be optimized by combining the add with a
|
// FIXME: This can be optimized by combining the add with a
|
||||||
// subsequent one.
|
// subsequent one.
|
||||||
N = FastEmit_ri_(VT.getSimpleVT(), ISD::ADD, N, Offs, VT.getSimpleVT());
|
N = FastEmit_ri_(VT, ISD::ADD, N, Offs, VT);
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
@ -99,7 +99,7 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
|||||||
if (CI->getZExtValue() == 0) continue;
|
if (CI->getZExtValue() == 0) continue;
|
||||||
uint64_t Offs =
|
uint64_t Offs =
|
||||||
TD.getABITypeSize(Ty)*cast<ConstantInt>(CI)->getSExtValue();
|
TD.getABITypeSize(Ty)*cast<ConstantInt>(CI)->getSExtValue();
|
||||||
N = FastEmit_ri_(VT.getSimpleVT(), ISD::ADD, N, Offs, VT.getSimpleVT());
|
N = FastEmit_ri_(VT, ISD::ADD, N, Offs, VT);
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
@ -117,21 +117,21 @@ bool FastISel::SelectGetElementPtr(Instruction *I,
|
|||||||
// it.
|
// it.
|
||||||
MVT IdxVT = MVT::getMVT(Idx->getType(), /*HandleUnknown=*/false);
|
MVT IdxVT = MVT::getMVT(Idx->getType(), /*HandleUnknown=*/false);
|
||||||
if (IdxVT.bitsLT(VT))
|
if (IdxVT.bitsLT(VT))
|
||||||
IdxN = FastEmit_r(VT.getSimpleVT(), ISD::SIGN_EXTEND, IdxN);
|
IdxN = FastEmit_r(VT, ISD::SIGN_EXTEND, IdxN);
|
||||||
else if (IdxVT.bitsGT(VT))
|
else if (IdxVT.bitsGT(VT))
|
||||||
IdxN = FastEmit_r(VT.getSimpleVT(), ISD::TRUNCATE, IdxN);
|
IdxN = FastEmit_r(VT, ISD::TRUNCATE, IdxN);
|
||||||
if (IdxN == 0)
|
if (IdxN == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// FIXME: If multiple is power of two, turn it into a shift. The
|
// FIXME: If multiple is power of two, turn it into a shift. The
|
||||||
// optimization should be in FastEmit_ri?
|
// optimization should be in FastEmit_ri?
|
||||||
IdxN = FastEmit_ri_(VT.getSimpleVT(), ISD::MUL, IdxN,
|
IdxN = FastEmit_ri_(VT, ISD::MUL, IdxN,
|
||||||
ElementSize, VT.getSimpleVT());
|
ElementSize, VT);
|
||||||
if (IdxN == 0)
|
if (IdxN == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
N = FastEmit_rr(VT.getSimpleVT(), ISD::ADD, N, IdxN);
|
N = FastEmit_rr(VT, ISD::ADD, N, IdxN);
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
// Unhandled operand. Halt "fast" selection and bail.
|
// Unhandled operand. Halt "fast" selection and bail.
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
; This tests very minimal fast-isel functionality.
|
; This tests very minimal fast-isel functionality.
|
||||||
|
|
||||||
define i32 @foo(i32* %p, i32* %q) {
|
define i32* @foo(i32* %p, i32* %q, i32** %z) {
|
||||||
entry:
|
entry:
|
||||||
%r = load i32* %p
|
%r = load i32* %p
|
||||||
%s = load i32* %q
|
%s = load i32* %q
|
||||||
|
%y = load i32** %z
|
||||||
br label %fast
|
br label %fast
|
||||||
|
|
||||||
fast:
|
fast:
|
||||||
@ -17,10 +18,12 @@ fast:
|
|||||||
%t4 = or i32 %t3, %s
|
%t4 = or i32 %t3, %s
|
||||||
%t5 = xor i32 %t4, %s
|
%t5 = xor i32 %t4, %s
|
||||||
%t6 = add i32 %t5, 2
|
%t6 = add i32 %t5, 2
|
||||||
|
%t7 = getelementptr i32* %y, i32 1
|
||||||
|
%t8 = getelementptr i32* %t7, i32 %t6
|
||||||
br label %exit
|
br label %exit
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
ret i32 %t6
|
ret i32* %t8
|
||||||
}
|
}
|
||||||
|
|
||||||
define double @bar(double* %p, double* %q) {
|
define double @bar(double* %p, double* %q) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user