mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-19 03:29:22 +00:00
Implement support for long GEP indices on 32-bit archs and support for
int GEP indices on 64-bit archs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fd8c39b773
commit
7cc4777a26
@ -529,6 +529,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
break;
|
break;
|
||||||
case ISD::ZERO_EXTEND:
|
case ISD::ZERO_EXTEND:
|
||||||
case ISD::SIGN_EXTEND:
|
case ISD::SIGN_EXTEND:
|
||||||
|
case ISD::TRUNCATE:
|
||||||
case ISD::FP_EXTEND:
|
case ISD::FP_EXTEND:
|
||||||
case ISD::FP_ROUND:
|
case ISD::FP_ROUND:
|
||||||
switch (getTypeAction(Node->getOperand(0).getValueType())) {
|
switch (getTypeAction(Node->getOperand(0).getValueType())) {
|
||||||
|
@ -477,9 +477,20 @@ void SelectionDAGLowering::visitGetElementPtr(User &I) {
|
|||||||
if (!isa<Constant>(Idx) || !cast<Constant>(Idx)->isNullValue()) {
|
if (!isa<Constant>(Idx) || !cast<Constant>(Idx)->isNullValue()) {
|
||||||
// N = N + Idx * ElementSize;
|
// N = N + Idx * ElementSize;
|
||||||
uint64_t ElementSize = TD.getTypeSize(Ty);
|
uint64_t ElementSize = TD.getTypeSize(Ty);
|
||||||
SDOperand IdxN = getValue(Idx);
|
SDOperand IdxN = getValue(Idx), Scale = getIntPtrConstant(ElementSize);
|
||||||
IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN,
|
|
||||||
getIntPtrConstant(ElementSize));
|
// If the index is smaller or larger than intptr_t, truncate or extend
|
||||||
|
// it.
|
||||||
|
if (IdxN.getValueType() < Scale.getValueType()) {
|
||||||
|
if (Idx->getType()->isSigned())
|
||||||
|
IdxN = DAG.getNode(ISD::SIGN_EXTEND, Scale.getValueType(), IdxN);
|
||||||
|
else
|
||||||
|
IdxN = DAG.getNode(ISD::ZERO_EXTEND, Scale.getValueType(), IdxN);
|
||||||
|
} else if (IdxN.getValueType() > Scale.getValueType())
|
||||||
|
IdxN = DAG.getNode(ISD::TRUNCATE, Scale.getValueType(), IdxN);
|
||||||
|
|
||||||
|
IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN, Scale);
|
||||||
|
|
||||||
N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
|
N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user