diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-01-15 06:17:04 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-01-15 06:17:04 +0000 |
| commit | 1001c6e2cd5167a68e4a4ed95cce69637c8a301a (patch) | |
| tree | b77ce287c0f751a9c653d85118030d956ed01eca /llvm/lib/CodeGen | |
| parent | 9de5890211d3fc9271bf2b9db45bf8f4d2fb28d8 (diff) | |
| download | bcm5719-llvm-1001c6e2cd5167a68e4a4ed95cce69637c8a301a.tar.gz bcm5719-llvm-1001c6e2cd5167a68e4a4ed95cce69637c8a301a.zip | |
Add new SIGN_EXTEND_INREG, ZERO_EXTEND_INREG, and FP_ROUND_INREG operators.
llvm-svn: 19568
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 73 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 1 |
2 files changed, 57 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index e1b52019e96..c18dd40f6dd 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -220,26 +220,19 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) { N->getOperand(1)), cast<SetCCSDNode>(N)->getCondition())); break; - case ISD::TRUNCSTORE: { - EVTStruct NN; - NN.Opcode = ISD::TRUNCSTORE; - NN.VT = N->getValueType(0); - NN.EVT = cast<MVTSDNode>(N)->getExtraValueType(); - NN.Ops.push_back(N->getOperand(0)); - NN.Ops.push_back(N->getOperand(1)); - NN.Ops.push_back(N->getOperand(2)); - MVTSDNodes.erase(NN); - break; - } + case ISD::TRUNCSTORE: + case ISD::SIGN_EXTEND_INREG: + case ISD::ZERO_EXTEND_INREG: + case ISD::FP_ROUND_INREG: case ISD::EXTLOAD: case ISD::SEXTLOAD: case ISD::ZEXTLOAD: { EVTStruct NN; - NN.Opcode = N->getOpcode(); + NN.Opcode = ISD::TRUNCSTORE; NN.VT = N->getValueType(0); NN.EVT = cast<MVTSDNode>(N)->getExtraValueType(); - NN.Ops.push_back(N->getOperand(0)); - NN.Ops.push_back(N->getOperand(1)); + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) + NN.Ops.push_back(N->getOperand(i)); MVTSDNodes.erase(NN); break; } @@ -857,6 +850,41 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, } SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1, + MVT::ValueType EVT) { + + switch (Opcode) { + default: assert(0 && "Bad opcode for this accessor!"); + case ISD::FP_ROUND_INREG: + assert(VT == N1.getValueType() && "Not an inreg round!"); + assert(MVT::isFloatingPoint(VT) && MVT::isFloatingPoint(EVT) && + "Cannot FP_ROUND_INREG integer types"); + if (EVT == VT) return N1; // Not actually rounding + assert(EVT < VT && "Not rounding down!"); + break; + case ISD::ZERO_EXTEND_INREG: + case ISD::SIGN_EXTEND_INREG: + assert(VT == N1.getValueType() && "Not an inreg extend!"); + assert(MVT::isInteger(VT) && MVT::isInteger(EVT) && + "Cannot *_EXTEND_INREG FP types"); + if (EVT == VT) return N1; // Not actually extending + assert(EVT < VT && "Not extending!"); + break; + } + + EVTStruct NN; + NN.Opcode = Opcode; + NN.VT = VT; + NN.EVT = EVT; + NN.Ops.push_back(N1); + + SDNode *&N = MVTSDNodes[NN]; + if (N) return SDOperand(N, 0); + N = new MVTSDNode(Opcode, VT, N1, EVT); + AllNodes.push_back(N); + return SDOperand(N, 0); +} + +SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1, SDOperand N2, MVT::ValueType EVT) { switch (Opcode) { default: assert(0 && "Bad opcode for this accessor!"); @@ -894,10 +922,20 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,SDOperand N1, switch (Opcode) { default: assert(0 && "Bad opcode for this accessor!"); case ISD::TRUNCSTORE: +#if 0 // FIXME: If the target supports EVT natively, convert to a truncate/store + // If this is a truncating store of a constant, convert to the desired type + // and store it instead. + if (isa<Constant>(N1)) { + SDOperand Op = getNode(ISD::TRUNCATE, EVT, N1); + if (isa<Constant>(Op)) + N1 = Op; + } + // Also for ConstantFP? +#endif if (N1.getValueType() == EVT) // Normal store? return getNode(ISD::STORE, VT, N1, N2, N3); - assert(N1.getValueType() > EVT && "Not a truncation?"); - assert(MVT::isInteger(N1.getValueType()) == MVT::isInteger(EVT) && + assert(N2.getValueType() > EVT && "Not a truncation?"); + assert(MVT::isInteger(N2.getValueType()) == MVT::isInteger(EVT) && "Can't do FP-INT conversion!"); break; } @@ -988,8 +1026,11 @@ const char *SDNode::getOperationName() const { // Conversion operators. case ISD::SIGN_EXTEND: return "sign_extend"; case ISD::ZERO_EXTEND: return "zero_extend"; + case ISD::SIGN_EXTEND_INREG: return "sign_extend_inreg"; + case ISD::ZERO_EXTEND_INREG: return "zero_extend_inreg"; case ISD::TRUNCATE: return "truncate"; case ISD::FP_ROUND: return "fp_round"; + case ISD::FP_ROUND_INREG: return "fp_round_inreg"; case ISD::FP_EXTEND: return "fp_extend"; case ISD::SINT_TO_FP: return "sint_to_fp"; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 2d264c0ed2f..3250760acad 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -570,7 +570,6 @@ void SelectionDAGLowering::visitStore(StoreInst &I) { SDOperand Src = getValue(SrcV); SDOperand Ptr = getValue(I.getOperand(1)); DAG.setRoot(DAG.getNode(ISD::STORE, MVT::Other, DAG.getRoot(), Src, Ptr)); - return; } void SelectionDAGLowering::visitCall(CallInst &I) { |

