[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h SelectionDAGNodes.h
Chris Lattner
lattner at cs.uiuc.edu
Fri Jan 14 14:08:01 PST 2005
Changes in directory llvm/include/llvm/CodeGen:
SelectionDAG.h updated: 1.11 -> 1.12
SelectionDAGNodes.h updated: 1.14 -> 1.15
---
Log message:
Start adding some new operators, give IMPLICIT_DEF a chain operand.
---
Diffs of the changes: (+110 -29)
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.11 llvm/include/llvm/CodeGen/SelectionDAG.h:1.12
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.11 Thu Jan 13 14:49:26 2005
+++ llvm/include/llvm/CodeGen/SelectionDAG.h Fri Jan 14 16:07:46 2005
@@ -44,26 +44,6 @@
// AllNodes - All of the nodes in the DAG
std::vector<SDNode*> AllNodes;
-
- // Maps to auto-CSE operations.
- std::map<std::pair<unsigned, std::pair<SDOperand, MVT::ValueType> >,
- SDNode *> UnaryOps;
- std::map<std::pair<unsigned, std::pair<SDOperand, SDOperand> >,
- SDNode *> BinaryOps;
-
- std::map<std::pair<std::pair<SDOperand, SDOperand>, ISD::CondCode>,
- SetCCSDNode*> SetCCs;
-
- std::map<std::pair<SDOperand, std::pair<SDOperand, MVT::ValueType> >,
- SDNode *> Loads;
-
- std::map<const GlobalValue*, SDNode*> GlobalValues;
- std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> Constants;
- std::map<std::pair<double, MVT::ValueType>, SDNode*> ConstantFPs;
- std::map<int, SDNode*> FrameIndices;
- std::map<unsigned, SDNode*> ConstantPoolIndices;
- std::map<MachineBasicBlock *, SDNode*> BBNodes;
- std::map<std::string, SDNode*> ExternalSymbols;
public:
SelectionDAG(const TargetMachine &tm, MachineFunction &mf) : TM(tm), MF(mf) {
EntryNode = Root = getNode(ISD::EntryToken, MVT::Other);
@@ -119,21 +99,21 @@
SDOperand getCopyToReg(SDOperand Chain, SDOperand N, unsigned Reg) {
// Note: these are auto-CSE'd because the caller doesn't make requests that
// could cause duplicates to occur.
- SDNode *NN = new RegSDNode(Chain, N, Reg);
+ SDNode *NN = new RegSDNode(ISD::CopyToReg, MVT::Other, Chain, N, Reg);
AllNodes.push_back(NN);
return SDOperand(NN, 0);
}
SDOperand getCopyFromReg(unsigned Reg, MVT::ValueType VT) {
// Note: These nodes are auto-CSE'd by the caller of this method.
- SDNode *NN = new RegSDNode(ISD::CopyFromReg, Reg, VT);
+ SDNode *NN = new RegSDNode(ISD::CopyFromReg, VT, Reg);
AllNodes.push_back(NN);
return SDOperand(NN, 0);
}
- SDOperand getImplicitDef(unsigned Reg) {
+ SDOperand getImplicitDef(SDOperand Chain, unsigned Reg) {
// Note: These nodes are auto-CSE'd by the caller of this method.
- SDNode *NN = new RegSDNode(ISD::ImplicitDef, Reg, MVT::Other);
+ SDNode *NN = new RegSDNode(ISD::ImplicitDef, MVT::Other, Chain, Reg);
AllNodes.push_back(NN);
return SDOperand(NN, 0);
}
@@ -161,6 +141,13 @@
SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
std::vector<SDOperand> &Children);
+ // getNode - These versions take an extra value type for extending and
+ // truncating loads and stores.
+ SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1,
+ SDOperand N2, MVT::ValueType EVT);
+ SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1,
+ SDOperand N2, SDOperand N3, MVT::ValueType EVT);
+
/// getLoad - Loads are not normal binary operators: their result type is not
/// determined by their operands, and they produce a value AND a token chain.
///
@@ -175,6 +162,41 @@
private:
void DeleteNodeIfDead(SDNode *N, void *NodeSet);
+
+ // Maps to auto-CSE operations.
+ std::map<std::pair<unsigned, std::pair<SDOperand, MVT::ValueType> >,
+ SDNode *> UnaryOps;
+ std::map<std::pair<unsigned, std::pair<SDOperand, SDOperand> >,
+ SDNode *> BinaryOps;
+
+ std::map<std::pair<std::pair<SDOperand, SDOperand>, ISD::CondCode>,
+ SetCCSDNode*> SetCCs;
+
+ std::map<std::pair<SDOperand, std::pair<SDOperand, MVT::ValueType> >,
+ SDNode *> Loads;
+
+ std::map<const GlobalValue*, SDNode*> GlobalValues;
+ std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> Constants;
+ std::map<std::pair<double, MVT::ValueType>, SDNode*> ConstantFPs;
+ std::map<int, SDNode*> FrameIndices;
+ std::map<unsigned, SDNode*> ConstantPoolIndices;
+ std::map<MachineBasicBlock *, SDNode*> BBNodes;
+ std::map<std::string, SDNode*> ExternalSymbols;
+ struct EVTStruct {
+ unsigned Opcode;
+ MVT::ValueType VT, EVT;
+ std::vector<SDOperand> Ops;
+ bool operator<(const EVTStruct &RHS) const {
+ if (Opcode < RHS.Opcode) return true;
+ if (Opcode > RHS.Opcode) return false;
+ if (VT < RHS.VT) return true;
+ if (VT > RHS.VT) return false;
+ if (EVT < RHS.EVT) return true;
+ if (EVT > RHS.EVT) return false;
+ return Ops < RHS.Ops;
+ }
+ };
+ std::map<EVTStruct, SDNode*> MVTSDNodes;
};
template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.14 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.15
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.14 Thu Jan 13 16:58:50 2005
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jan 14 16:07:46 2005
@@ -138,9 +138,33 @@
// FP_EXTEND - Extend a smaller FP type into a larger FP type.
FP_EXTEND,
- // Other operators. LOAD and STORE have token chains.
+ // Other operators. LOAD and STORE have token chains as their first
+ // operand, then the same operands as an LLVM load/store instruction.
LOAD, STORE,
+ // EXTLOAD, SEXTLOAD, ZEXTLOAD - These three operators are instances of the
+ // MVTSDNode. All of these load a value from memory and extend them to a
+ // larger value (e.g. load a byte into a word register). All three of these
+ // have two operands, a chain and a pointer to load from. The extra value
+ // type is the source type being loaded.
+ //
+ // SEXTLOAD loads the integer operand and sign extends it to a larger
+ // integer result type.
+ // ZEXTLOAD loads the integer operand and zero extends it to a larger
+ // integer result type.
+ // EXTLOAD is used for two things: floating point extending loads, and
+ // integer extending loads where it doesn't matter what the high
+ // bits are set to. The code generator is allowed to codegen this
+ // into whichever operation is more efficient.
+ EXTLOAD, SEXTLOAD, ZEXTLOAD,
+
+ // TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a
+ // value and stores it to memory in one operation. This can be used for
+ // either integer or floating point operands, and the stored type
+ // represented as the 'extra' value type in the MVTSDNode representing the
+ // operator. This node has the same three operands as a standard store.
+ TRUNCSTORE,
+
// DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
// to a specified boundary. The first operand is the token chain, the
// second is the number of bytes to allocate, and the third is the alignment
@@ -624,11 +648,17 @@
unsigned Reg;
protected:
friend class SelectionDAG;
- RegSDNode(SDOperand Chain, SDOperand Src, unsigned reg)
- : SDNode(ISD::CopyToReg, Chain, Src), Reg(reg) {
- setValueTypes(MVT::Other); // Just a token chain.
+ RegSDNode(unsigned Opc, MVT::ValueType VT, SDOperand Chain,
+ SDOperand Src, unsigned reg)
+ : SDNode(Opc, Chain, Src), Reg(reg) {
+ setValueTypes(VT);
+ }
+ RegSDNode(unsigned Opc, MVT::ValueType VT, SDOperand Chain,
+ unsigned reg)
+ : SDNode(Opc, Chain), Reg(reg) {
+ setValueTypes(VT);
}
- RegSDNode(unsigned Opc, unsigned reg, MVT::ValueType VT)
+ RegSDNode(unsigned Opc, MVT::ValueType VT, unsigned reg)
: SDNode(Opc, VT), Reg(reg) {
}
public:
@@ -678,6 +708,35 @@
}
};
+/// MVTSDNode - This class is used for operators that require an extra
+/// value-type to be kept with the node.
+class MVTSDNode : public SDNode {
+ MVT::ValueType ExtraValueType;
+protected:
+ friend class SelectionDAG;
+ MVTSDNode(unsigned Opc, MVT::ValueType VT,
+ SDOperand Op0, SDOperand Op1, MVT::ValueType EVT)
+ : SDNode(Opc, Op0, Op1), ExtraValueType(EVT) {
+ setValueTypes(VT);
+ }
+ MVTSDNode(unsigned Opc, MVT::ValueType VT,
+ SDOperand Op0, SDOperand Op1, SDOperand Op2, MVT::ValueType EVT)
+ : SDNode(Opc, Op0, Op1, Op2), ExtraValueType(EVT) {
+ setValueTypes(VT);
+ }
+public:
+
+ MVT::ValueType getExtraValueType() const { return ExtraValueType; }
+
+ static bool classof(const MVTSDNode *) { return true; }
+ static bool classof(const SDNode *N) {
+ return
+ N->getOpcode() == ISD::EXTLOAD ||
+ N->getOpcode() == ISD::SEXTLOAD ||
+ N->getOpcode() == ISD::ZEXTLOAD ||
+ N->getOpcode() == ISD::TRUNCSTORE;
+ }
+};
class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
SDNode *Node;
More information about the llvm-commits
mailing list