LLVM API Documentation

ARMSubtarget.h

Go to the documentation of this file.
00001 //=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the ARM specific subclass of TargetSubtarget.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef ARMSUBTARGET_H
00015 #define ARMSUBTARGET_H
00016 
00017 #include "llvm/Target/TargetInstrItineraries.h"
00018 #include "llvm/Target/TargetSubtarget.h"
00019 #include <string>
00020 
00021 namespace llvm {
00022 class GlobalValue;
00023 
00024 class ARMSubtarget : public TargetSubtarget {
00025 protected:
00026   enum ARMArchEnum {
00027     V4T, V5T, V5TE, V6, V6T2, V7A
00028   };
00029 
00030   enum ARMFPEnum {
00031     None, VFPv2, VFPv3, NEON
00032   };
00033 
00034   enum ThumbTypeEnum {
00035     Thumb1,
00036     Thumb2
00037   };
00038 
00039   /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
00040   /// V6, V6T2, V7A.
00041   ARMArchEnum ARMArchVersion;
00042 
00043   /// ARMFPUType - Floating Point Unit type.
00044   ARMFPEnum ARMFPUType;
00045 
00046   /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
00047   /// specified. Use the method useNEONForSinglePrecisionFP() to
00048   /// determine if NEON should actually be used.
00049   bool UseNEONForSinglePrecisionFP;
00050 
00051   /// IsThumb - True if we are in thumb mode, false if in ARM mode.
00052   bool IsThumb;
00053 
00054   /// ThumbMode - Indicates supported Thumb version.
00055   ThumbTypeEnum ThumbMode;
00056 
00057   /// IsR9Reserved - True if R9 is a not available as general purpose register.
00058   bool IsR9Reserved;
00059 
00060   /// stackAlignment - The minimum alignment known to hold of the stack frame on
00061   /// entry to the function and which must be maintained by every function.
00062   unsigned stackAlignment;
00063 
00064   /// CPUString - String name of used CPU.
00065   std::string CPUString;
00066 
00067   /// Selected instruction itineraries (one entry per itinerary class.)
00068   InstrItineraryData InstrItins;
00069 
00070  public:
00071   enum {
00072     isELF, isDarwin
00073   } TargetType;
00074 
00075   enum {
00076     ARM_ABI_APCS,
00077     ARM_ABI_AAPCS // ARM EABI
00078   } TargetABI;
00079 
00080   /// This constructor initializes the data members to match that
00081   /// of the specified triple.
00082   ///
00083   ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
00084 
00085   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
00086   /// that still makes it profitable to inline the call.
00087   unsigned getMaxInlineSizeThreshold() const {
00088     // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
00089     // Change this once Thumb ldmia / stmia support is added.
00090     return isThumb() ? 0 : 64;
00091   }
00092   /// ParseSubtargetFeatures - Parses features string setting specified
00093   /// subtarget options.  Definition of function is auto generated by tblgen.
00094   std::string ParseSubtargetFeatures(const std::string &FS,
00095                                      const std::string &CPU);
00096 
00097   bool hasV4TOps()  const { return ARMArchVersion >= V4T;  }
00098   bool hasV5TOps()  const { return ARMArchVersion >= V5T;  }
00099   bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
00100   bool hasV6Ops()   const { return ARMArchVersion >= V6;   }
00101   bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
00102   bool hasV7Ops()   const { return ARMArchVersion >= V7A;  }
00103 
00104   bool hasVFP2() const { return ARMFPUType >= VFPv2; }
00105   bool hasVFP3() const { return ARMFPUType >= VFPv3; }
00106   bool hasNEON() const { return ARMFPUType >= NEON;  }
00107   bool useNEONForSinglePrecisionFP() const {
00108     return hasNEON() && UseNEONForSinglePrecisionFP; }
00109 
00110   bool isTargetDarwin() const { return TargetType == isDarwin; }
00111   bool isTargetELF() const { return TargetType == isELF; }
00112 
00113   bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
00114   bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
00115 
00116   bool isThumb() const { return IsThumb; }
00117   bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
00118   bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
00119   bool hasThumb2() const { return ThumbMode >= Thumb2; }
00120 
00121   bool isR9Reserved() const { return IsR9Reserved; }
00122 
00123   const std::string & getCPUString() const { return CPUString; }
00124 
00125   /// getInstrItins - Return the instruction itineraies based on subtarget
00126   /// selection.
00127   const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
00128 
00129   /// getStackAlignment - Returns the minimum alignment known to hold of the
00130   /// stack frame on entry to the function and which must be maintained by every
00131   /// function for this subtarget.
00132   unsigned getStackAlignment() const { return stackAlignment; }
00133 
00134   /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
00135   /// symbol.
00136   bool GVIsIndirectSymbol(GlobalValue *GV, bool isStatic) const;
00137 };
00138 } // End llvm namespace
00139 
00140 #endif  // ARMSUBTARGET_H