diff options
author | Tim Northover <tnorthover@apple.com> | 2016-08-19 20:48:16 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2016-08-19 20:48:16 +0000 |
commit | d5c23bcfc9287a21280116ec1a5364f54c2df10c (patch) | |
tree | 82ba06131c63b20db973d6749e01faaacce7c57a /llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | |
parent | 8075b823223ea465d8fc7d7720a8abbee5798b77 (diff) | |
download | bcm5719-llvm-d5c23bcfc9287a21280116ec1a5364f54c2df10c.tar.gz bcm5719-llvm-d5c23bcfc9287a21280116ec1a5364f54c2df10c.zip |
GlobalISel: translate floating-point comparisons
llvm-svn: 279319
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 1a243c54887..36150c6c444 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -100,17 +100,24 @@ bool IRTranslator::translateBinaryOp(unsigned Opcode, const User &U) { return true; } -bool IRTranslator::translateICmp(const User &U) { - const CmpInst &CI = cast<CmpInst>(U); - unsigned Op0 = getOrCreateVReg(*CI.getOperand(0)); - unsigned Op1 = getOrCreateVReg(*CI.getOperand(1)); - unsigned Res = getOrCreateVReg(CI); - CmpInst::Predicate Pred = CI.getPredicate(); - - assert(isa<ICmpInst>(CI) && "only integer comparisons supported now"); - assert(CmpInst::isIntPredicate(Pred) && "only int comparisons supported now"); - MIRBuilder.buildICmp({LLT{*CI.getType()}, LLT{*CI.getOperand(0)->getType()}}, - Pred, Res, Op0, Op1); +bool IRTranslator::translateCompare(const User &U) { + const CmpInst *CI = dyn_cast<CmpInst>(&U); + unsigned Op0 = getOrCreateVReg(*U.getOperand(0)); + unsigned Op1 = getOrCreateVReg(*U.getOperand(1)); + unsigned Res = getOrCreateVReg(U); + CmpInst::Predicate Pred = + CI ? CI->getPredicate() : static_cast<CmpInst::Predicate>( + cast<ConstantExpr>(U).getPredicate()); + + if (CmpInst::isIntPredicate(Pred)) + MIRBuilder.buildICmp( + {LLT{*U.getType()}, LLT{*U.getOperand(0)->getType()}}, Pred, Res, Op0, + Op1); + else + MIRBuilder.buildFCmp( + {LLT{*U.getType()}, LLT{*U.getOperand(0)->getType()}}, Pred, Res, Op0, + Op1); + return true; } |