1 //=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the ARM specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMSUBTARGET_H
15 #define ARMSUBTARGET_H
17 #include "llvm/Target/TargetInstrItineraries.h"
18 #include "llvm/Target/TargetMachine.h"
19 #include "llvm/Target/TargetSubtarget.h"
25 class ARMSubtarget
: public TargetSubtarget
{
28 V4T
, V5T
, V5TE
, V6
, V6T2
, V7A
32 None
, VFPv2
, VFPv3
, NEON
40 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
42 ARMArchEnum ARMArchVersion
;
44 /// ARMFPUType - Floating Point Unit type.
47 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
48 /// specified. Use the method useNEONForSinglePrecisionFP() to
49 /// determine if NEON should actually be used.
50 bool UseNEONForSinglePrecisionFP
;
52 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
55 /// ThumbMode - Indicates supported Thumb version.
56 ThumbTypeEnum ThumbMode
;
58 /// IsR9Reserved - True if R9 is a not available as general purpose register.
61 /// stackAlignment - The minimum alignment known to hold of the stack frame on
62 /// entry to the function and which must be maintained by every function.
63 unsigned stackAlignment
;
65 /// CPUString - String name of used CPU.
66 std::string CPUString
;
68 /// Selected instruction itineraries (one entry per itinerary class.)
69 InstrItineraryData InstrItins
;
78 ARM_ABI_AAPCS
// ARM EABI
81 /// This constructor initializes the data members to match that
82 /// of the specified triple.
84 ARMSubtarget(const std::string
&TT
, const std::string
&FS
, bool isThumb
);
86 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
87 /// that still makes it profitable to inline the call.
88 unsigned getMaxInlineSizeThreshold() const {
89 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
90 // Change this once Thumb ldmia / stmia support is added.
91 return isThumb() ? 0 : 64;
93 /// ParseSubtargetFeatures - Parses features string setting specified
94 /// subtarget options. Definition of function is auto generated by tblgen.
95 std::string
ParseSubtargetFeatures(const std::string
&FS
,
96 const std::string
&CPU
);
98 bool hasV4TOps() const { return ARMArchVersion
>= V4T
; }
99 bool hasV5TOps() const { return ARMArchVersion
>= V5T
; }
100 bool hasV5TEOps() const { return ARMArchVersion
>= V5TE
; }
101 bool hasV6Ops() const { return ARMArchVersion
>= V6
; }
102 bool hasV6T2Ops() const { return ARMArchVersion
>= V6T2
; }
103 bool hasV7Ops() const { return ARMArchVersion
>= V7A
; }
105 bool hasVFP2() const { return ARMFPUType
>= VFPv2
; }
106 bool hasVFP3() const { return ARMFPUType
>= VFPv3
; }
107 bool hasNEON() const { return ARMFPUType
>= NEON
; }
108 bool useNEONForSinglePrecisionFP() const {
109 return hasNEON() && UseNEONForSinglePrecisionFP
; }
111 bool isTargetDarwin() const { return TargetType
== isDarwin
; }
112 bool isTargetELF() const { return TargetType
== isELF
; }
114 bool isAPCS_ABI() const { return TargetABI
== ARM_ABI_APCS
; }
115 bool isAAPCS_ABI() const { return TargetABI
== ARM_ABI_AAPCS
; }
117 bool isThumb() const { return IsThumb
; }
118 bool isThumb1Only() const { return IsThumb
&& (ThumbMode
== Thumb1
); }
119 bool isThumb2() const { return IsThumb
&& (ThumbMode
== Thumb2
); }
120 bool hasThumb2() const { return ThumbMode
>= Thumb2
; }
122 bool isR9Reserved() const { return IsR9Reserved
; }
124 const std::string
& getCPUString() const { return CPUString
; }
126 /// getInstrItins - Return the instruction itineraies based on subtarget
128 const InstrItineraryData
&getInstrItineraryData() const { return InstrItins
; }
130 /// getStackAlignment - Returns the minimum alignment known to hold of the
131 /// stack frame on entry to the function and which must be maintained by every
132 /// function for this subtarget.
133 unsigned getStackAlignment() const { return stackAlignment
; }
135 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
137 bool GVIsIndirectSymbol(GlobalValue
*GV
, Reloc::Model RelocM
) const;
139 } // End llvm namespace
141 #endif // ARMSUBTARGET_H