blob: 3d0e01e99b792e97f269460791cfc6480b997794 [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
68 /// stackAlignment - The minimum alignment known to hold of the stack frame on
69 /// entry to the function and which must be maintained by every function.
70 unsigned stackAlignment;
71
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000072 /// CPUString - String name of used CPU.
73 std::string CPUString;
74
Evan Cheng88e78d22009-06-19 01:51:50 +000075 /// Selected instruction itineraries (one entry per itinerary class.)
76 InstrItineraryData InstrItins;
Jim Grosbach770d7182009-08-11 15:33:49 +000077
Dan Gohmanf17a25c2007-07-18 16:29:46 +000078 public:
79 enum {
80 isELF, isDarwin
81 } TargetType;
82
83 enum {
84 ARM_ABI_APCS,
85 ARM_ABI_AAPCS // ARM EABI
86 } TargetABI;
87
88 /// This constructor initializes the data members to match that
Daniel Dunbarb711cf02009-08-02 22:11:08 +000089 /// of the specified triple.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090 ///
Daniel Dunbarb711cf02009-08-02 22:11:08 +000091 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092
Dan Gohmane8b391e2008-04-12 04:36:06 +000093 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
94 /// that still makes it profitable to inline the call.
Rafael Espindola948da402007-10-31 14:39:58 +000095 unsigned getMaxInlineSizeThreshold() const {
96 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
97 // Change this once Thumb ldmia / stmia support is added.
98 return isThumb() ? 0 : 64;
99 }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000100 /// ParseSubtargetFeatures - Parses features string setting specified
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000101 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000102 std::string ParseSubtargetFeatures(const std::string &FS,
103 const std::string &CPU);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000105 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
106 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000107 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000108 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Bob Wilsoneab41ba2009-06-25 16:03:07 +0000109 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000110 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000112 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
113 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
114 bool hasNEON() const { return ARMFPUType >= NEON; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000115 bool useNEONForSinglePrecisionFP() const {
David Goodwindd19ce42009-08-04 17:53:06 +0000116 return hasNEON() && UseNEONForSinglePrecisionFP; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000117
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118 bool isTargetDarwin() const { return TargetType == isDarwin; }
119 bool isTargetELF() const { return TargetType == isELF; }
120
121 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
122 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
123
Anton Korobeynikove7540d62009-06-01 20:00:48 +0000124 bool isThumb() const { return IsThumb; }
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000125 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
Evan Cheng86ae71d2009-07-06 22:29:14 +0000126 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
Evan Chengb1b2abc2009-07-02 06:38:40 +0000127 bool hasThumb2() const { return ThumbMode >= Thumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000128
Bob Wilson19194a22009-11-18 03:34:27 +0000129 bool hasBranchTargetBuffer() const { return HasBranchTargetBuffer; }
130
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000131 bool isR9Reserved() const { return IsR9Reserved; }
132
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000133 const std::string & getCPUString() const { return CPUString; }
David Goodwincf89a602009-09-30 00:10:16 +0000134
David Goodwin2a0ca3b2009-11-10 00:48:55 +0000135 /// enablePostRAScheduler - True at 'More' optimization.
David Goodwine56e4a62009-10-22 23:19:17 +0000136 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
David Goodwin526dd742009-11-10 00:15:47 +0000137 TargetSubtarget::AntiDepBreakMode& Mode,
David Goodwine6e30352009-11-13 19:52:48 +0000138 RegClassVector& CriticalPathRCs) const;
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000139
Jim Grosbach770d7182009-08-11 15:33:49 +0000140 /// getInstrItins - Return the instruction itineraies based on subtarget
Evan Cheng88e78d22009-06-19 01:51:50 +0000141 /// selection.
142 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
143
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144 /// getStackAlignment - Returns the minimum alignment known to hold of the
145 /// stack frame on entry to the function and which must be maintained by every
146 /// function for this subtarget.
147 unsigned getStackAlignment() const { return stackAlignment; }
Evan Chengc2999142009-08-28 23:18:09 +0000148
149 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
150 /// symbol.
Evan Chengba2cf3d2009-09-03 07:04:02 +0000151 bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152};
153} // End llvm namespace
154
155#endif // ARMSUBTARGET_H