ARMSubtarget.h revision 42a83f2d15cbbc08f5be19856198e3c885221e9c
1//=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file declares the ARM specific subclass of TargetSubtarget. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef ARMSUBTARGET_H 15#define ARMSUBTARGET_H 16 17#include "llvm/Target/TargetInstrItineraries.h" 18#include "llvm/Target/TargetSubtarget.h" 19#include <string> 20 21namespace llvm { 22 23class ARMSubtarget : public TargetSubtarget { 24protected: 25 enum ARMArchEnum { 26 V4T, V5T, V5TE, V6, V6T2, V7A 27 }; 28 29 enum ARMFPEnum { 30 None, VFPv2, VFPv3, NEON 31 }; 32 33 enum ThumbTypeEnum { 34 Thumb1, 35 Thumb2 36 }; 37 38 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE, 39 /// V6, V6T2, V7A. 40 ARMArchEnum ARMArchVersion; 41 42 /// ARMFPUType - Floating Point Unit type. 43 ARMFPEnum ARMFPUType; 44 45 /// UseNEONForSinglePrecisionFP - if NEON is available use for FP 46 bool UseNEONForSinglePrecisionFP; 47 48 /// IsThumb - True if we are in thumb mode, false if in ARM mode. 49 bool IsThumb; 50 51 /// ThumbMode - Indicates supported Thumb version. 52 ThumbTypeEnum ThumbMode; 53 54 /// IsR9Reserved - True if R9 is a not available as general purpose register. 55 bool IsR9Reserved; 56 57 /// stackAlignment - The minimum alignment known to hold of the stack frame on 58 /// entry to the function and which must be maintained by every function. 59 unsigned stackAlignment; 60 61 /// CPUString - String name of used CPU. 62 std::string CPUString; 63 64 /// Selected instruction itineraries (one entry per itinerary class.) 65 InstrItineraryData InstrItins; 66 67 public: 68 enum { 69 isELF, isDarwin 70 } TargetType; 71 72 enum { 73 ARM_ABI_APCS, 74 ARM_ABI_AAPCS // ARM EABI 75 } TargetABI; 76 77 /// This constructor initializes the data members to match that 78 /// of the specified triple. 79 /// 80 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb); 81 82 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size 83 /// that still makes it profitable to inline the call. 84 unsigned getMaxInlineSizeThreshold() const { 85 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb. 86 // Change this once Thumb ldmia / stmia support is added. 87 return isThumb() ? 0 : 64; 88 } 89 /// ParseSubtargetFeatures - Parses features string setting specified 90 /// subtarget options. Definition of function is auto generated by tblgen. 91 std::string ParseSubtargetFeatures(const std::string &FS, 92 const std::string &CPU); 93 94 bool hasV4TOps() const { return ARMArchVersion >= V4T; } 95 bool hasV5TOps() const { return ARMArchVersion >= V5T; } 96 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; } 97 bool hasV6Ops() const { return ARMArchVersion >= V6; } 98 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; } 99 bool hasV7Ops() const { return ARMArchVersion >= V7A; } 100 101 bool hasVFP2() const { return ARMFPUType >= VFPv2; } 102 bool hasVFP3() const { return ARMFPUType >= VFPv3; } 103 bool hasNEON() const { return ARMFPUType >= NEON; } 104 bool useNEONForSinglePrecisionFP() const { 105 return hasNEON() && UseNEONForSinglePrecisionFP; } 106 107 bool isTargetDarwin() const { return TargetType == isDarwin; } 108 bool isTargetELF() const { return TargetType == isELF; } 109 110 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; } 111 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; } 112 113 bool isThumb() const { return IsThumb; } 114 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); } 115 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); } 116 bool hasThumb2() const { return ThumbMode >= Thumb2; } 117 118 bool isR9Reserved() const { return IsR9Reserved; } 119 120 const std::string & getCPUString() const { return CPUString; } 121 122 /// getInstrItins - Return the instruction itineraies based on subtarget 123 /// selection. 124 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } 125 126 /// getStackAlignment - Returns the minimum alignment known to hold of the 127 /// stack frame on entry to the function and which must be maintained by every 128 /// function for this subtarget. 129 unsigned getStackAlignment() const { return stackAlignment; } 130}; 131} // End llvm namespace 132 133#endif // ARMSUBTARGET_H 134