Chromium Code Reviews| Index: src/IceTargetLoweringARM32.cpp |
| diff --git a/src/IceTargetLoweringARM32.cpp b/src/IceTargetLoweringARM32.cpp |
| index 9b76976586f6406d8eb494dfbcec724078b92baa..96077ec31fa70acacac327335717610468039e60 100644 |
| --- a/src/IceTargetLoweringARM32.cpp |
| +++ b/src/IceTargetLoweringARM32.cpp |
| @@ -468,24 +468,24 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| // Technically, ARM has its own aeabi routines, but we can use the |
| // non-aeabi routine as well. LLVM uses __aeabi_ldivmod for div, but uses |
| // the more standard __moddi3 for rem. |
| - Operand *TargetHelper = nullptr; |
| + RuntimeHelperFuncID HelperID = H_Num; |
| switch (Op) { |
| default: |
| return; |
| case InstArithmetic::Udiv: |
| - TargetHelper = Ctx->getConstantExternSym(H_udiv_i64); |
| + HelperID = H_udiv_i64; |
| break; |
| case InstArithmetic::Sdiv: |
| - TargetHelper = Ctx->getConstantExternSym(H_sdiv_i64); |
| + HelperID = H_sdiv_i64; |
| break; |
| case InstArithmetic::Urem: |
| - TargetHelper = Ctx->getConstantExternSym(H_urem_i64); |
| + HelperID = H_urem_i64; |
| break; |
| case InstArithmetic::Srem: |
| - TargetHelper = Ctx->getConstantExternSym(H_srem_i64); |
| + HelperID = H_srem_i64; |
| break; |
| } |
| - assert(TargetHelper != nullptr); |
| + Operand *TargetHelper = getRuntimeHelperFunc(HelperID); |
| ARM32HelpersPreamble[TargetHelper] = &TargetARM32::preambleDivRem; |
| constexpr SizeT MaxArgs = 2; |
| auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, |
| @@ -500,33 +500,29 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| case IceType_i8: { |
| const bool HasHWDiv = hasCPUFeature(TargetARM32Features::HWDivArm); |
| InstCast::OpKind CastKind; |
| - Operand *TargetHelper; |
| + RuntimeHelperFuncID HelperID = H_Num; |
| switch (Op) { |
| default: |
| return; |
| case InstArithmetic::Udiv: |
| - TargetHelper = |
| - HasHWDiv ? nullptr : Ctx->getConstantExternSym(H_udiv_i32); |
| + HelperID = HasHWDiv ? H_Num : H_udiv_i32; |
| CastKind = InstCast::Zext; |
| break; |
| case InstArithmetic::Sdiv: |
| - TargetHelper = |
| - HasHWDiv ? nullptr : Ctx->getConstantExternSym(H_sdiv_i32); |
| + HelperID = HasHWDiv ? H_Num : H_sdiv_i32; |
| CastKind = InstCast::Sext; |
| break; |
| case InstArithmetic::Urem: |
| - TargetHelper = |
| - HasHWDiv ? nullptr : Ctx->getConstantExternSym(H_urem_i32); |
| + HelperID = HasHWDiv ? H_Num : H_urem_i32; |
| CastKind = InstCast::Zext; |
| break; |
| case InstArithmetic::Srem: |
| - TargetHelper = |
| - HasHWDiv ? nullptr : Ctx->getConstantExternSym(H_srem_i32); |
| + HelperID = HasHWDiv ? H_Num : H_srem_i32; |
| CastKind = InstCast::Sext; |
| break; |
| } |
| - if (TargetHelper == nullptr) { |
| - // TargetHelper should only ever be nullptr when the processor does not |
| + if (HelperID == H_Num) { |
| + // HelperID should only ever be undefined when the processor does not |
| // have a hardware divider. If any other helpers are ever introduced, |
| // the following assert will have to be modified. |
| assert(HasHWDiv); |
| @@ -560,7 +556,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| Src1 = Src1_32; |
| } |
| } |
| - assert(TargetHelper != nullptr); |
| + Operand *TargetHelper = getRuntimeHelperFunc(HelperID); |
| ARM32HelpersPreamble[TargetHelper] = &TargetARM32::preambleDivRem; |
| constexpr SizeT MaxArgs = 2; |
| auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, |
| @@ -578,8 +574,8 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| return; |
| } |
| constexpr SizeT MaxArgs = 2; |
| - Operand *TargetHelper = Ctx->getConstantExternSym( |
| - DestTy == IceType_f32 ? H_frem_f32 : H_frem_f64); |
| + Operand *TargetHelper = |
| + getRuntimeHelperFunc(DestTy == IceType_f32 ? H_frem_f32 : H_frem_f64); |
|
Jim Stichnoth
2016/03/17 00:14:52
It seems that TargetLowering::getRuntimeHelperFunc
John
2016/03/17 14:31:33
to avoid tons of changes, maybe just add a todo to
Karl
2016/03/17 16:40:53
See we scoped the enum RuntimeFunctionFuncID, we n
|
| auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, |
| NoTailCall, IsTargetHelperCall); |
| Call->addArg(Instr->getSrc(0)); |
| @@ -619,7 +615,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| } |
| const bool DestIsSigned = CastKind == InstCast::Fptosi; |
| const bool Src0IsF32 = isFloat32Asserting32Or64(SrcTy); |
| - Operand *TargetHelper = Ctx->getConstantExternSym( |
| + Operand *TargetHelper = getRuntimeHelperFunc( |
| Src0IsF32 ? (DestIsSigned ? H_fptosi_f32_i64 : H_fptoui_f32_i64) |
| : (DestIsSigned ? H_fptosi_f64_i64 : H_fptoui_f64_i64)); |
| static constexpr SizeT MaxArgs = 1; |
| @@ -636,7 +632,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| } |
| const bool SourceIsSigned = CastKind == InstCast::Sitofp; |
| const bool DestIsF32 = isFloat32Asserting32Or64(Dest->getType()); |
| - Operand *TargetHelper = Ctx->getConstantExternSym( |
| + Operand *TargetHelper = getRuntimeHelperFunc( |
| DestIsF32 ? (SourceIsSigned ? H_sitofp_i64_f32 : H_uitofp_i64_f32) |
| : (SourceIsSigned ? H_sitofp_i64_f64 : H_uitofp_i64_f64)); |
| static constexpr SizeT MaxArgs = 1; |
| @@ -651,23 +647,23 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| return; |
| } |
| Variable *CallDest = Dest; |
| - const char *HelperName = nullptr; |
| + RuntimeHelperFuncID HelperID = H_Num; |
| switch (DestTy) { |
| default: |
| return; |
| case IceType_i8: |
| assert(SrcTy == IceType_v8i1); |
| - HelperName = H_bitcast_8xi1_i8; |
| + HelperID = H_bitcast_8xi1_i8; |
| CallDest = Func->makeVariable(IceType_i32); |
| break; |
| case IceType_i16: |
| assert(SrcTy == IceType_v16i1); |
| - HelperName = H_bitcast_16xi1_i16; |
| + HelperID = H_bitcast_16xi1_i16; |
| CallDest = Func->makeVariable(IceType_i32); |
| break; |
| case IceType_v8i1: { |
| assert(SrcTy == IceType_i8); |
| - HelperName = H_bitcast_i8_8xi1; |
| + HelperID = H_bitcast_i8_8xi1; |
| Variable *Src0AsI32 = Func->makeVariable(stackSlotType()); |
| // Arguments to functions are required to be at least 32 bits wide. |
| Context.insert<InstCast>(InstCast::Zext, Src0AsI32, Src0); |
| @@ -675,16 +671,15 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| } break; |
| case IceType_v16i1: { |
| assert(SrcTy == IceType_i16); |
| - HelperName = H_bitcast_i16_16xi1; |
| + HelperID = H_bitcast_i16_16xi1; |
| Variable *Src0AsI32 = Func->makeVariable(stackSlotType()); |
| // Arguments to functions are required to be at least 32 bits wide. |
| Context.insert<InstCast>(InstCast::Zext, Src0AsI32, Src0); |
| Src0 = Src0AsI32; |
| } break; |
| } |
| - assert(HelperName != nullptr); |
| constexpr SizeT MaxSrcs = 1; |
| - InstCall *Call = makeHelperCall(HelperName, CallDest, MaxSrcs); |
| + InstCall *Call = makeHelperCall(HelperID, CallDest, MaxSrcs); |
| Call->addArg(Src0); |
| Context.insert(Call); |
| // The PNaCl ABI disallows i8/i16 return types, so truncate the helper |
| @@ -706,7 +701,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| return; |
| case Intrinsics::Ctpop: { |
| Operand *Src0 = IntrinsicCall->getArg(0); |
| - Operand *TargetHelper = Ctx->getConstantExternSym( |
| + Operand *TargetHelper = getRuntimeHelperFunc( |
| isInt32Asserting32Or64(Src0->getType()) ? H_call_ctpop_i32 |
| : H_call_ctpop_i64); |
| static constexpr SizeT MaxArgs = 1; |
| @@ -722,7 +717,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| case Intrinsics::Longjmp: { |
| static constexpr SizeT MaxArgs = 2; |
| static constexpr Variable *NoDest = nullptr; |
| - Operand *TargetHelper = Ctx->getConstantExternSym(H_call_longjmp); |
| + Operand *TargetHelper = getRuntimeHelperFunc(H_call_longjmp); |
| auto *Call = Context.insert<InstCall>(MaxArgs, NoDest, TargetHelper, |
| NoTailCall, IsTargetHelperCall); |
| Call->addArg(IntrinsicCall->getArg(0)); |
| @@ -735,7 +730,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| // for intrinsic calls w/ a known length. |
| static constexpr SizeT MaxArgs = 3; |
| static constexpr Variable *NoDest = nullptr; |
| - Operand *TargetHelper = Ctx->getConstantExternSym(H_call_memcpy); |
| + Operand *TargetHelper = getRuntimeHelperFunc(H_call_memcpy); |
| auto *Call = Context.insert<InstCall>(MaxArgs, NoDest, TargetHelper, |
| NoTailCall, IsTargetHelperCall); |
| Call->addArg(IntrinsicCall->getArg(0)); |
| @@ -747,7 +742,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| case Intrinsics::Memmove: { |
| static constexpr SizeT MaxArgs = 3; |
| static constexpr Variable *NoDest = nullptr; |
| - Operand *TargetHelper = Ctx->getConstantExternSym(H_call_memmove); |
| + Operand *TargetHelper = getRuntimeHelperFunc(H_call_memmove); |
| auto *Call = Context.insert<InstCall>(MaxArgs, NoDest, TargetHelper, |
| NoTailCall, IsTargetHelperCall); |
| Call->addArg(IntrinsicCall->getArg(0)); |
| @@ -769,7 +764,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| // decide to use __aeabi_memset. |
| static constexpr SizeT MaxArgs = 3; |
| static constexpr Variable *NoDest = nullptr; |
| - Operand *TargetHelper = Ctx->getConstantExternSym(H_call_memset); |
| + Operand *TargetHelper = getRuntimeHelperFunc(H_call_memset); |
| auto *Call = Context.insert<InstCall>(MaxArgs, NoDest, TargetHelper, |
| NoTailCall, IsTargetHelperCall); |
| Call->addArg(IntrinsicCall->getArg(0)); |
| @@ -783,9 +778,9 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| return; |
| } |
| static constexpr SizeT MaxArgs = 0; |
| - const char *ReadTP = |
| - SandboxingType == ST_Nonsfi ? "__aeabi_read_tp" : H_call_read_tp; |
| - Operand *TargetHelper = Ctx->getConstantExternSym(ReadTP); |
| + Operand *TargetHelper = SandboxingType == ST_Nonsfi |
| + ? Ctx->getConstantExternSym("__aeabi_read_tp") |
| + : getRuntimeHelperFunc(H_call_read_tp); |
| Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, NoTailCall, |
| IsTargetHelperCall); |
| Instr->setDeleted(); |
| @@ -793,7 +788,7 @@ void TargetARM32::genTargetHelperCallFor(Inst *Instr) { |
| } |
| case Intrinsics::Setjmp: { |
| static constexpr SizeT MaxArgs = 1; |
| - Operand *TargetHelper = Ctx->getConstantExternSym(H_call_setjmp); |
| + Operand *TargetHelper = getRuntimeHelperFunc(H_call_setjmp); |
| auto *Call = Context.insert<InstCall>(MaxArgs, Dest, TargetHelper, |
| NoTailCall, IsTargetHelperCall); |
| Call->addArg(IntrinsicCall->getArg(0)); |