diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2007-04-21 08:16:25 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2007-04-21 08:16:25 +0000 |
commit | 2330e4d4c4f8008d17f5a38ac0d7b04e139d4131 (patch) | |
tree | 50e224364619b5ef673361d3c9535b97f75473a1 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 1b7f584fd81b4c0df42e06be79af7d7401d3b01d (diff) |
add support for alignment attributes on load/store instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36301 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 75fbf8afb9..7562f669ae 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -20,6 +20,7 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Target/TargetData.h" #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetInstrInfo.h" @@ -1539,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 }; @@ -1557,6 +1556,10 @@ 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 = MVT::getTypeForValueType(VT); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED, ISD::NON_EXTLOAD, VT, SV, SVOffset, Alignment, isVolatile); @@ -1569,7 +1572,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) @@ -1584,8 +1587,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 }; @@ -1601,6 +1602,10 @@ 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 = MVT::getTypeForValueType(VT); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new LoadSDNode(Ops, VTs, ISD::UNINDEXED, ExtType, EVT, SV, SVOffset, Alignment, isVolatile); CSEMap.InsertNode(N, IP); @@ -1648,11 +1653,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 }; @@ -1668,6 +1671,10 @@ 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 = MVT::getTypeForValueType(VT); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, false, VT, SV, SVOffset, Alignment, isVolatile); CSEMap.InsertNode(N, IP); @@ -1678,7 +1685,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; @@ -1686,8 +1693,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 }; @@ -1703,6 +1708,10 @@ 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 = MVT::getTypeForValueType(VT); + Alignment = TLI.getTargetData()->getABITypeAlignment(Ty); + } SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, isTrunc, SVT, SV, SVOffset, Alignment, isVolatile); CSEMap.InsertNode(N, IP); |