aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r--include/llvm/CodeGen/DAGISelHeader.h11
-rw-r--r--include/llvm/CodeGen/SelectionDAG.h39
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h46
3 files changed, 76 insertions, 20 deletions
diff --git a/include/llvm/CodeGen/DAGISelHeader.h b/include/llvm/CodeGen/DAGISelHeader.h
index f1774bf..79f6276 100644
--- a/include/llvm/CodeGen/DAGISelHeader.h
+++ b/include/llvm/CodeGen/DAGISelHeader.h
@@ -124,6 +124,17 @@ void ReplaceUses(SDOperand F, SDOperand T) DISABLE_INLINE {
UpdateQueue(ISQU);
}
+/// ReplaceUses - replace all uses of the old nodes F with the use
+/// of the new nodes T.
+void ReplaceUses(const SDOperand *F, const SDOperand *T,
+ unsigned Num) DISABLE_INLINE {
+ ISelQueueUpdater ISQU(ISelQueue);
+ CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num, &ISQU);
+ for (unsigned i = 0; i != Num; ++i)
+ setSelected(F[i].Val->getNodeId());
+ UpdateQueue(ISQU);
+}
+
/// ReplaceUses - replace all uses of the old node F with the use
/// of the new node T.
void ReplaceUses(SDNode *F, SDNode *T) DISABLE_INLINE {
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 636e36d..f530f33 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -60,6 +60,10 @@ class SelectionDAG {
/// CSE with existing nodes with a duplicate is requested.
FoldingSet<SDNode> CSEMap;
+ /// Allocator - Pool allocation for misc. objects that are created once per
+ /// SelectionDAG.
+ BumpPtrAllocator Allocator;
+
public:
SelectionDAG(TargetLowering &tli, MachineFunction &mf,
FunctionLoweringInfo &fli, MachineModuleInfo *mmi,
@@ -457,8 +461,7 @@ public:
/// SelectNodeTo - These are used for target selectors to *mutate* the
/// specified node to have the specified return type, Target opcode, and
/// operands. Note that target opcodes are stored as
- /// ISD::BUILTIN_OP_END+TargetOpcode in the node opcode field. The 0th value
- /// of the resultant node is returned.
+ /// ~TargetOpcode in the node opcode field. The resultant node is returned.
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT);
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, SDOperand Op1);
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT,
@@ -481,6 +484,29 @@ public:
SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs,
const SDOperand *Ops, unsigned NumOps);
+ /// MorphNodeTo - These *mutate* the specified node to have the specified
+ /// return type, opcode, and operands.
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, SDOperand Op1);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT,
+ SDOperand Op1, SDOperand Op2);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT,
+ const SDOperand *Ops, unsigned NumOps);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, MVT VT2);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
+ MVT VT2, const SDOperand *Ops, unsigned NumOps);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
+ MVT VT2, MVT VT3, const SDOperand *Ops, unsigned NumOps);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
+ MVT VT2, SDOperand Op1);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
+ MVT VT2, SDOperand Op1, SDOperand Op2);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1,
+ MVT VT2, SDOperand Op1, SDOperand Op2, SDOperand Op3);
+ SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
+ const SDOperand *Ops, unsigned NumOps);
/// getTargetNode - These are used for target selectors to create a new node
/// with specified return type(s), target opcode, and operands.
@@ -565,6 +591,13 @@ public:
void ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To,
DAGUpdateListener *UpdateListener = 0);
+ /// ReplaceAllUsesOfValuesWith - Like ReplaceAllUsesOfValueWith, but
+ /// for multiple values at once. This correctly handles the case where
+ /// there is an overlap between the From values and the To values.
+ void ReplaceAllUsesOfValuesWith(const SDOperand *From, const SDOperand *To,
+ unsigned Num,
+ DAGUpdateListener *UpdateListener = 0);
+
/// AssignTopologicalOrder - Assign a unique node id for each node in the DAG
/// based on their topological order. It returns the maximum id and a vector
/// of the SDNodes* in assigned order by reference.
@@ -654,7 +687,7 @@ private:
unsigned getMVTAlignment(MVT MemoryVT) const;
// List of non-single value types.
- std::list<std::vector<MVT> > VTList;
+ std::vector<SDVTList> VTList;
// Maps to auto-CSE operations.
std::vector<CondCodeSDNode*> CondCodeNodes;
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index d1363e9..78897cb 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -846,7 +846,8 @@ public:
inline const SDOperand &getOperand(unsigned i) const;
inline uint64_t getConstantOperandVal(unsigned i) const;
inline bool isTargetOpcode() const;
- inline unsigned getTargetOpcode() const;
+ inline bool isMachineOpcode() const;
+ inline unsigned getMachineOpcode() const;
/// reachesChainWithoutSideEffects - Return true if this operand (which must
@@ -1028,7 +1029,7 @@ class SDNode : public FoldingSetNode {
private:
/// NodeType - The operation that this node performs.
///
- unsigned short NodeType;
+ short NodeType;
/// OperandsNeedDelete - This is true if OperandList was new[]'d. If true,
/// then they will be delete[]'d when the node is destroyed.
@@ -1072,11 +1073,27 @@ public:
//===--------------------------------------------------------------------===//
// Accessors
//
- unsigned getOpcode() const { return NodeType; }
+
+ /// getOpcode - Return the SelectionDAG opcode value for this node. For
+ /// pre-isel nodes (those for which isMachineOpcode returns false), these
+ /// are the opcode values in the ISD and <target>ISD namespaces. For
+ /// post-isel opcodes, see getMachineOpcode.
+ unsigned getOpcode() const { return (unsigned short)NodeType; }
+
+ /// isTargetOpcode - Test if this node has a target-specific opcode (in the
+ /// <target>ISD namespace).
bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
- unsigned getTargetOpcode() const {
- assert(isTargetOpcode() && "Not a target opcode!");
- return NodeType - ISD::BUILTIN_OP_END;
+
+ /// isMachineOpcode - Test if this node has a post-isel opcode, directly
+ /// corresponding to a MachineInstr opcode.
+ bool isMachineOpcode() const { return NodeType < 0; }
+
+ /// getMachineOpcode - This may only be called if isMachineOpcode returns
+ /// true. It returns the MachineInstr opcode value that the node's opcode
+ /// corresponds to.
+ unsigned getMachineOpcode() const {
+ assert(isMachineOpcode() && "Not a target opcode!");
+ return ~NodeType;
}
size_t use_size() const { return std::distance(use_begin(), use_end()); }
@@ -1314,17 +1331,9 @@ protected:
}
/// DropOperands - Release the operands and set this node to have
- /// zero operands. This should only be used by HandleSDNode to clear
- /// its operand list.
+ /// zero operands.
void DropOperands();
- /// MorphNodeTo - This frees the operands of the current node, resets the
- /// opcode, types, and operands to the specified value. This should only be
- /// used by the SelectionDAG class.
- void MorphNodeTo(unsigned Opc, SDVTList L,
- const SDOperand *Ops, unsigned NumOps,
- SmallVectorImpl<SDNode *> &DeadNodes);
-
void addUser(unsigned i, SDNode *User) {
assert(User->OperandList[i].getUser() && "Node without parent");
addUse(User->OperandList[i]);
@@ -1358,8 +1367,11 @@ inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
inline bool SDOperand::isTargetOpcode() const {
return Val->isTargetOpcode();
}
-inline unsigned SDOperand::getTargetOpcode() const {
- return Val->getTargetOpcode();
+inline bool SDOperand::isMachineOpcode() const {
+ return Val->isMachineOpcode();
+}
+inline unsigned SDOperand::getMachineOpcode() const {
+ return Val->getMachineOpcode();
}
inline bool SDOperand::hasOneUse() const {
return Val->hasNUsesOfValue(1, ResNo);