int offset = 0);
SDOperand getFrameIndex(int FI, MVT::ValueType VT);
SDOperand getTargetFrameIndex(int FI, MVT::ValueType VT);
+ SDOperand getJumpTable(int JTI, MVT::ValueType VT);
+ SDOperand getTargetJumpTable(int JTI, MVT::ValueType VT);
SDOperand getConstantPool(Constant *C, MVT::ValueType VT,
- unsigned Alignment=0);
+ unsigned Alignment=0, int offset = 0);
SDOperand getTargetConstantPool(Constant *C, MVT::ValueType VT,
- unsigned Alignment=0);
+ unsigned Alignment=0, int offset = 0);
SDOperand getBasicBlock(MachineBasicBlock *MBB);
SDOperand getExternalSymbol(const char *Sym, MVT::ValueType VT);
SDOperand getTargetExternalSymbol(const char *Sym, MVT::ValueType VT);
/// getZeroExtendInReg - Return the expression required to zero extend the Op
/// value assuming it was the smaller SrcTy value.
SDOperand getZeroExtendInReg(SDOperand Op, MVT::ValueType SrcTy);
+
+ /// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have
+ /// a flag result (to ensure it's not CSE'd).
+ SDOperand getCALLSEQ_START(SDOperand Chain, SDOperand Op) {
+ std::vector<MVT::ValueType> ResultTys;
+ ResultTys.push_back(MVT::Other);
+ ResultTys.push_back(MVT::Flag);
+ std::vector<SDOperand> Ops;
+ Ops.push_back(Chain);
+ Ops.push_back(Op);
+ return getNode(ISD::CALLSEQ_START, ResultTys, Ops);
+ }
/// getNode - Gets or creates the specified node.
///
MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
SDOperand Op3, SDOperand Op4, SDOperand Op5);
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT) {
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1) {
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2) {
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2, SDOperand Op3) {
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2, SDOperand Op3,
- SDOperand Op4) {
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3, Op4);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2, SDOperand Op3,
- SDOperand Op4, SDOperand Op5) {
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Op1, Op2, Op3, Op4, Op5);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2, SDOperand Op3,
- SDOperand Op4, SDOperand Op5, SDOperand Op6) {
- std::vector<SDOperand> Ops;
- Ops.reserve(6);
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- Ops.push_back(Op6);
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2, SDOperand Op3,
- SDOperand Op4, SDOperand Op5, SDOperand Op6,
- SDOperand Op7) {
- std::vector<SDOperand> Ops;
- Ops.reserve(7);
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- Ops.push_back(Op6);
- Ops.push_back(Op7);
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- SDOperand Op1, SDOperand Op2, SDOperand Op3,
- SDOperand Op4, SDOperand Op5, SDOperand Op6,
- SDOperand Op7, SDOperand Op8) {
- std::vector<SDOperand> Ops;
- Ops.reserve(8);
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- Ops.push_back(Op6);
- Ops.push_back(Op7);
- Ops.push_back(Op8);
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT,
- std::vector<SDOperand> &Ops) {
- return getNode(ISD::BUILTIN_OP_END+Opcode, VT, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
- SDOperand Op3) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
- SDOperand Op3, SDOperand Op4) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
- SDOperand Op3, SDOperand Op4, SDOperand Op5) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
- SDOperand Op3, SDOperand Op4, SDOperand Op5,
- SDOperand Op6) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- Ops.push_back(Op6);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
- SDOperand Op3, SDOperand Op4, SDOperand Op5,
- SDOperand Op6, SDOperand Op7) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- Ops.push_back(Op6);
- Ops.push_back(Op7);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
- SDOperand Op1, SDOperand Op2) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- ResultTys.push_back(VT3);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
- SDOperand Op1, SDOperand Op2,
- SDOperand Op3, SDOperand Op4, SDOperand Op5) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- ResultTys.push_back(VT3);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
- SDOperand Op1, SDOperand Op2,
- SDOperand Op3, SDOperand Op4, SDOperand Op5,
- SDOperand Op6) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- ResultTys.push_back(VT3);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- Ops.push_back(Op6);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, MVT::ValueType VT3,
- SDOperand Op1, SDOperand Op2,
- SDOperand Op3, SDOperand Op4, SDOperand Op5,
- SDOperand Op6, SDOperand Op7) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- ResultTys.push_back(VT3);
- std::vector<SDOperand> Ops;
- Ops.push_back(Op1);
- Ops.push_back(Op2);
- Ops.push_back(Op3);
- Ops.push_back(Op4);
- Ops.push_back(Op5);
- Ops.push_back(Op6);
- Ops.push_back(Op7);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
- SDOperand getTargetNode(unsigned Opcode, MVT::ValueType VT1,
- MVT::ValueType VT2, std::vector<SDOperand> &Ops) {
- std::vector<MVT::ValueType> ResultTys;
- ResultTys.push_back(VT1);
- ResultTys.push_back(VT2);
- return getNode(ISD::BUILTIN_OP_END+Opcode, ResultTys, Ops);
- }
+ /// getTargetNode - These are used for target selectors to create a new node
+ /// with specified return type(s), target opcode, and operands.
+ ///
+ /// Note that getTargetNode returns the resultant node. If there is already a
+ /// node of the specified opcode and operands, it returns that node instead of
+ /// the current one.
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1, SDOperand Op2);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3,
+ SDOperand Op4);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3,
+ SDOperand Op4, SDOperand Op5);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3,
+ SDOperand Op4, SDOperand Op5, SDOperand Op6);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3,
+ SDOperand Op4, SDOperand Op5, SDOperand Op6,
+ SDOperand Op7);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ SDOperand Op1, SDOperand Op2, SDOperand Op3,
+ SDOperand Op4, SDOperand Op5, SDOperand Op6,
+ SDOperand Op7, SDOperand Op8);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
+ std::vector<SDOperand> &Ops);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, SDOperand Op1);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
+ SDOperand Op3);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
+ SDOperand Op3, SDOperand Op4);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
+ SDOperand Op3, SDOperand Op4, SDOperand Op5);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
+ SDOperand Op3, SDOperand Op4, SDOperand Op5,
+ SDOperand Op6);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
+ SDOperand Op3, SDOperand Op4, SDOperand Op5,
+ SDOperand Op6, SDOperand Op7);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, MVT::ValueType VT3,
+ SDOperand Op1, SDOperand Op2);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, MVT::ValueType VT3,
+ SDOperand Op1, SDOperand Op2,
+ SDOperand Op3, SDOperand Op4, SDOperand Op5);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, MVT::ValueType VT3,
+ SDOperand Op1, SDOperand Op2,
+ SDOperand Op3, SDOperand Op4, SDOperand Op5,
+ SDOperand Op6);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, MVT::ValueType VT3,
+ SDOperand Op1, SDOperand Op2,
+ SDOperand Op3, SDOperand Op4, SDOperand Op5,
+ SDOperand Op6, SDOperand Op7);
+ SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
+ MVT::ValueType VT2, std::vector<SDOperand> &Ops);
/// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead.
/// This can cause recursive merging of nodes in the DAG. Use the first
std::vector<SDNode*> *Deleted = 0);
void ReplaceAllUsesWith(SDNode *From, const std::vector<SDOperand> &To,
std::vector<SDNode*> *Deleted = 0);
-
-
+
+ /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving
+ /// uses of other values produced by From.Val alone. The Deleted vector is
+ /// handled the same was as for ReplaceAllUsesWith, but it is required for
+ /// this method.
+ void ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To,
+ std::vector<SDNode*> &Deleted);
+
/// DeleteNode - Remove the specified node from the system. This node must
/// have no referrers.
void DeleteNode(SDNode *N);
void dump() const;
+ /// InsertISelMapEntry - A helper function to insert a key / element pair
+ /// into a SDOperand to SDOperand map. This is added to avoid the map
+ /// insertion operator from being inlined.
+ static void InsertISelMapEntry(std::map<SDOperand, SDOperand> &Map,
+ SDNode *Key, unsigned KeyResNo,
+ SDNode *Element, unsigned ElementResNo);
+
private:
void RemoveNodeFromCSEMaps(SDNode *N);
SDNode *AddNonLeafNodeToCSEMaps(SDNode *N);
std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> TargetConstants;
std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> ConstantFPs;
std::map<std::pair<uint64_t, MVT::ValueType>, SDNode*> TargetConstantFPs;
- std::map<int, SDNode*> FrameIndices, TargetFrameIndices;
- std::map<std::pair<Constant *, unsigned>, SDNode*> ConstantPoolIndices;
- std::map<std::pair<Constant *, unsigned>, SDNode*> TargetConstantPoolIndices;
+ std::map<int, SDNode*> FrameIndices, TargetFrameIndices, JumpTableIndices,
+ TargetJumpTableIndices;
+ std::map<std::pair<Constant *,
+ std::pair<int, unsigned> >, SDNode*> ConstantPoolIndices;
+ std::map<std::pair<Constant *,
+ std::pair<int, unsigned> >, SDNode*> TargetConstantPoolIndices;
std::map<MachineBasicBlock *, SDNode*> BBNodes;
std::vector<SDNode*> ValueTypeNodes;
std::map<std::string, SDNode*> ExternalSymbols;