ARMSubtarget.h revision 207618
144165Sjulian//=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====// 244165Sjulian// 344165Sjulian// The LLVM Compiler Infrastructure 444165Sjulian// 544165Sjulian// This file is distributed under the University of Illinois Open Source 644165Sjulian// License. See LICENSE.TXT for details. 744165Sjulian// 844165Sjulian//===----------------------------------------------------------------------===// 944165Sjulian// 1044165Sjulian// This file declares the ARM specific subclass of TargetSubtarget. 1144165Sjulian// 1244165Sjulian//===----------------------------------------------------------------------===// 1344165Sjulian 1444165Sjulian#ifndef ARMSUBTARGET_H 1544165Sjulian#define ARMSUBTARGET_H 1644165Sjulian 1744165Sjulian#include "llvm/Target/TargetInstrItineraries.h" 1844165Sjulian#include "llvm/Target/TargetMachine.h" 1944165Sjulian#include "llvm/Target/TargetSubtarget.h" 2044165Sjulian#include "ARMBaseRegisterInfo.h" 2144165Sjulian#include <string> 2244165Sjulian 2344165Sjuliannamespace llvm { 2444165Sjulianclass GlobalValue; 2544165Sjulian 2644165Sjulianclass ARMSubtarget : public TargetSubtarget { 2744165Sjulianprotected: 2844165Sjulian enum ARMArchEnum { 2944165Sjulian V4, V4T, V5T, V5TE, V6, V6T2, V7A 3050514Slile }; 3150514Slile 3244165Sjulian enum ARMFPEnum { 3350514Slile None, VFPv2, VFPv3, NEON 3444165Sjulian }; 3550514Slile 3650514Slile enum ThumbTypeEnum { 3750514Slile Thumb1, 3850514Slile Thumb2 3950514Slile }; 4044165Sjulian 4150514Slile /// ARMArchVersion - ARM architecture version: V4, V4T (base), V5T, V5TE, 4250514Slile /// V6, V6T2, V7A. 4350514Slile ARMArchEnum ARMArchVersion; 4450514Slile 4550514Slile /// ARMFPUType - Floating Point Unit type. 4650514Slile ARMFPEnum ARMFPUType; 4750514Slile 4850514Slile /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been 4950514Slile /// specified. Use the method useNEONForSinglePrecisionFP() to 5050514Slile /// determine if NEON should actually be used. 5150514Slile bool UseNEONForSinglePrecisionFP; 5244165Sjulian 5344165Sjulian /// SlowVMLx - If the VFP2 instructions are available, indicates whether 5444165Sjulian /// the VML[AS] instructions are slow (if so, don't use them). 5544165Sjulian bool SlowVMLx; 5644165Sjulian 5744165Sjulian /// IsThumb - True if we are in thumb mode, false if in ARM mode. 5844165Sjulian bool IsThumb; 5944165Sjulian 60 /// ThumbMode - Indicates supported Thumb version. 61 ThumbTypeEnum ThumbMode; 62 63 /// PostRAScheduler - True if using post-register-allocation scheduler. 64 bool PostRAScheduler; 65 66 /// IsR9Reserved - True if R9 is a not available as general purpose register. 67 bool IsR9Reserved; 68 69 /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit 70 /// imms (including global addresses). 71 bool UseMovt; 72 73 /// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF 74 /// only so far) 75 bool HasFP16; 76 77 /// stackAlignment - The minimum alignment known to hold of the stack frame on 78 /// entry to the function and which must be maintained by every function. 79 unsigned stackAlignment; 80 81 /// CPUString - String name of used CPU. 82 std::string CPUString; 83 84 /// Selected instruction itineraries (one entry per itinerary class.) 85 InstrItineraryData InstrItins; 86 87 public: 88 enum { 89 isELF, isDarwin 90 } TargetType; 91 92 enum { 93 ARM_ABI_APCS, 94 ARM_ABI_AAPCS // ARM EABI 95 } TargetABI; 96 97 /// This constructor initializes the data members to match that 98 /// of the specified triple. 99 /// 100 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb); 101 102 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size 103 /// that still makes it profitable to inline the call. 104 unsigned getMaxInlineSizeThreshold() const { 105 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb1. 106 // Change this once Thumb1 ldmia / stmia support is added. 107 return isThumb1Only() ? 0 : 64; 108 } 109 /// ParseSubtargetFeatures - Parses features string setting specified 110 /// subtarget options. Definition of function is auto generated by tblgen. 111 std::string ParseSubtargetFeatures(const std::string &FS, 112 const std::string &CPU); 113 114 bool hasV4TOps() const { return ARMArchVersion >= V4T; } 115 bool hasV5TOps() const { return ARMArchVersion >= V5T; } 116 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; } 117 bool hasV6Ops() const { return ARMArchVersion >= V6; } 118 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; } 119 bool hasV7Ops() const { return ARMArchVersion >= V7A; } 120 121 bool hasVFP2() const { return ARMFPUType >= VFPv2; } 122 bool hasVFP3() const { return ARMFPUType >= VFPv3; } 123 bool hasNEON() const { return ARMFPUType >= NEON; } 124 bool useNEONForSinglePrecisionFP() const { 125 return hasNEON() && UseNEONForSinglePrecisionFP; } 126 bool useVMLx() const {return hasVFP2() && !SlowVMLx; } 127 128 bool hasFP16() const { return HasFP16; } 129 130 bool isTargetDarwin() const { return TargetType == isDarwin; } 131 bool isTargetELF() const { return TargetType == isELF; } 132 133 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; } 134 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; } 135 136 bool isThumb() const { return IsThumb; } 137 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); } 138 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); } 139 bool hasThumb2() const { return ThumbMode >= Thumb2; } 140 141 bool isR9Reserved() const { return IsR9Reserved; } 142 143 bool useMovt() const { return UseMovt && hasV6T2Ops(); } 144 145 const std::string & getCPUString() const { return CPUString; } 146 147 /// enablePostRAScheduler - True at 'More' optimization. 148 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, 149 TargetSubtarget::AntiDepBreakMode& Mode, 150 RegClassVector& CriticalPathRCs) const; 151 152 /// getInstrItins - Return the instruction itineraies based on subtarget 153 /// selection. 154 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } 155 156 /// getStackAlignment - Returns the minimum alignment known to hold of the 157 /// stack frame on entry to the function and which must be maintained by every 158 /// function for this subtarget. 159 unsigned getStackAlignment() const { return stackAlignment; } 160 161 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect 162 /// symbol. 163 bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const; 164}; 165} // End llvm namespace 166 167#endif // ARMSUBTARGET_H 168