mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
allow setting target operand flags on TargetGlobalAddress nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74203 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
304f6a48b1
commit
2a4ed82ce2
@ -278,10 +278,12 @@ public:
|
|||||||
return getConstantFP(Val, VT, true);
|
return getConstantFP(Val, VT, true);
|
||||||
}
|
}
|
||||||
SDValue getGlobalAddress(const GlobalValue *GV, MVT VT,
|
SDValue getGlobalAddress(const GlobalValue *GV, MVT VT,
|
||||||
int64_t offset = 0, bool isTargetGA = false);
|
int64_t offset = 0, bool isTargetGA = false,
|
||||||
|
unsigned char TargetFlags = 0);
|
||||||
SDValue getTargetGlobalAddress(const GlobalValue *GV, MVT VT,
|
SDValue getTargetGlobalAddress(const GlobalValue *GV, MVT VT,
|
||||||
int64_t offset = 0) {
|
int64_t offset = 0,
|
||||||
return getGlobalAddress(GV, VT, offset, true);
|
unsigned char TargetFlags = 0) {
|
||||||
|
return getGlobalAddress(GV, VT, offset, true, TargetFlags);
|
||||||
}
|
}
|
||||||
SDValue getFrameIndex(int FI, MVT VT, bool isTarget = false);
|
SDValue getFrameIndex(int FI, MVT VT, bool isTarget = false);
|
||||||
SDValue getTargetFrameIndex(int FI, MVT VT) {
|
SDValue getTargetFrameIndex(int FI, MVT VT) {
|
||||||
|
@ -1819,13 +1819,15 @@ public:
|
|||||||
class GlobalAddressSDNode : public SDNode {
|
class GlobalAddressSDNode : public SDNode {
|
||||||
GlobalValue *TheGlobal;
|
GlobalValue *TheGlobal;
|
||||||
int64_t Offset;
|
int64_t Offset;
|
||||||
|
unsigned char TargetFlags;
|
||||||
friend class SelectionDAG;
|
friend class SelectionDAG;
|
||||||
GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
|
GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
|
||||||
int64_t o = 0);
|
int64_t o, unsigned char TargetFlags);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GlobalValue *getGlobal() const { return TheGlobal; }
|
GlobalValue *getGlobal() const { return TheGlobal; }
|
||||||
int64_t getOffset() const { return Offset; }
|
int64_t getOffset() const { return Offset; }
|
||||||
|
unsigned char getTargetFlags() const { return TargetFlags; }
|
||||||
// Return the address space this GlobalAddress belongs to.
|
// Return the address space this GlobalAddress belongs to.
|
||||||
unsigned getAddressSpace() const;
|
unsigned getAddressSpace() const;
|
||||||
|
|
||||||
|
@ -361,6 +361,9 @@ static void AddNodeIDNode(FoldingSetNodeID &ID,
|
|||||||
/// the NodeID data.
|
/// the NodeID data.
|
||||||
static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
|
static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
|
||||||
switch (N->getOpcode()) {
|
switch (N->getOpcode()) {
|
||||||
|
case ISD::TargetExternalSymbol:
|
||||||
|
case ISD::ExternalSymbol:
|
||||||
|
assert(0 && "Should only be used on nodes with operands");
|
||||||
default: break; // Normal nodes don't need extra info.
|
default: break; // Normal nodes don't need extra info.
|
||||||
case ISD::ARG_FLAGS:
|
case ISD::ARG_FLAGS:
|
||||||
ID.AddInteger(cast<ARG_FLAGSSDNode>(N)->getArgFlags().getRawBits());
|
ID.AddInteger(cast<ARG_FLAGSSDNode>(N)->getArgFlags().getRawBits());
|
||||||
@ -381,6 +384,7 @@ static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
|
|||||||
const GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N);
|
const GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N);
|
||||||
ID.AddPointer(GA->getGlobal());
|
ID.AddPointer(GA->getGlobal());
|
||||||
ID.AddInteger(GA->getOffset());
|
ID.AddInteger(GA->getOffset());
|
||||||
|
ID.AddInteger(GA->getTargetFlags());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::BasicBlock:
|
case ISD::BasicBlock:
|
||||||
@ -958,8 +962,10 @@ SDValue SelectionDAG::getConstantFP(double Val, MVT VT, bool isTarget) {
|
|||||||
|
|
||||||
SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV,
|
SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV,
|
||||||
MVT VT, int64_t Offset,
|
MVT VT, int64_t Offset,
|
||||||
bool isTargetGA) {
|
bool isTargetGA,
|
||||||
unsigned Opc;
|
unsigned char TargetFlags) {
|
||||||
|
assert((TargetFlags == 0 || isTargetGA) &&
|
||||||
|
"Cannot set target flags on target-independent globals");
|
||||||
|
|
||||||
// Truncate (with sign-extension) the offset value to the pointer size.
|
// Truncate (with sign-extension) the offset value to the pointer size.
|
||||||
unsigned BitWidth = TLI.getPointerTy().getSizeInBits();
|
unsigned BitWidth = TLI.getPointerTy().getSizeInBits();
|
||||||
@ -973,6 +979,7 @@ SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV,
|
|||||||
GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false));
|
GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Opc;
|
||||||
if (GVar && GVar->isThreadLocal())
|
if (GVar && GVar->isThreadLocal())
|
||||||
Opc = isTargetGA ? ISD::TargetGlobalTLSAddress : ISD::GlobalTLSAddress;
|
Opc = isTargetGA ? ISD::TargetGlobalTLSAddress : ISD::GlobalTLSAddress;
|
||||||
else
|
else
|
||||||
@ -982,11 +989,12 @@ SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV,
|
|||||||
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0);
|
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0);
|
||||||
ID.AddPointer(GV);
|
ID.AddPointer(GV);
|
||||||
ID.AddInteger(Offset);
|
ID.AddInteger(Offset);
|
||||||
|
ID.AddInteger(TargetFlags);
|
||||||
void *IP = 0;
|
void *IP = 0;
|
||||||
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
|
||||||
return SDValue(E, 0);
|
return SDValue(E, 0);
|
||||||
SDNode *N = NodeAllocator.Allocate<GlobalAddressSDNode>();
|
SDNode *N = NodeAllocator.Allocate<GlobalAddressSDNode>();
|
||||||
new (N) GlobalAddressSDNode(isTargetGA, GV, VT, Offset);
|
new (N) GlobalAddressSDNode(isTargetGA, GV, VT, Offset, TargetFlags);
|
||||||
CSEMap.InsertNode(N, IP);
|
CSEMap.InsertNode(N, IP);
|
||||||
AllNodes.push_back(N);
|
AllNodes.push_back(N);
|
||||||
return SDValue(N, 0);
|
return SDValue(N, 0);
|
||||||
@ -4914,14 +4922,15 @@ HandleSDNode::~HandleSDNode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlobalAddressSDNode::GlobalAddressSDNode(bool isTarget, const GlobalValue *GA,
|
GlobalAddressSDNode::GlobalAddressSDNode(bool isTarget, const GlobalValue *GA,
|
||||||
MVT VT, int64_t o)
|
MVT VT, int64_t o, unsigned char TF)
|
||||||
: SDNode(isa<GlobalVariable>(GA) &&
|
: SDNode(isa<GlobalVariable>(GA) &&
|
||||||
cast<GlobalVariable>(GA)->isThreadLocal() ?
|
cast<GlobalVariable>(GA)->isThreadLocal() ?
|
||||||
// Thread Local
|
// Thread Local
|
||||||
(isTarget ? ISD::TargetGlobalTLSAddress : ISD::GlobalTLSAddress) :
|
(isTarget ? ISD::TargetGlobalTLSAddress : ISD::GlobalTLSAddress) :
|
||||||
// Non Thread Local
|
// Non Thread Local
|
||||||
(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress),
|
(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress),
|
||||||
DebugLoc::getUnknownLoc(), getSDVTList(VT)), Offset(o) {
|
DebugLoc::getUnknownLoc(), getSDVTList(VT)),
|
||||||
|
Offset(o), TargetFlags(TF) {
|
||||||
TheGlobal = const_cast<GlobalValue*>(GA);
|
TheGlobal = const_cast<GlobalValue*>(GA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5487,6 +5496,8 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
|
|||||||
OS << " + " << offset;
|
OS << " + " << offset;
|
||||||
else
|
else
|
||||||
OS << " " << offset;
|
OS << " " << offset;
|
||||||
|
if (unsigned char TF = GADN->getTargetFlags())
|
||||||
|
OS << " [TF=" << TF << ']';
|
||||||
} else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) {
|
} else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) {
|
||||||
OS << "<" << FIDN->getIndex() << ">";
|
OS << "<" << FIDN->getIndex() << ">";
|
||||||
} else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(this)) {
|
} else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(this)) {
|
||||||
@ -5517,6 +5528,8 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
|
|||||||
} else if (const ExternalSymbolSDNode *ES =
|
} else if (const ExternalSymbolSDNode *ES =
|
||||||
dyn_cast<ExternalSymbolSDNode>(this)) {
|
dyn_cast<ExternalSymbolSDNode>(this)) {
|
||||||
OS << "'" << ES->getSymbol() << "'";
|
OS << "'" << ES->getSymbol() << "'";
|
||||||
|
if (unsigned char TF = GADN->getTargetFlags())
|
||||||
|
OS << " [TF=" << TF << ']';
|
||||||
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
|
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
|
||||||
if (M->getValue())
|
if (M->getValue())
|
||||||
OS << "<" << M->getValue() << ">";
|
OS << "<" << M->getValue() << ">";
|
||||||
|
Loading…
Reference in New Issue
Block a user