From 6d5b8e16462859333db9ad984f05ec2ed1f48f4a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 9 May 2005 20:36:57 +0000 Subject: [PATCH] legalize readio/writeio into a load/store if requested git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21827 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 60 ++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index b9245a5d2ae..282dfd11ca9 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -595,7 +595,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { } V; V.F = CFP->getValue(); Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp1, - DAG.getConstant(V.I, MVT::i32), Tmp2, + DAG.getConstant(V.I, MVT::i32), Tmp2, Node->getOperand(3)); } else { assert(CFP->getValueType(0) == MVT::f64 && "Unknown FP type!"); @@ -927,11 +927,11 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { } case ISD::READPORT: - case ISD::READIO: Tmp1 = LegalizeOp(Node->getOperand(0)); Tmp2 = LegalizeOp(Node->getOperand(1)); + if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) - Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0),Tmp1, Tmp2); + Result = DAG.getNode(ISD::READPORT, Node->getValueType(0), Tmp1, Tmp2); else Result = SDOperand(Node, 0); // Since these produce two values, make sure to remember that we legalized @@ -939,9 +939,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { AddLegalizedOperand(SDOperand(Node, 0), Result); AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); return Result.getValue(Op.ResNo); - case ISD::WRITEPORT: - case ISD::WRITEIO: Tmp1 = LegalizeOp(Node->getOperand(0)); Tmp2 = LegalizeOp(Node->getOperand(1)); Tmp3 = LegalizeOp(Node->getOperand(2)); @@ -950,6 +948,58 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Result = DAG.getNode(Node->getOpcode(), MVT::Other, Tmp1, Tmp2, Tmp3); break; + case ISD::READIO: + Tmp1 = LegalizeOp(Node->getOperand(0)); + Tmp2 = LegalizeOp(Node->getOperand(1)); + + switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) { + case TargetLowering::Custom: + default: assert(0 && "This action not implemented for this operation!"); + case TargetLowering::Legal: + if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) + Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), + Tmp1, Tmp2); + else + Result = SDOperand(Node, 0); + break; + case TargetLowering::Expand: + // Replace this with a load from memory. + Result = DAG.getLoad(Node->getValueType(0), Node->getOperand(0), + Node->getOperand(1), DAG.getSrcValue(NULL)); + Result = LegalizeOp(Result); + break; + } + + // Since these produce two values, make sure to remember that we legalized + // both of them. + AddLegalizedOperand(SDOperand(Node, 0), Result); + AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); + return Result.getValue(Op.ResNo); + + case ISD::WRITEIO: + Tmp1 = LegalizeOp(Node->getOperand(0)); + Tmp2 = LegalizeOp(Node->getOperand(1)); + Tmp3 = LegalizeOp(Node->getOperand(2)); + + switch (TLI.getOperationAction(Node->getOpcode(), + Node->getOperand(1).getValueType())) { + case TargetLowering::Custom: + default: assert(0 && "This action not implemented for this operation!"); + case TargetLowering::Legal: + if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1) || + Tmp3 != Node->getOperand(2)) + Result = DAG.getNode(Node->getOpcode(), MVT::Other, Tmp1, Tmp2, Tmp3); + break; + case TargetLowering::Expand: + // Replace this with a store to memory. + Result = DAG.getNode(ISD::STORE, MVT::Other, Node->getOperand(0), + Node->getOperand(1), Node->getOperand(2), + DAG.getSrcValue(NULL)); + Result = LegalizeOp(Result); + break; + } + break; + case ISD::ADD_PARTS: case ISD::SUB_PARTS: case ISD::SHL_PARTS: