mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-02 22:32:08 +00:00
Track IR ordering of SelectionDAG nodes 1/4.
Use a field in the SelectionDAGNode object to track its IR ordering. This adds fields and utility classes without changing existing interfaces or functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182701 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ba3500e4d2
commit
ea5db0c315
@ -344,6 +344,13 @@ private:
|
|||||||
/// debugLoc - source line information.
|
/// debugLoc - source line information.
|
||||||
DebugLoc debugLoc;
|
DebugLoc debugLoc;
|
||||||
|
|
||||||
|
// The ordering of the SDNodes. It roughly corresponds to the ordering of the
|
||||||
|
// original LLVM instructions.
|
||||||
|
// This is used for turning off scheduling, because we'll forgo
|
||||||
|
// the normal scheduling algorithms and output the instructions according to
|
||||||
|
// this ordering.
|
||||||
|
unsigned IROrder;
|
||||||
|
|
||||||
/// getValueTypeList - Return a pointer to the specified value type.
|
/// getValueTypeList - Return a pointer to the specified value type.
|
||||||
static const EVT *getValueTypeList(EVT VT);
|
static const EVT *getValueTypeList(EVT VT);
|
||||||
|
|
||||||
@ -412,6 +419,14 @@ public:
|
|||||||
/// setNodeId - Set unique node id.
|
/// setNodeId - Set unique node id.
|
||||||
void setNodeId(int Id) { NodeId = Id; }
|
void setNodeId(int Id) { NodeId = Id; }
|
||||||
|
|
||||||
|
/// getIROrder - Return the node ordering.
|
||||||
|
///
|
||||||
|
unsigned getIROrder() const { return IROrder; }
|
||||||
|
|
||||||
|
/// setIROrder - Set the node ordering.
|
||||||
|
///
|
||||||
|
void setIROrder(unsigned Order) { IROrder = Order; }
|
||||||
|
|
||||||
/// getDebugLoc - Return the source location info.
|
/// getDebugLoc - Return the source location info.
|
||||||
const DebugLoc getDebugLoc() const { return debugLoc; }
|
const DebugLoc getDebugLoc() const { return debugLoc; }
|
||||||
|
|
||||||
@ -770,6 +785,53 @@ protected:
|
|||||||
void DropOperands();
|
void DropOperands();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Wrapper class for IR location info (IR ordering and DebugLoc) to be passed
|
||||||
|
/// into SDNode creation functions.
|
||||||
|
/// When an SDNode is created from the DAGBuilder, the DebugLoc is extracted
|
||||||
|
/// from the original Instruction, and IROrder is the ordinal position of
|
||||||
|
/// the instruction.
|
||||||
|
/// When an SDNode is created after the DAG is being built, both DebugLoc and
|
||||||
|
/// the IROrder are propagated from the original SDNode.
|
||||||
|
/// So SDLoc class provides two constructors besides the default one, one to
|
||||||
|
/// be used by the DAGBuilder, the other to be used by others.
|
||||||
|
class SDLoc {
|
||||||
|
private:
|
||||||
|
// Ptr could be used for either Instruction* or SDNode*. It is used for
|
||||||
|
// Instruction* if IROrder is not -1.
|
||||||
|
const void *Ptr;
|
||||||
|
int IROrder;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SDLoc() : Ptr(NULL), IROrder(0) {}
|
||||||
|
SDLoc(const SDNode *N) : Ptr(N), IROrder(-1) {
|
||||||
|
assert(N && "null SDNode");
|
||||||
|
}
|
||||||
|
SDLoc(const SDValue V) : Ptr(V.getNode()), IROrder(-1) {
|
||||||
|
assert(Ptr && "null SDNode");
|
||||||
|
}
|
||||||
|
SDLoc(const Instruction *I, int Order) : Ptr(I), IROrder(Order) {
|
||||||
|
assert(Order >= 0 && "bad IROrder");
|
||||||
|
}
|
||||||
|
unsigned getIROrder() {
|
||||||
|
if (IROrder >= 0 || Ptr == NULL) {
|
||||||
|
return (unsigned)IROrder;
|
||||||
|
}
|
||||||
|
const SDNode *N = (const SDNode*)(Ptr);
|
||||||
|
return N->getIROrder();
|
||||||
|
}
|
||||||
|
DebugLoc getDebugLoc() {
|
||||||
|
if (Ptr == NULL) {
|
||||||
|
return DebugLoc();
|
||||||
|
}
|
||||||
|
if (IROrder >= 0) {
|
||||||
|
const Instruction *I = (const Instruction*)(Ptr);
|
||||||
|
return I->getDebugLoc();
|
||||||
|
}
|
||||||
|
const SDNode *N = (const SDNode*)(Ptr);
|
||||||
|
return N->getDebugLoc();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Define inline functions from the SDValue class.
|
// Define inline functions from the SDValue class.
|
||||||
|
|
||||||
|
@ -869,7 +869,7 @@ void SelectionDAGBuilder::clear() {
|
|||||||
UnusedArgNodeMap.clear();
|
UnusedArgNodeMap.clear();
|
||||||
PendingLoads.clear();
|
PendingLoads.clear();
|
||||||
PendingExports.clear();
|
PendingExports.clear();
|
||||||
CurDebugLoc = DebugLoc();
|
CurInst = NULL;
|
||||||
HasTailCall = false;
|
HasTailCall = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,14 +951,14 @@ void SelectionDAGBuilder::visit(const Instruction &I) {
|
|||||||
if (isa<TerminatorInst>(&I))
|
if (isa<TerminatorInst>(&I))
|
||||||
HandlePHINodesInSuccessorBlocks(I.getParent());
|
HandlePHINodesInSuccessorBlocks(I.getParent());
|
||||||
|
|
||||||
CurDebugLoc = I.getDebugLoc();
|
CurInst = &I;
|
||||||
|
|
||||||
visit(I.getOpcode(), I);
|
visit(I.getOpcode(), I);
|
||||||
|
|
||||||
if (!isa<TerminatorInst>(&I) && !HasTailCall)
|
if (!isa<TerminatorInst>(&I) && !HasTailCall)
|
||||||
CopyToExportRegsIfNeeded(&I);
|
CopyToExportRegsIfNeeded(&I);
|
||||||
|
|
||||||
CurDebugLoc = DebugLoc();
|
CurInst = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionDAGBuilder::visitPHI(const PHINode &) {
|
void SelectionDAGBuilder::visitPHI(const PHINode &) {
|
||||||
|
@ -80,8 +80,8 @@ class ZExtInst;
|
|||||||
/// implementation that is parameterized by a TargetLowering object.
|
/// implementation that is parameterized by a TargetLowering object.
|
||||||
///
|
///
|
||||||
class SelectionDAGBuilder {
|
class SelectionDAGBuilder {
|
||||||
/// CurDebugLoc - current file + line number. Changes as we build the DAG.
|
/// CurInst - The current instruction being visited
|
||||||
DebugLoc CurDebugLoc;
|
const Instruction *CurInst;
|
||||||
|
|
||||||
DenseMap<const Value*, SDValue> NodeMap;
|
DenseMap<const Value*, SDValue> NodeMap;
|
||||||
|
|
||||||
@ -327,7 +327,8 @@ public:
|
|||||||
|
|
||||||
SelectionDAGBuilder(SelectionDAG &dag, FunctionLoweringInfo &funcinfo,
|
SelectionDAGBuilder(SelectionDAG &dag, FunctionLoweringInfo &funcinfo,
|
||||||
CodeGenOpt::Level ol)
|
CodeGenOpt::Level ol)
|
||||||
: SDNodeOrder(0), TM(dag.getTarget()), TLI(dag.getTargetLoweringInfo()),
|
: CurInst(NULL), SDNodeOrder(0), TM(dag.getTarget()),
|
||||||
|
TLI(dag.getTargetLoweringInfo()),
|
||||||
DAG(dag), FuncInfo(funcinfo), OptLevel(ol),
|
DAG(dag), FuncInfo(funcinfo), OptLevel(ol),
|
||||||
HasTailCall(false) {
|
HasTailCall(false) {
|
||||||
}
|
}
|
||||||
@ -364,7 +365,14 @@ public:
|
|||||||
///
|
///
|
||||||
SDValue getControlRoot();
|
SDValue getControlRoot();
|
||||||
|
|
||||||
DebugLoc getCurDebugLoc() const { return CurDebugLoc; }
|
SDLoc getCurSDLoc() const {
|
||||||
|
assert(CurInst && "CurInst NULL");
|
||||||
|
return SDLoc(CurInst, SDNodeOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugLoc getCurDebugLoc() const {
|
||||||
|
return CurInst ? CurInst->getDebugLoc() : DebugLoc();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned getSDNodeOrder() const { return SDNodeOrder; }
|
unsigned getSDNodeOrder() const { return SDNodeOrder; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user