blob: b2467b073b5b0f8b987c5308276d2b01cbd8d94b [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the ARM specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef ARMSUBTARGET_H
15#define ARMSUBTARGET_H
16
Evan Cheng88e78d22009-06-19 01:51:50 +000017#include "llvm/Target/TargetInstrItineraries.h"
Evan Chengba2cf3d2009-09-03 07:04:02 +000018#include "llvm/Target/TargetMachine.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019#include "llvm/Target/TargetSubtarget.h"
David Goodwin526dd742009-11-10 00:15:47 +000020#include "ARMBaseRegisterInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021#include <string>
22
23namespace llvm {
Evan Chengc2999142009-08-28 23:18:09 +000024class GlobalValue;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025
26class ARMSubtarget : public TargetSubtarget {
27protected:
28 enum ARMArchEnum {
Anton Korobeynikov48000e92009-06-08 21:20:36 +000029 V4T, V5T, V5TE, V6, V6T2, V7A
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030 };
31
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000032 enum ARMFPEnum {
33 None, VFPv2, VFPv3, NEON
34 };
35
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000036 enum ThumbTypeEnum {
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000037 Thumb1,
38 Thumb2
39 };
40
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000041 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000042 /// V6, V6T2, V7A.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043 ARMArchEnum ARMArchVersion;
44
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000045 /// ARMFPUType - Floating Point Unit type.
46 ARMFPEnum ARMFPUType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047
David Goodwin8916f802009-08-05 16:01:19 +000048 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
49 /// specified. Use the method useNEONForSinglePrecisionFP() to
50 /// determine if NEON should actually be used.
David Goodwindd19ce42009-08-04 17:53:06 +000051 bool UseNEONForSinglePrecisionFP;
52
Bob Wilson19194a22009-11-18 03:34:27 +000053 /// HasBranchTargetBuffer - True if processor can predict indirect branches.
54 bool HasBranchTargetBuffer;
55
Anton Korobeynikove7540d62009-06-01 20:00:48 +000056 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
57 bool IsThumb;
58
59 /// ThumbMode - Indicates supported Thumb version.
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000060 ThumbTypeEnum ThumbMode;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061
David Goodwincf89a602009-09-30 00:10:16 +000062 /// PostRAScheduler - True if using post-register-allocation scheduler.
63 bool PostRAScheduler;
64
Dan Gohmanf17a25c2007-07-18 16:29:46 +000065 /// IsR9Reserved - True if R9 is a not available as general purpose register.
66 bool IsR9Reserved;
67
Anton Korobeynikova414f362009-11-24 00:44:37 +000068 /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit
69 /// imms (including global addresses).
70 bool UseMovt;
71
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072 /// stackAlignment - The minimum alignment known to hold of the stack frame on
73 /// entry to the function and which must be maintained by every function.
74 unsigned stackAlignment;
75
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000076 /// CPUString - String name of used CPU.
77 std::string CPUString;
78
Evan Cheng88e78d22009-06-19 01:51:50 +000079 /// Selected instruction itineraries (one entry per itinerary class.)
80 InstrItineraryData InstrItins;
Jim Grosbach770d7182009-08-11 15:33:49 +000081
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082 public:
83 enum {
84 isELF, isDarwin
85 } TargetType;
86
87 enum {
88 ARM_ABI_APCS,
89 ARM_ABI_AAPCS // ARM EABI
90 } TargetABI;
91
92 /// This constructor initializes the data members to match that
Daniel Dunbarb711cf02009-08-02 22:11:08 +000093 /// of the specified triple.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094 ///
Daniel Dunbarb711cf02009-08-02 22:11:08 +000095 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000096
Dan Gohmane8b391e2008-04-12 04:36:06 +000097 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
98 /// that still makes it profitable to inline the call.
Rafael Espindola948da402007-10-31 14:39:58 +000099 unsigned getMaxInlineSizeThreshold() const {
100 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
101 // Change this once Thumb ldmia / stmia support is added.
102 return isThumb() ? 0 : 64;
103 }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000104 /// ParseSubtargetFeatures - Parses features string setting specified
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000105 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000106 std::string ParseSubtargetFeatures(const std::string &FS,
107 const std::string &CPU);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000109 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
110 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000112 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Bob Wilsoneab41ba2009-06-25 16:03:07 +0000113 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000114 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000116 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
117 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
118 bool hasNEON() const { return ARMFPUType >= NEON; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000119 bool useNEONForSinglePrecisionFP() const {
David Goodwindd19ce42009-08-04 17:53:06 +0000120 return hasNEON() && UseNEONForSinglePrecisionFP; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000121
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122 bool isTargetDarwin() const { return TargetType == isDarwin; }
123 bool isTargetELF() const { return TargetType == isELF; }
124
125 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
126 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
127
Anton Korobeynikove7540d62009-06-01 20:00:48 +0000128 bool isThumb() const { return IsThumb; }
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000129 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
Evan Cheng86ae71d2009-07-06 22:29:14 +0000130 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
Evan Chengb1b2abc2009-07-02 06:38:40 +0000131 bool hasThumb2() const { return ThumbMode >= Thumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132
Bob Wilson19194a22009-11-18 03:34:27 +0000133 bool hasBranchTargetBuffer() const { return HasBranchTargetBuffer; }
134
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135 bool isR9Reserved() const { return IsR9Reserved; }
136
Anton Korobeynikova414f362009-11-24 00:44:37 +0000137 bool useMovt() const { return UseMovt && hasV6T2Ops(); }
138
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000139 const std::string & getCPUString() const { return CPUString; }
Anton Korobeynikova414f362009-11-24 00:44:37 +0000140
David Goodwin2a0ca3b2009-11-10 00:48:55 +0000141 /// enablePostRAScheduler - True at 'More' optimization.
David Goodwine56e4a62009-10-22 23:19:17 +0000142 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
David Goodwin526dd742009-11-10 00:15:47 +0000143 TargetSubtarget::AntiDepBreakMode& Mode,
David Goodwine6e30352009-11-13 19:52:48 +0000144 RegClassVector& CriticalPathRCs) const;
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000145
Jim Grosbach770d7182009-08-11 15:33:49 +0000146 /// getInstrItins - Return the instruction itineraies based on subtarget
Evan Cheng88e78d22009-06-19 01:51:50 +0000147 /// selection.
148 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
149
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150 /// getStackAlignment - Returns the minimum alignment known to hold of the
151 /// stack frame on entry to the function and which must be maintained by every
152 /// function for this subtarget.
153 unsigned getStackAlignment() const { return stackAlignment; }
Evan Chengc2999142009-08-28 23:18:09 +0000154
155 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
156 /// symbol.
Evan Chengba2cf3d2009-09-03 07:04:02 +0000157 bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158};
159} // End llvm namespace
160
161#endif // ARMSUBTARGET_H