[llvm-commits] [llvm] r129045 - in /llvm/trunk: include/llvm/Target/TargetOptions.h lib/Target/ARM/ARMISelLowering.cpp lib/Target/TargetMachine.cpp test/CodeGen/ARM/divmod.ll

Bob Wilson bob.wilson at apple.com
Thu Apr 7 09:05:33 PDT 2011


On Apr 6, 2011, at 10:49 PM, Chris Lattner wrote:

> 
> On Apr 6, 2011, at 5:58 PM, Evan Cheng wrote:
> 
>> Author: evancheng
>> Date: Wed Apr  6 19:58:44 2011
>> New Revision: 129045
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=129045&view=rev
>> Log:
>> Change -arm-divmod-libcall to a target neutral option.
> 
> Hi Evan,
> 
> Shouldn't this just be conditionalized based on the target?  We don't want an extra knob for this.
> 
> -Chris

I think Evan agrees with you.

There are some problems with the version numbers in arm-apple-darwin triples, so we've been discussing how to fix it.  Daniel, Jim and Andy all had a fairly strong preference to put the logic controlling things like this in the driver, rather than spreading tests of the OS version through the backend.  For example, in this case the driver would look at the OS and OS version number to decide whether to pass -use-divmod-libcall to the backend.  This makes it easier to find all the OS and version-specific logic in one place (the driver), and with Andy's new --print-options flag, you can easily see what options are enabled and modify them individually (e.g., for debugging).

The alternative of having the driver specify the OS and OS version via the target triple has the advantage of preserving that information in the bitcode file so that you can get the same options enabled without having to pass so many flags to opt or llc, but it makes it hard to figure out why the compiler does certain things.  The --print-options feature won't show you those things.

I had been on the fence on this topic, but I've become convinced that having separate knobs for these things is a good idea.  If you still disagree, it would be good to hash this out before we go much further in that direction.

> 
> 
>> 
>> Modified:
>>   llvm/trunk/include/llvm/Target/TargetOptions.h
>>   llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
>>   llvm/trunk/lib/Target/TargetMachine.cpp
>>   llvm/trunk/test/CodeGen/ARM/divmod.ll
>> 
>> Modified: llvm/trunk/include/llvm/Target/TargetOptions.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=129045&r1=129044&r2=129045&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Target/TargetOptions.h (original)
>> +++ llvm/trunk/include/llvm/Target/TargetOptions.h Wed Apr  6 19:58:44 2011
>> @@ -157,6 +157,10 @@
>>  /// wth earlier copy coalescing.
>>  extern bool StrongPHIElim;
>> 
>> +  /// HasDivModLibcall - This flag indicates whether the target compiler
>> +  /// runtime library has integer divmod libcalls.
>> +  extern bool HasDivModLibcall;
>> +
>> } // End llvm namespace
>> 
>> #endif
>> 
>> Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=129045&r1=129044&r2=129045&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
>> +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Apr  6 19:58:44 2011
>> @@ -72,11 +72,6 @@
>>  cl::desc("Enable / disable ARM interworking (for debugging only)"),
>>  cl::init(true));
>> 
>> -static cl::opt<bool>
>> -UseDivMod("arm-divmod-libcall", cl::Hidden,
>> -  cl::desc("Use __{u}divmod libcalls for div / rem pairs"),
>> -  cl::init(false));
>> -
>> void ARMTargetLowering::addTypeForNEON(EVT VT, EVT PromotedLdStVT,
>>                                       EVT PromotedBitwiseVT) {
>>  if (VT != PromotedLdStVT) {
>> @@ -398,7 +393,7 @@
>>    setLibcallCallingConv(RTLIB::UDIV_I32, CallingConv::ARM_AAPCS);
>>  }
>> 
>> -  if (UseDivMod) {
>> +  if (HasDivModLibcall) {
>>    setLibcallName(RTLIB::SDIVREM_I32, "__divmodsi4");
>>    setLibcallName(RTLIB::UDIVREM_I32, "__udivmodsi4");
>>  }
>> 
>> Modified: llvm/trunk/lib/Target/TargetMachine.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=129045&r1=129044&r2=129045&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/TargetMachine.cpp (original)
>> +++ llvm/trunk/lib/Target/TargetMachine.cpp Wed Apr  6 19:58:44 2011
>> @@ -48,6 +48,7 @@
>>  bool RealignStack;
>>  bool DisableJumpTables;
>>  bool StrongPHIElim;
>> +  bool HasDivModLibcall;
>>  bool AsmVerbosityDefault(false);
>> }
>> 
>> @@ -205,6 +206,11 @@
>>  cl::desc("Use strong PHI elimination."),
>>  cl::location(StrongPHIElim),
>>  cl::init(false));
>> +static cl::opt<bool, true>
>> +UseDivMod("use-divmod-libcall",
>> +  cl::desc("Use __{u}divmod libcalls for div / rem pairs"),
>> +  cl::location(HasDivModLibcall),
>> +  cl::init(false));
>> static cl::opt<bool>
>> DataSections("fdata-sections",
>>  cl::desc("Emit data into separate sections"),
>> 
>> Modified: llvm/trunk/test/CodeGen/ARM/divmod.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/divmod.ll?rev=129045&r1=129044&r2=129045&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/ARM/divmod.ll (original)
>> +++ llvm/trunk/test/CodeGen/ARM/divmod.ll Wed Apr  6 19:58:44 2011
>> @@ -1,4 +1,4 @@
>> -; RUN: llc < %s -mtriple=arm-apple-darwin -arm-divmod-libcall | FileCheck %s
>> +; RUN: llc < %s -mtriple=arm-apple-darwin -use-divmod-libcall | FileCheck %s
>> 
>> define void @foo(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp {
>> entry:
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list