mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
PR400 phase 2. Propagate attributed load/store information through DAGs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36356 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7d2cc2b983
commit
95c218a83e
@ -311,10 +311,12 @@ public:
|
||||
/// determined by their operands, and they produce a value AND a token chain.
|
||||
///
|
||||
SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
|
||||
const Value *SV, int SVOffset, bool isVolatile=false);
|
||||
const Value *SV, int SVOffset, bool isVolatile=false,
|
||||
unsigned Alignment=0);
|
||||
SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
|
||||
SDOperand Chain, SDOperand Ptr, const Value *SV,
|
||||
int SVOffset, MVT::ValueType EVT, bool isVolatile=false);
|
||||
int SVOffset, MVT::ValueType EVT, bool isVolatile=false,
|
||||
unsigned Alignment=0);
|
||||
SDOperand getIndexedLoad(SDOperand OrigLoad, SDOperand Base,
|
||||
SDOperand Offset, ISD::MemIndexedMode AM);
|
||||
SDOperand getVecLoad(unsigned Count, MVT::ValueType VT, SDOperand Chain,
|
||||
@ -323,10 +325,11 @@ public:
|
||||
/// getStore - Helper function to build ISD::STORE nodes.
|
||||
///
|
||||
SDOperand getStore(SDOperand Chain, SDOperand Val, SDOperand Ptr,
|
||||
const Value *SV, int SVOffset, bool isVolatile=false);
|
||||
const Value *SV, int SVOffset, bool isVolatile=false,
|
||||
unsigned Alignment=0);
|
||||
SDOperand getTruncStore(SDOperand Chain, SDOperand Val, SDOperand Ptr,
|
||||
const Value *SV, int SVOffset, MVT::ValueType TVT,
|
||||
bool isVolatile=false);
|
||||
bool isVolatile=false, unsigned Alignment=0);
|
||||
SDOperand getIndexedStore(SDOperand OrigStoe, SDOperand Base,
|
||||
SDOperand Offset, ISD::MemIndexedMode AM);
|
||||
|
||||
|
@ -1438,7 +1438,7 @@ protected:
|
||||
friend class SelectionDAG;
|
||||
LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs,
|
||||
ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
|
||||
const Value *SV, int O=0, unsigned Align=1, bool Vol=false)
|
||||
const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
|
||||
: SDNode(ISD::LOAD, VTs),
|
||||
AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O),
|
||||
Alignment(Align), IsVolatile(Vol) {
|
||||
@ -1446,6 +1446,7 @@ protected:
|
||||
Ops[1] = ChainPtrOff[1]; // Ptr
|
||||
Ops[2] = ChainPtrOff[2]; // Off
|
||||
InitOperands(Ops, 3);
|
||||
assert(Align != 0 && "Loads should have non-zero aligment");
|
||||
assert((getOffset().getOpcode() == ISD::UNDEF ||
|
||||
AddrMode != ISD::UNINDEXED) &&
|
||||
"Only indexed load has a non-undef offset operand");
|
||||
@ -1508,6 +1509,7 @@ protected:
|
||||
Ops[2] = ChainValuePtrOff[2]; // Ptr
|
||||
Ops[3] = ChainValuePtrOff[3]; // Off
|
||||
InitOperands(Ops, 4);
|
||||
assert(Align != 0 && "Stores should have non-zero aligment");
|
||||
assert((getOffset().getOpcode() == ISD::UNDEF ||
|
||||
AddrMode != ISD::UNINDEXED) &&
|
||||
"Only indexed store has a non-undef offset operand");
|
||||
|
@ -1263,7 +1263,9 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
|
||||
(!AfterLegalize || TLI.isLoadXLegal(ISD::ZEXTLOAD, EVT))) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
AddToWorkList(N);
|
||||
CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1));
|
||||
return SDOperand(N, 0); // Return N so it doesn't get rechecked!
|
||||
@ -1280,7 +1282,9 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
|
||||
(!AfterLegalize || TLI.isLoadXLegal(ISD::ZEXTLOAD, EVT))) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
AddToWorkList(N);
|
||||
CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1));
|
||||
return SDOperand(N, 0); // Return N so it doesn't get rechecked!
|
||||
@ -1320,7 +1324,8 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
|
||||
AddToWorkList(NewPtr.Val);
|
||||
SDOperand Load =
|
||||
DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(), NewPtr,
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(), LN0->getAlignment());
|
||||
AddToWorkList(N);
|
||||
CombineTo(N0.Val, Load, Load.getValue(1));
|
||||
return SDOperand(N, 0); // Return N so it doesn't get rechecked!
|
||||
@ -2120,7 +2125,8 @@ SDOperand DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(),
|
||||
N0.getValueType());
|
||||
N0.getValueType(),
|
||||
LN0->isVolatile());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad),
|
||||
ExtLoad.getValue(1));
|
||||
@ -2136,7 +2142,9 @@ SDOperand DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
|
||||
if (!AfterLegalize || TLI.isLoadXLegal(ISD::SEXTLOAD, EVT)) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad),
|
||||
ExtLoad.getValue(1));
|
||||
@ -2212,7 +2220,9 @@ SDOperand DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(),
|
||||
N0.getValueType());
|
||||
N0.getValueType(),
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad),
|
||||
ExtLoad.getValue(1));
|
||||
@ -2227,7 +2237,9 @@ SDOperand DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
||||
MVT::ValueType EVT = LN0->getLoadedVT();
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad),
|
||||
ExtLoad.getValue(1));
|
||||
@ -2303,7 +2315,9 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::EXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(),
|
||||
N0.getValueType());
|
||||
N0.getValueType(),
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad),
|
||||
ExtLoad.getValue(1));
|
||||
@ -2321,7 +2335,9 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(LN0->getExtensionType(), VT,
|
||||
LN0->getChain(), LN0->getBasePtr(),
|
||||
LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::TRUNCATE, N0.getValueType(), ExtLoad),
|
||||
ExtLoad.getValue(1));
|
||||
@ -2398,9 +2414,11 @@ SDOperand DAGCombiner::ReduceLoadWidth(SDNode *N) {
|
||||
AddToWorkList(NewPtr.Val);
|
||||
SDOperand Load = (ExtType == ISD::NON_EXTLOAD)
|
||||
? DAG.getLoad(VT, LN0->getChain(), NewPtr,
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset())
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset(),
|
||||
LN0->isVolatile(), LN0->getAlignment())
|
||||
: DAG.getExtLoad(ExtType, VT, LN0->getChain(), NewPtr,
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(), LN0->getAlignment());
|
||||
AddToWorkList(N);
|
||||
if (CombineSRL) {
|
||||
std::vector<SDNode*> NowDead;
|
||||
@ -2479,7 +2497,9 @@ SDOperand DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
|
||||
LoadSDNode *LN0 = cast<LoadSDNode>(N0);
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1));
|
||||
return SDOperand(N, 0); // Return N so it doesn't get rechecked!
|
||||
@ -2492,7 +2512,9 @@ SDOperand DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
|
||||
LoadSDNode *LN0 = cast<LoadSDNode>(N0);
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(), EVT);
|
||||
LN0->getSrcValueOffset(), EVT,
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, ExtLoad, ExtLoad.getValue(1));
|
||||
return SDOperand(N, 0); // Return N so it doesn't get rechecked!
|
||||
@ -2552,7 +2574,8 @@ SDOperand DAGCombiner::visitBIT_CONVERT(SDNode *N) {
|
||||
if (0 && ISD::isNON_EXTLoad(N0.Val) && N0.hasOneUse()) {
|
||||
LoadSDNode *LN0 = cast<LoadSDNode>(N0);
|
||||
SDOperand Load = DAG.getLoad(VT, LN0->getChain(), LN0->getBasePtr(),
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset());
|
||||
LN0->getSrcValue(), LN0->getSrcValueOffset(),
|
||||
LN0->isVolatile(), LN0->getAlignment());
|
||||
AddToWorkList(N);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::BIT_CONVERT, N0.getValueType(), Load),
|
||||
Load.getValue(1));
|
||||
@ -2942,7 +2965,9 @@ SDOperand DAGCombiner::visitFP_EXTEND(SDNode *N) {
|
||||
SDOperand ExtLoad = DAG.getExtLoad(ISD::EXTLOAD, VT, LN0->getChain(),
|
||||
LN0->getBasePtr(), LN0->getSrcValue(),
|
||||
LN0->getSrcValueOffset(),
|
||||
N0.getValueType());
|
||||
N0.getValueType(),
|
||||
LN0->isVolatile(),
|
||||
LN0->getAlignment());
|
||||
CombineTo(N, ExtLoad);
|
||||
CombineTo(N0.Val, DAG.getNode(ISD::FP_ROUND, N0.getValueType(), ExtLoad),
|
||||
ExtLoad.getValue(1));
|
||||
@ -3331,13 +3356,16 @@ SDOperand DAGCombiner::visitLOAD(SDNode *N) {
|
||||
// Replace the chain to void dependency.
|
||||
if (LD->getExtensionType() == ISD::NON_EXTLOAD) {
|
||||
ReplLoad = DAG.getLoad(N->getValueType(0), BetterChain, Ptr,
|
||||
LD->getSrcValue(), LD->getSrcValueOffset());
|
||||
LD->getSrcValue(), LD->getSrcValueOffset(),
|
||||
LD->isVolatile(), LD->getAlignment());
|
||||
} else {
|
||||
ReplLoad = DAG.getExtLoad(LD->getExtensionType(),
|
||||
LD->getValueType(0),
|
||||
BetterChain, Ptr, LD->getSrcValue(),
|
||||
LD->getSrcValueOffset(),
|
||||
LD->getLoadedVT());
|
||||
LD->getLoadedVT(),
|
||||
LD->isVolatile(),
|
||||
LD->getAlignment());
|
||||
}
|
||||
|
||||
// Create token factor to keep old chain connected.
|
||||
@ -4040,13 +4068,17 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDOperand LHS,
|
||||
if (LLD->getExtensionType() == ISD::NON_EXTLOAD)
|
||||
Load = DAG.getLoad(TheSelect->getValueType(0), LLD->getChain(),
|
||||
Addr,LLD->getSrcValue(),
|
||||
LLD->getSrcValueOffset());
|
||||
LLD->getSrcValueOffset(),
|
||||
LLD->isVolatile(),
|
||||
LLD->getAlignment());
|
||||
else {
|
||||
Load = DAG.getExtLoad(LLD->getExtensionType(),
|
||||
TheSelect->getValueType(0),
|
||||
LLD->getChain(), Addr, LLD->getSrcValue(),
|
||||
LLD->getSrcValueOffset(),
|
||||
LLD->getLoadedVT());
|
||||
LLD->getLoadedVT(),
|
||||
LLD->isVolatile(),
|
||||
LLD->getAlignment());
|
||||
}
|
||||
// Users of the select now use the result of the load.
|
||||
CombineTo(TheSelect, Load);
|
||||
|
@ -15,11 +15,13 @@
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/GlobalVariable.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Target/MRegisterInfo.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
@ -1538,9 +1540,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
||||
SDOperand SelectionDAG::getLoad(MVT::ValueType VT,
|
||||
SDOperand Chain, SDOperand Ptr,
|
||||
const Value *SV, int SVOffset,
|
||||
bool isVolatile) {
|
||||
// FIXME: Alignment == 1 for now.
|
||||
unsigned Alignment = 1;
|
||||
bool isVolatile, unsigned Alignment) {
|
||||
SDVTList VTs = getVTList(VT, MVT::Other);
|
||||
SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType());
|
||||
SDOperand Ops[] = { Chain, Ptr, Undef };
|
||||
@ -1556,6 +1556,18 @@ SDOperand SelectionDAG::getLoad(MVT::ValueType VT,
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDOperand(E, 0);
|
||||
if (Alignment == 0) { // Ensure that codegen never sees alignment 0
|
||||
const Type *Ty = 0;
|
||||
if (VT != MVT::Vector && VT != MVT::iPTR) {
|
||||
Ty = MVT::getTypeForValueType(VT);
|
||||
} else if (SV) {
|
||||
const PointerType *PT = dyn_cast<PointerType>(SV->getType());
|
||||
assert(PT && "Value for load must be a pointer");
|
||||
Ty = PT->getElementType();
|
||||
}
|
||||
assert(Ty && "Could not get type information for load");
|
||||
Alignment = TLI.getTargetData()->getABITypeAlignment(Ty);
|
||||
}
|
||||
SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED,
|
||||
ISD::NON_EXTLOAD, VT, SV, SVOffset, Alignment,
|
||||
isVolatile);
|
||||
@ -1568,7 +1580,7 @@ SDOperand SelectionDAG::getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
|
||||
SDOperand Chain, SDOperand Ptr,
|
||||
const Value *SV,
|
||||
int SVOffset, MVT::ValueType EVT,
|
||||
bool isVolatile) {
|
||||
bool isVolatile, unsigned Alignment) {
|
||||
// If they are asking for an extending load from/to the same thing, return a
|
||||
// normal load.
|
||||
if (VT == EVT)
|
||||
@ -1583,8 +1595,6 @@ SDOperand SelectionDAG::getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
|
||||
assert(MVT::isInteger(VT) == MVT::isInteger(EVT) &&
|
||||
"Cannot convert from FP to Int or Int -> FP!");
|
||||
|
||||
// FIXME: Alignment == 1 for now.
|
||||
unsigned Alignment = 1;
|
||||
SDVTList VTs = getVTList(VT, MVT::Other);
|
||||
SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType());
|
||||
SDOperand Ops[] = { Chain, Ptr, Undef };
|
||||
@ -1600,6 +1610,18 @@ SDOperand SelectionDAG::getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDOperand(E, 0);
|
||||
if (Alignment == 0) { // Ensure that codegen never sees alignment 0
|
||||
const Type *Ty = 0;
|
||||
if (VT != MVT::Vector && VT != MVT::iPTR) {
|
||||
Ty = MVT::getTypeForValueType(VT);
|
||||
} else if (SV) {
|
||||
const PointerType *PT = dyn_cast<PointerType>(SV->getType());
|
||||
assert(PT && "Value for load must be a pointer");
|
||||
Ty = PT->getElementType();
|
||||
}
|
||||
assert(Ty && "Could not get type information for load");
|
||||
Alignment = TLI.getTargetData()->getABITypeAlignment(Ty);
|
||||
}
|
||||
SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED, ExtType, EVT,
|
||||
SV, SVOffset, Alignment, isVolatile);
|
||||
CSEMap.InsertNode(N, IP);
|
||||
@ -1647,11 +1669,9 @@ SDOperand SelectionDAG::getVecLoad(unsigned Count, MVT::ValueType EVT,
|
||||
|
||||
SDOperand SelectionDAG::getStore(SDOperand Chain, SDOperand Val,
|
||||
SDOperand Ptr, const Value *SV, int SVOffset,
|
||||
bool isVolatile) {
|
||||
bool isVolatile, unsigned Alignment) {
|
||||
MVT::ValueType VT = Val.getValueType();
|
||||
|
||||
// FIXME: Alignment == 1 for now.
|
||||
unsigned Alignment = 1;
|
||||
SDVTList VTs = getVTList(MVT::Other);
|
||||
SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType());
|
||||
SDOperand Ops[] = { Chain, Val, Ptr, Undef };
|
||||
@ -1667,6 +1687,18 @@ SDOperand SelectionDAG::getStore(SDOperand Chain, SDOperand Val,
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDOperand(E, 0);
|
||||
if (Alignment == 0) { // Ensure that codegen never sees alignment 0
|
||||
const Type *Ty = 0;
|
||||
if (VT != MVT::Vector && VT != MVT::iPTR) {
|
||||
Ty = MVT::getTypeForValueType(VT);
|
||||
} else if (SV) {
|
||||
const PointerType *PT = dyn_cast<PointerType>(SV->getType());
|
||||
assert(PT && "Value for store must be a pointer");
|
||||
Ty = PT->getElementType();
|
||||
}
|
||||
assert(Ty && "Could not get type information for store");
|
||||
Alignment = TLI.getTargetData()->getABITypeAlignment(Ty);
|
||||
}
|
||||
SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, false,
|
||||
VT, SV, SVOffset, Alignment, isVolatile);
|
||||
CSEMap.InsertNode(N, IP);
|
||||
@ -1677,7 +1709,7 @@ SDOperand SelectionDAG::getStore(SDOperand Chain, SDOperand Val,
|
||||
SDOperand SelectionDAG::getTruncStore(SDOperand Chain, SDOperand Val,
|
||||
SDOperand Ptr, const Value *SV,
|
||||
int SVOffset, MVT::ValueType SVT,
|
||||
bool isVolatile) {
|
||||
bool isVolatile, unsigned Alignment) {
|
||||
MVT::ValueType VT = Val.getValueType();
|
||||
bool isTrunc = VT != SVT;
|
||||
|
||||
@ -1685,8 +1717,6 @@ SDOperand SelectionDAG::getTruncStore(SDOperand Chain, SDOperand Val,
|
||||
assert(MVT::isInteger(VT) == MVT::isInteger(SVT) &&
|
||||
"Can't do FP-INT conversion!");
|
||||
|
||||
// FIXME: Alignment == 1 for now.
|
||||
unsigned Alignment = 1;
|
||||
SDVTList VTs = getVTList(MVT::Other);
|
||||
SDOperand Undef = getNode(ISD::UNDEF, Ptr.getValueType());
|
||||
SDOperand Ops[] = { Chain, Val, Ptr, Undef };
|
||||
@ -1702,6 +1732,18 @@ SDOperand SelectionDAG::getTruncStore(SDOperand Chain, SDOperand Val,
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDOperand(E, 0);
|
||||
if (Alignment == 0) { // Ensure that codegen never sees alignment 0
|
||||
const Type *Ty = 0;
|
||||
if (VT != MVT::Vector && VT != MVT::iPTR) {
|
||||
Ty = MVT::getTypeForValueType(VT);
|
||||
} else if (SV) {
|
||||
const PointerType *PT = dyn_cast<PointerType>(SV->getType());
|
||||
assert(PT && "Value for store must be a pointer");
|
||||
Ty = PT->getElementType();
|
||||
}
|
||||
assert(Ty && "Could not get type information for store");
|
||||
Alignment = TLI.getTargetData()->getABITypeAlignment(Ty);
|
||||
}
|
||||
SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, isTrunc,
|
||||
SVT, SV, SVOffset, Alignment, isVolatile);
|
||||
CSEMap.InsertNode(N, IP);
|
||||
|
@ -498,7 +498,7 @@ public:
|
||||
|
||||
SDOperand getLoadFrom(const Type *Ty, SDOperand Ptr,
|
||||
const Value *SV, SDOperand Root,
|
||||
bool isVolatile);
|
||||
bool isVolatile, unsigned Alignment);
|
||||
|
||||
SDOperand getIntPtrConstant(uint64_t Val) {
|
||||
return DAG.getConstant(Val, TLI.getPointerTy());
|
||||
@ -2313,19 +2313,21 @@ void SelectionDAGLowering::visitLoad(LoadInst &I) {
|
||||
}
|
||||
|
||||
setValue(&I, getLoadFrom(I.getType(), Ptr, I.getOperand(0),
|
||||
Root, I.isVolatile()));
|
||||
Root, I.isVolatile(), I.getAlignment()));
|
||||
}
|
||||
|
||||
SDOperand SelectionDAGLowering::getLoadFrom(const Type *Ty, SDOperand Ptr,
|
||||
const Value *SV, SDOperand Root,
|
||||
bool isVolatile) {
|
||||
bool isVolatile,
|
||||
unsigned Alignment) {
|
||||
SDOperand L;
|
||||
if (const VectorType *PTy = dyn_cast<VectorType>(Ty)) {
|
||||
MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
|
||||
L = DAG.getVecLoad(PTy->getNumElements(), PVT, Root, Ptr,
|
||||
DAG.getSrcValue(SV));
|
||||
} else {
|
||||
L = DAG.getLoad(TLI.getValueType(Ty), Root, Ptr, SV, 0, isVolatile);
|
||||
L = DAG.getLoad(TLI.getValueType(Ty), Root, Ptr, SV, 0,
|
||||
isVolatile, Alignment);
|
||||
}
|
||||
|
||||
if (isVolatile)
|
||||
@ -2342,7 +2344,7 @@ void SelectionDAGLowering::visitStore(StoreInst &I) {
|
||||
SDOperand Src = getValue(SrcV);
|
||||
SDOperand Ptr = getValue(I.getOperand(1));
|
||||
DAG.setRoot(DAG.getStore(getRoot(), Src, Ptr, I.getOperand(1), 0,
|
||||
I.isVolatile()));
|
||||
I.isVolatile(), I.getAlignment()));
|
||||
}
|
||||
|
||||
/// IntrinsicCannotAccessMemory - Return true if the specified intrinsic cannot
|
||||
|
Loading…
x
Reference in New Issue
Block a user