mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 17:25:21 +00:00
Re-apply the memory operand changes, with a fix for the static
initializer problem, a minor tweak to the way the DAGISelEmitter finds load/store nodes, and a renaming of the new PseudoSourceValue objects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46827 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/CodeGen/PseudoSourceValue.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Target/MRegisterInfo.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
@@ -361,10 +362,16 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
|
||||
case ISD::Register:
|
||||
ID.AddInteger(cast<RegisterSDNode>(N)->getReg());
|
||||
break;
|
||||
case ISD::SRCVALUE: {
|
||||
SrcValueSDNode *SV = cast<SrcValueSDNode>(N);
|
||||
ID.AddPointer(SV->getValue());
|
||||
ID.AddInteger(SV->getOffset());
|
||||
case ISD::SRCVALUE:
|
||||
ID.AddPointer(cast<SrcValueSDNode>(N)->getValue());
|
||||
break;
|
||||
case ISD::MEMOPERAND: {
|
||||
const MemOperand &MO = cast<MemOperandSDNode>(N)->MO;
|
||||
ID.AddPointer(MO.getValue());
|
||||
ID.AddInteger(MO.getFlags());
|
||||
ID.AddInteger(MO.getOffset());
|
||||
ID.AddInteger(MO.getSize());
|
||||
ID.AddInteger(MO.getAlignment());
|
||||
break;
|
||||
}
|
||||
case ISD::FrameIndex:
|
||||
@@ -937,18 +944,42 @@ SDOperand SelectionDAG::getRegister(unsigned RegNo, MVT::ValueType VT) {
|
||||
return SDOperand(N, 0);
|
||||
}
|
||||
|
||||
SDOperand SelectionDAG::getSrcValue(const Value *V, int Offset) {
|
||||
SDOperand SelectionDAG::getSrcValue(const Value *V) {
|
||||
assert((!V || isa<PointerType>(V->getType())) &&
|
||||
"SrcValue is not a pointer?");
|
||||
|
||||
FoldingSetNodeID ID;
|
||||
AddNodeIDNode(ID, ISD::SRCVALUE, getVTList(MVT::Other), 0, 0);
|
||||
ID.AddPointer(V);
|
||||
ID.AddInteger(Offset);
|
||||
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDOperand(E, 0);
|
||||
SDNode *N = new SrcValueSDNode(V, Offset);
|
||||
|
||||
SDNode *N = new SrcValueSDNode(V);
|
||||
CSEMap.InsertNode(N, IP);
|
||||
AllNodes.push_back(N);
|
||||
return SDOperand(N, 0);
|
||||
}
|
||||
|
||||
SDOperand SelectionDAG::getMemOperand(const MemOperand &MO) {
|
||||
const Value *v = MO.getValue();
|
||||
assert((!v || isa<PointerType>(v->getType())) &&
|
||||
"SrcValue is not a pointer?");
|
||||
|
||||
FoldingSetNodeID ID;
|
||||
AddNodeIDNode(ID, ISD::MEMOPERAND, getVTList(MVT::Other), 0, 0);
|
||||
ID.AddPointer(v);
|
||||
ID.AddInteger(MO.getFlags());
|
||||
ID.AddInteger(MO.getOffset());
|
||||
ID.AddInteger(MO.getSize());
|
||||
ID.AddInteger(MO.getAlignment());
|
||||
|
||||
void *IP = 0;
|
||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||
return SDOperand(E, 0);
|
||||
|
||||
SDNode *N = new MemOperandSDNode(MO);
|
||||
CSEMap.InsertNode(N, IP);
|
||||
AllNodes.push_back(N);
|
||||
return SDOperand(N, 0);
|
||||
@@ -3479,6 +3510,7 @@ void JumpTableSDNode::ANCHOR() {}
|
||||
void ConstantPoolSDNode::ANCHOR() {}
|
||||
void BasicBlockSDNode::ANCHOR() {}
|
||||
void SrcValueSDNode::ANCHOR() {}
|
||||
void MemOperandSDNode::ANCHOR() {}
|
||||
void RegisterSDNode::ANCHOR() {}
|
||||
void ExternalSymbolSDNode::ANCHOR() {}
|
||||
void CondCodeSDNode::ANCHOR() {}
|
||||
@@ -3503,6 +3535,26 @@ GlobalAddressSDNode::GlobalAddressSDNode(bool isTarget, const GlobalValue *GA,
|
||||
TheGlobal = const_cast<GlobalValue*>(GA);
|
||||
}
|
||||
|
||||
/// getMemOperand - Return a MemOperand object describing the memory
|
||||
/// reference performed by this load or store.
|
||||
MemOperand LSBaseSDNode::getMemOperand() const {
|
||||
int Size = (MVT::getSizeInBits(getMemoryVT()) + 7) >> 3;
|
||||
int Flags =
|
||||
getOpcode() == ISD::LOAD ? MemOperand::MOLoad : MemOperand::MOStore;
|
||||
if (IsVolatile) Flags |= MemOperand::MOVolatile;
|
||||
|
||||
// Check if the load references a frame index, and does not have
|
||||
// an SV attached.
|
||||
const FrameIndexSDNode *FI =
|
||||
dyn_cast<const FrameIndexSDNode>(getBasePtr().Val);
|
||||
if (!getSrcValue() && FI)
|
||||
return MemOperand(&PseudoSourceValue::getFixedStack(), Flags,
|
||||
FI->getIndex(), Size, Alignment);
|
||||
else
|
||||
return MemOperand(getSrcValue(), Flags,
|
||||
getSrcValueOffset(), Size, Alignment);
|
||||
}
|
||||
|
||||
/// Profile - Gather unique data for the node.
|
||||
///
|
||||
void SDNode::Profile(FoldingSetNodeID &ID) {
|
||||
@@ -3695,6 +3747,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
|
||||
case ISD::PCMARKER: return "PCMarker";
|
||||
case ISD::READCYCLECOUNTER: return "ReadCycleCounter";
|
||||
case ISD::SRCVALUE: return "SrcValue";
|
||||
case ISD::MEMOPERAND: return "MemOperand";
|
||||
case ISD::EntryToken: return "EntryToken";
|
||||
case ISD::TokenFactor: return "TokenFactor";
|
||||
case ISD::AssertSext: return "AssertSext";
|
||||
@@ -4000,9 +4053,14 @@ void SDNode::dump(const SelectionDAG *G) const {
|
||||
cerr << "'" << ES->getSymbol() << "'";
|
||||
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
|
||||
if (M->getValue())
|
||||
cerr << "<" << M->getValue() << ":" << M->getOffset() << ">";
|
||||
cerr << "<" << M->getValue() << ">";
|
||||
else
|
||||
cerr << "<null:" << M->getOffset() << ">";
|
||||
cerr << "<null>";
|
||||
} else if (const MemOperandSDNode *M = dyn_cast<MemOperandSDNode>(this)) {
|
||||
if (M->MO.getValue())
|
||||
cerr << "<" << M->MO.getValue() << ":" << M->MO.getOffset() << ">";
|
||||
else
|
||||
cerr << "<null:" << M->MO.getOffset() << ">";
|
||||
} else if (const VTSDNode *N = dyn_cast<VTSDNode>(this)) {
|
||||
cerr << ":" << MVT::getValueTypeString(N->getVT());
|
||||
} else if (const LoadSDNode *LD = dyn_cast<LoadSDNode>(this)) {
|
||||
|
Reference in New Issue
Block a user