[llvm-commits] [llvm] r74203 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Chris Lattner
sabre at nondot.org
Thu Jun 25 14:21:14 PDT 2009
Author: lattner
Date: Thu Jun 25 16:21:14 2009
New Revision: 74203
URL: http://llvm.org/viewvc/llvm-project?rev=74203&view=rev
Log:
allow setting target operand flags on TargetGlobalAddress nodes.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=74203&r1=74202&r2=74203&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Thu Jun 25 16:21:14 2009
@@ -278,10 +278,12 @@
return getConstantFP(Val, VT, true);
}
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,
- int64_t offset = 0) {
- return getGlobalAddress(GV, VT, offset, true);
+ int64_t offset = 0,
+ unsigned char TargetFlags = 0) {
+ return getGlobalAddress(GV, VT, offset, true, TargetFlags);
}
SDValue getFrameIndex(int FI, MVT VT, bool isTarget = false);
SDValue getTargetFrameIndex(int FI, MVT VT) {
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=74203&r1=74202&r2=74203&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Thu Jun 25 16:21:14 2009
@@ -1819,13 +1819,15 @@
class GlobalAddressSDNode : public SDNode {
GlobalValue *TheGlobal;
int64_t Offset;
+ unsigned char TargetFlags;
friend class SelectionDAG;
GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
- int64_t o = 0);
+ int64_t o, unsigned char TargetFlags);
public:
GlobalValue *getGlobal() const { return TheGlobal; }
int64_t getOffset() const { return Offset; }
+ unsigned char getTargetFlags() const { return TargetFlags; }
// Return the address space this GlobalAddress belongs to.
unsigned getAddressSpace() const;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=74203&r1=74202&r2=74203&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Jun 25 16:21:14 2009
@@ -361,6 +361,9 @@
/// the NodeID data.
static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N) {
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.
case ISD::ARG_FLAGS:
ID.AddInteger(cast<ARG_FLAGSSDNode>(N)->getArgFlags().getRawBits());
@@ -381,6 +384,7 @@
const GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N);
ID.AddPointer(GA->getGlobal());
ID.AddInteger(GA->getOffset());
+ ID.AddInteger(GA->getTargetFlags());
break;
}
case ISD::BasicBlock:
@@ -958,9 +962,11 @@
SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV,
MVT VT, int64_t Offset,
- bool isTargetGA) {
- unsigned Opc;
-
+ bool isTargetGA,
+ 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.
unsigned BitWidth = TLI.getPointerTy().getSizeInBits();
if (BitWidth < 64)
@@ -973,6 +979,7 @@
GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false));
}
+ unsigned Opc;
if (GVar && GVar->isThreadLocal())
Opc = isTargetGA ? ISD::TargetGlobalTLSAddress : ISD::GlobalTLSAddress;
else
@@ -982,11 +989,12 @@
AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0);
ID.AddPointer(GV);
ID.AddInteger(Offset);
+ ID.AddInteger(TargetFlags);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
SDNode *N = NodeAllocator.Allocate<GlobalAddressSDNode>();
- new (N) GlobalAddressSDNode(isTargetGA, GV, VT, Offset);
+ new (N) GlobalAddressSDNode(isTargetGA, GV, VT, Offset, TargetFlags);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
return SDValue(N, 0);
@@ -4914,14 +4922,15 @@
}
GlobalAddressSDNode::GlobalAddressSDNode(bool isTarget, const GlobalValue *GA,
- MVT VT, int64_t o)
+ MVT VT, int64_t o, unsigned char TF)
: SDNode(isa<GlobalVariable>(GA) &&
cast<GlobalVariable>(GA)->isThreadLocal() ?
// Thread Local
(isTarget ? ISD::TargetGlobalTLSAddress : ISD::GlobalTLSAddress) :
// Non Thread Local
(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress),
- DebugLoc::getUnknownLoc(), getSDVTList(VT)), Offset(o) {
+ DebugLoc::getUnknownLoc(), getSDVTList(VT)),
+ Offset(o), TargetFlags(TF) {
TheGlobal = const_cast<GlobalValue*>(GA);
}
@@ -5487,6 +5496,8 @@
OS << " + " << offset;
else
OS << " " << offset;
+ if (unsigned char TF = GADN->getTargetFlags())
+ OS << " [TF=" << TF << ']';
} else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) {
OS << "<" << FIDN->getIndex() << ">";
} else if (const JumpTableSDNode *JTDN = dyn_cast<JumpTableSDNode>(this)) {
@@ -5517,6 +5528,8 @@
} else if (const ExternalSymbolSDNode *ES =
dyn_cast<ExternalSymbolSDNode>(this)) {
OS << "'" << ES->getSymbol() << "'";
+ if (unsigned char TF = GADN->getTargetFlags())
+ OS << " [TF=" << TF << ']';
} else if (const SrcValueSDNode *M = dyn_cast<SrcValueSDNode>(this)) {
if (M->getValue())
OS << "<" << M->getValue() << ">";
More information about the llvm-commits
mailing list