diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-22 13:09:10 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-22 13:09:10 -0800 |
commit | 30fb3ff89104c2a4112f54740722c43f42286f74 (patch) | |
tree | b86707e574efc191682ed396b51f954490727187 /lib/Transforms/NaCl/ExpandI64.cpp | |
parent | 4f5b909434e73adbceb1e96a95d0bda1b34666aa (diff) |
handle fptosi|ui on both floats and doubles
Diffstat (limited to 'lib/Transforms/NaCl/ExpandI64.cpp')
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp index 5af1ac197d..40ad6b6cbf 100644 --- a/lib/Transforms/NaCl/ExpandI64.cpp +++ b/lib/Transforms/NaCl/ExpandI64.cpp @@ -98,7 +98,7 @@ namespace { void finalizeInst(Instruction *I); - Function *Add, *Sub, *Mul, *SDiv, *UDiv, *SRem, *URem, *LShr, *AShr, *Shl, *GetHigh, *SetHigh, *FPtoILow, *FPtoIHigh, *SItoF, *UItoF, *SItoD, *UItoD, *BItoD, *BDtoILow, *BDtoIHigh; + Function *Add, *Sub, *Mul, *SDiv, *UDiv, *SRem, *URem, *LShr, *AShr, *Shl, *GetHigh, *SetHigh, *FtoILow, *FtoIHigh, *DtoILow, *DtoIHigh, *SItoF, *UItoF, *SItoD, *UItoD, *BItoD, *BDtoILow, *BDtoIHigh; void ensureFuncs(); @@ -509,9 +509,16 @@ void ExpandI64::splitInst(Instruction *I, DataLayout& DL) { case Instruction::FPToSI: { ensureFuncs(); SmallVector<Value *, 1> Args; - Args.push_back(I->getOperand(0)); - Instruction *L = CopyDebug(CallInst::Create(FPtoILow, Args, "", I), I); - Instruction *H = CopyDebug(CallInst::Create(FPtoIHigh, Args, "", I), I); + Value *Input = I->getOperand(0); + Args.push_back(Input); + Instruction *L, *H; + if (Input->getType()->isFloatTy()) { + L = CopyDebug(CallInst::Create(FtoILow, Args, "", I), I); + H = CopyDebug(CallInst::Create(FtoIHigh, Args, "", I), I); + } else { + L = CopyDebug(CallInst::Create(DtoILow, Args, "", I), I); + H = CopyDebug(CallInst::Create(DtoIHigh, Args, "", I), I); + } SplitInfo &Split = Splits[I]; Split.LowHigh.Low = L; Split.LowHigh.High = H; @@ -890,16 +897,25 @@ void ExpandI64::ensureFuncs() { Type *Double = Type::getDoubleTy(TheModule->getContext()); Type *Float = Type::getFloatTy(TheModule->getContext()); - SmallVector<Type*, 1> FPtoITypes; - FPtoITypes.push_back(Double); - FunctionType *FPtoIFunc = FunctionType::get(i32, FPtoITypes, false); - FPtoILow = Function::Create(FPtoIFunc, GlobalValue::ExternalLinkage, - "FPtoILow", TheModule); - FPtoIHigh = Function::Create(FPtoIFunc, GlobalValue::ExternalLinkage, - "FPtoIHigh", TheModule); - BDtoILow = Function::Create(FPtoIFunc, GlobalValue::ExternalLinkage, + SmallVector<Type*, 1> FtoITypes; + FtoITypes.push_back(Float); + FunctionType *FtoIFunc = FunctionType::get(i32, FtoITypes, false); + + SmallVector<Type*, 1> DtoITypes; + DtoITypes.push_back(Double); + FunctionType *DtoIFunc = FunctionType::get(i32, DtoITypes, false); + + FtoILow = Function::Create(FtoIFunc, GlobalValue::ExternalLinkage, + "FtoILow", TheModule); + FtoIHigh = Function::Create(FtoIFunc, GlobalValue::ExternalLinkage, + "FtoIHigh", TheModule); + DtoILow = Function::Create(DtoIFunc, GlobalValue::ExternalLinkage, + "DtoILow", TheModule); + DtoIHigh = Function::Create(DtoIFunc, GlobalValue::ExternalLinkage, + "DtoIHigh", TheModule); + BDtoILow = Function::Create(DtoIFunc, GlobalValue::ExternalLinkage, "BDtoILow", TheModule); - BDtoIHigh = Function::Create(FPtoIFunc, GlobalValue::ExternalLinkage, + BDtoIHigh = Function::Create(DtoIFunc, GlobalValue::ExternalLinkage, "BDtoIHigh", TheModule); SmallVector<Type*, 2> ItoTypes; |