[llvm] r175315 - Support changing the subtarget features in ARM.

Bill Wendling wendling at apple.com
Sun Feb 17 02:42:47 PST 2013


Ah! Copy-pasto. :-)

-bw

On Feb 16, 2013, at 10:55 AM, Renato Golin <renato.golin at linaro.org> wrote:

> +  /// \brief Reset the features for the X86 target.
> 
> ARM... ;)
> 
> --renato
> 
> 
> On 15 February 2013 22:41, Bill Wendling <isanbard at gmail.com> wrote:
> Author: void
> Date: Fri Feb 15 16:41:25 2013
> New Revision: 175315
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=175315&view=rev
> Log:
> Support changing the subtarget features in ARM.
> 
> Modified:
>     llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
>     llvm/trunk/lib/Target/ARM/ARMSubtarget.h
> 
> Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=175315&r1=175314&r2=175315&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Fri Feb 15 16:41:25 2013
> @@ -14,7 +14,9 @@
>  #include "ARMSubtarget.h"
>  #include "ARMBaseInstrInfo.h"
>  #include "ARMBaseRegisterInfo.h"
> +#include "llvm/IR/Attributes.h"
>  #include "llvm/IR/GlobalValue.h"
> +#include "llvm/IR/Function.h"
>  #include "llvm/Support/CommandLine.h"
>  #include "llvm/Target/TargetInstrInfo.h"
> 
> @@ -85,17 +87,35 @@ ARMSubtarget::ARMSubtarget(const std::st
>    , CPUString(CPU)
>    , TargetTriple(TT)
>    , TargetABI(ARM_ABI_APCS) {
> -  // Determine default and user specified characteristics
> +  resetSubtargetFeatures(CPU, FS);
> +}
> +
> +void ARMSubtarget::resetSubtargetFeatures(const MachineFunction *MF) {
> +  AttributeSet FnAttrs = MF->getFunction()->getAttributes();
> +  Attribute CPUAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex,
> +                                           "target-cpu");
> +  Attribute FSAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex,
> +                                          "target-features");
> +  std::string CPU =
> +    !CPUAttr.hasAttribute(Attribute::None) ?CPUAttr.getValueAsString() : "";
> +  std::string FS =
> +    !FSAttr.hasAttribute(Attribute::None) ? FSAttr.getValueAsString() : "";
> +  if (!FS.empty())
> +    resetSubtargetFeatures(CPU, FS);
> +}
> +
> +void ARMSubtarget::resetSubtargetFeatures(StringRef CPU, StringRef FS) {
>    if (CPUString.empty())
>      CPUString = "generic";
> 
>    // Insert the architecture feature derived from the target triple into the
>    // feature string. This is important for setting features that are implied
>    // based on the architecture version.
> -  std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPUString);
> +  std::string ArchFS = ARM_MC::ParseARMTriple(TargetTriple.getTriple(),
> +                                              CPUString);
>    if (!FS.empty()) {
>      if (!ArchFS.empty())
> -      ArchFS = ArchFS + "," + FS;
> +      ArchFS = ArchFS + "," + FS.str();
>      else
>        ArchFS = FS;
>    }
> @@ -112,7 +132,8 @@ ARMSubtarget::ARMSubtarget(const std::st
>    // Initialize scheduling itinerary for the specified CPU.
>    InstrItins = getInstrItineraryForCPU(CPUString);
> 
> -  if ((TT.find("eabi") != std::string::npos) || (isTargetIOS() && isMClass()))
> +  if ((TargetTriple.getTriple().find("eabi") != std::string::npos) ||
> +      (isTargetIOS() && isMClass()))
>      // FIXME: We might want to separate AAPCS and EABI. Some systems, e.g.
>      // Darwin-EABI conforms to AACPS but not the rest of EABI.
>      TargetABI = ARM_ABI_AAPCS;
> 
> Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=175315&r1=175314&r2=175315&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original)
> +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Fri Feb 15 16:41:25 2013
> @@ -202,6 +202,10 @@ protected:
>    /// subtarget options.  Definition of function is auto generated by tblgen.
>    void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
> 
> +  /// \brief Reset the features for the X86 target.
> +  virtual void resetSubtargetFeatures(const MachineFunction *MF);
> +  void resetSubtargetFeatures(StringRef CPU, StringRef FS);
> +
>    void computeIssueWidth();
> 
>    bool hasV4TOps()  const { return HasV4TOps;  }
> 
> 
> _______________________________________________
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130217/490860a4/attachment.html>


More information about the llvm-commits mailing list