diff options
author | Nate Begeman <natebegeman@mac.com> | 2008-02-14 08:57:00 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2008-02-14 08:57:00 +0000 |
commit | e2ba64fc3785eb8bcc9a7fc2091c56ef056cbc07 (patch) | |
tree | 154abecd7804f8cb2ee74ced19f41990f9725832 /lib/CodeGen | |
parent | 74bb9f5ad413f38958e64052a8d409fb5f20ec33 (diff) | |
download | external_llvm-e2ba64fc3785eb8bcc9a7fc2091c56ef056cbc07.zip external_llvm-e2ba64fc3785eb8bcc9a7fc2091c56ef056cbc07.tar.gz external_llvm-e2ba64fc3785eb8bcc9a7fc2091c56ef056cbc07.tar.bz2 |
Change how FP immediates are handled.
1) ConstantFP is now expand by default
2) ConstantFP is not turned into TargetConstantFP during Legalize
if it is legal.
This allows ConstantFP to be handled like Constant, allowing for
targets that can encode FP immediates as MachineOperands.
As a bonus, fix up Itanium FP constants, which now correctly match,
and match more constants! Hooray.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 33 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAG.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/TargetLowering.cpp | 7 |
3 files changed, 28 insertions, 17 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 2b8d47b..f0f3d1c 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1155,24 +1155,10 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { // leave these constants as ConstantFP nodes for the target to deal with. ConstantFPSDNode *CFP = cast<ConstantFPSDNode>(Node); - // Check to see if this FP immediate is already legal. - bool isLegal = false; - for (TargetLowering::legal_fpimm_iterator I = TLI.legal_fpimm_begin(), - E = TLI.legal_fpimm_end(); I != E; ++I) - if (CFP->isExactlyValue(*I)) { - isLegal = true; - break; - } - - // If this is a legal constant, turn it into a TargetConstantFP node. - if (isLegal) { - Result = DAG.getTargetConstantFP(CFP->getValueAPF(), - CFP->getValueType(0)); - break; - } - switch (TLI.getOperationAction(ISD::ConstantFP, CFP->getValueType(0))) { default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Legal: + break; case TargetLowering::Custom: Tmp3 = TLI.LowerOperation(Result, DAG); if (Tmp3.Val) { @@ -1180,9 +1166,22 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { break; } // FALLTHROUGH - case TargetLowering::Expand: + case TargetLowering::Expand: { + // Check to see if this FP immediate is already legal. + bool isLegal = false; + for (TargetLowering::legal_fpimm_iterator I = TLI.legal_fpimm_begin(), + E = TLI.legal_fpimm_end(); I != E; ++I) { + if (CFP->isExactlyValue(*I)) { + isLegal = true; + break; + } + } + // If this is a legal constant, turn it into a TargetConstantFP node. + if (isLegal) + break; Result = ExpandConstantFP(CFP, true, DAG, TLI); } + } break; } case ISD::TokenFactor: diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp index 44886e7..e798015 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "pre-RA-sched" +#include "llvm/Constants.h" #include "llvm/Type.h" #include "llvm/CodeGen/ScheduleDAG.h" #include "llvm/CodeGen/MachineConstantPool.h" @@ -478,6 +479,10 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op, } } else if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) { MI->addOperand(MachineOperand::CreateImm(C->getValue())); + } else if (ConstantFPSDNode *F = dyn_cast<ConstantFPSDNode>(Op)) { + const Type *FType = MVT::getTypeForValueType(Op.getValueType()); + ConstantFP *CFP = ConstantFP::get(FType, F->getValueAPF()); + MI->addOperand(MachineOperand::CreateFPImm(CFP)); } else if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(Op)) { MI->addOperand(MachineOperand::CreateReg(R->getReg(), false)); } else if (GlobalAddressSDNode *TGA = dyn_cast<GlobalAddressSDNode>(Op)) { diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index f74ea5c..e58c2f7 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -174,6 +174,13 @@ TargetLowering::TargetLowering(TargetMachine &tm) // These operations default to expand. setOperationAction(ISD::FGETSIGN, (MVT::ValueType)VT, Expand); } + + // ConstantFP nodes default to expand. Targets can either change this to + // Legal, in which case all fp constants are legal, or use addLegalFPImmediate + // to optimize expansions for certain constants. + setOperationAction(ISD::ConstantFP, MVT::f32, Expand); + setOperationAction(ISD::ConstantFP, MVT::f64, Expand); + setOperationAction(ISD::ConstantFP, MVT::f80, Expand); // Default ISD::TRAP to expand (which turns it into abort). setOperationAction(ISD::TRAP, MVT::Other, Expand); |