diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-08 16:06:50 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-08 16:06:50 -0500 |
commit | cbc0e4652b73931bb379dc71fdb2e8e2948b9811 (patch) | |
tree | df815205d7f3ecaef8d3e6e5e78175edd396be2c | |
parent | 99a0a2db9d1da8453731e8d95438cedf574f41d7 (diff) |
legalize shl
-rw-r--r-- | lib/Target/CppBackend/CallHandlers.h | 5 | ||||
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/Target/CppBackend/CallHandlers.h b/lib/Target/CppBackend/CallHandlers.h index 6976fe1a2a..fba392160c 100644 --- a/lib/Target/CppBackend/CallHandlers.h +++ b/lib/Target/CppBackend/CallHandlers.h @@ -69,6 +69,10 @@ DEF_CALL_HANDLER(bitshift64Ashr, { return CH___default__(CI, "_bitshift64Ashr", 3) + "|0"; }) +DEF_CALL_HANDLER(bitshift64Shl, { + return CH___default__(CI, "_bitshift64Shl", 3) + "|0"; +}) + #define DEF_REDIRECT_HANDLER_i(name, to) \ DEF_CALL_HANDLER(name, { \ /* FIXME: do not redirect if this is implemented and not just a declare! */ \ @@ -96,6 +100,7 @@ void setupCallHandlers() { SETUP_CALL_HANDLER(llvm_memmove_p0i8_p0i8_i32); SETUP_CALL_HANDLER(bitshift64Lshr); SETUP_CALL_HANDLER(bitshift64Ashr); + SETUP_CALL_HANDLER(bitshift64Shl); SETUP_CALL_HANDLER(putc); SETUP_CALL_HANDLER(__cxa_atexit); } diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp index 88325b9540..d064a508c0 100644 --- a/lib/Transforms/NaCl/ExpandI64.cpp +++ b/lib/Transforms/NaCl/ExpandI64.cpp @@ -87,7 +87,7 @@ namespace { void finalizeInst(Instruction *I); - Function *Add, *Sub, *Mul, *SDiv, *UDiv, *SRem, *URem, *LShr, *AShr, *GetHigh, *SetHigh; + Function *Add, *Sub, *Mul, *SDiv, *UDiv, *SRem, *URem, *LShr, *AShr, *Shl, *GetHigh, *SetHigh; void ensureFuncs(); @@ -98,7 +98,7 @@ namespace { ExpandI64() : ModulePass(ID) { initializeExpandI64Pass(*PassRegistry::getPassRegistry()); - Add = Sub = Mul = SDiv = UDiv = SRem = URem = LShr = AShr = GetHigh = SetHigh = NULL; + Add = Sub = Mul = SDiv = UDiv = SRem = URem = LShr = AShr = Shl = GetHigh = SetHigh = NULL; } virtual bool runOnModule(Module &M); @@ -209,7 +209,8 @@ void ExpandI64::splitInst(Instruction *I, DataLayout& DL) { case Instruction::SRem: case Instruction::URem: case Instruction::LShr: - case Instruction::AShr: { + case Instruction::AShr: + case Instruction::Shl: { ensureFuncs(); Function *F; switch (I->getOpcode()) { @@ -222,6 +223,7 @@ void ExpandI64::splitInst(Instruction *I, DataLayout& DL) { case Instruction::URem: F = URem; break; case Instruction::LShr: F = LShr; break; case Instruction::AShr: F = AShr; break; + case Instruction::Shl: F = Shl; break; default: assert(0); } SmallVector<Value *, 4> Args; @@ -360,7 +362,8 @@ void ExpandI64::finalizeInst(Instruction *I) { case Instruction::SRem: case Instruction::URem: case Instruction::LShr: - case Instruction::AShr: { + case Instruction::AShr: + case Instruction::Shl: { LowHighPair LeftLH = getLowHigh(I->getOperand(0)); LowHighPair RightLH = getLowHigh(I->getOperand(1)); Instruction *Call = Split.ToFix[0]; @@ -443,6 +446,8 @@ void ExpandI64::ensureFuncs() { "bitshift64Lshr", TheModule); AShr = Function::Create(FourFunc, GlobalValue::ExternalLinkage, "bitshift64Ashr", TheModule); + Shl = Function::Create(FourFunc, GlobalValue::ExternalLinkage, + "bitshift64Shl", TheModule); SmallVector<Type*, 0> GetHighArgTypes; FunctionType *GetHighFunc = FunctionType::get(i32, GetHighArgTypes, false); |