blob: e721a7fd68049adf5cdeb3a7b1bbe52ec0b2d125 [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"
20#include <string>
21
22namespace llvm {
Evan Chengc2999142009-08-28 23:18:09 +000023class GlobalValue;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024
25class ARMSubtarget : public TargetSubtarget {
26protected:
27 enum ARMArchEnum {
Anton Korobeynikov48000e92009-06-08 21:20:36 +000028 V4T, V5T, V5TE, V6, V6T2, V7A
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029 };
30
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000031 enum ARMFPEnum {
32 None, VFPv2, VFPv3, NEON
33 };
34
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000035 enum ThumbTypeEnum {
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000036 Thumb1,
37 Thumb2
38 };
39
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000040 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000041 /// V6, V6T2, V7A.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000042 ARMArchEnum ARMArchVersion;
43
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000044 /// ARMFPUType - Floating Point Unit type.
45 ARMFPEnum ARMFPUType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046
David Goodwin8916f802009-08-05 16:01:19 +000047 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
48 /// specified. Use the method useNEONForSinglePrecisionFP() to
49 /// determine if NEON should actually be used.
David Goodwindd19ce42009-08-04 17:53:06 +000050 bool UseNEONForSinglePrecisionFP;
51
Anton Korobeynikove7540d62009-06-01 20:00:48 +000052 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
53 bool IsThumb;
54
55 /// ThumbMode - Indicates supported Thumb version.
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000056 ThumbTypeEnum ThumbMode;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
David Goodwincf89a602009-09-30 00:10:16 +000058 /// PostRAScheduler - True if using post-register-allocation scheduler.
59 bool PostRAScheduler;
60
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 /// IsR9Reserved - True if R9 is a not available as general purpose register.
62 bool IsR9Reserved;
63
64 /// stackAlignment - The minimum alignment known to hold of the stack frame on
65 /// entry to the function and which must be maintained by every function.
66 unsigned stackAlignment;
67
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000068 /// CPUString - String name of used CPU.
69 std::string CPUString;
70
Evan Cheng88e78d22009-06-19 01:51:50 +000071 /// Selected instruction itineraries (one entry per itinerary class.)
72 InstrItineraryData InstrItins;
Jim Grosbach770d7182009-08-11 15:33:49 +000073
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074 public:
75 enum {
76 isELF, isDarwin
77 } TargetType;
78
79 enum {
80 ARM_ABI_APCS,
81 ARM_ABI_AAPCS // ARM EABI
82 } TargetABI;
83
84 /// This constructor initializes the data members to match that
Daniel Dunbarb711cf02009-08-02 22:11:08 +000085 /// of the specified triple.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086 ///
Daniel Dunbarb711cf02009-08-02 22:11:08 +000087 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000088
Dan Gohmane8b391e2008-04-12 04:36:06 +000089 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
90 /// that still makes it profitable to inline the call.
Rafael Espindola948da402007-10-31 14:39:58 +000091 unsigned getMaxInlineSizeThreshold() const {
92 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
93 // Change this once Thumb ldmia / stmia support is added.
94 return isThumb() ? 0 : 64;
95 }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000096 /// ParseSubtargetFeatures - Parses features string setting specified
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000098 std::string ParseSubtargetFeatures(const std::string &FS,
99 const std::string &CPU);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000101 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
102 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000103 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000104 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Bob Wilsoneab41ba2009-06-25 16:03:07 +0000105 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000106 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000107
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000108 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
109 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
110 bool hasNEON() const { return ARMFPUType >= NEON; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000111 bool useNEONForSinglePrecisionFP() const {
David Goodwindd19ce42009-08-04 17:53:06 +0000112 return hasNEON() && UseNEONForSinglePrecisionFP; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000113
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114 bool isTargetDarwin() const { return TargetType == isDarwin; }
115 bool isTargetELF() const { return TargetType == isELF; }
116
117 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
118 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
119
Anton Korobeynikove7540d62009-06-01 20:00:48 +0000120 bool isThumb() const { return IsThumb; }
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000121 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
Evan Cheng86ae71d2009-07-06 22:29:14 +0000122 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
Evan Chengb1b2abc2009-07-02 06:38:40 +0000123 bool hasThumb2() const { return ThumbMode >= Thumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000124
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125 bool isR9Reserved() const { return IsR9Reserved; }
126
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000127 const std::string & getCPUString() const { return CPUString; }
David Goodwincf89a602009-09-30 00:10:16 +0000128
Evan Cheng86e24b02009-10-16 21:06:15 +0000129 /// enablePostRAScheduler - True at 'More' optimization except
130 /// for Thumb1.
David Goodwine56e4a62009-10-22 23:19:17 +0000131 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
132 TargetSubtarget::AntiDepBreakMode& mode) const {
David Goodwinad5789c2009-10-26 16:59:04 +0000133 mode = TargetSubtarget::ANTIDEP_CRITICAL;
Evan Cheng86e24b02009-10-16 21:06:15 +0000134 return PostRAScheduler && OptLevel >= CodeGenOpt::Default;
135 }
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000136
Jim Grosbach770d7182009-08-11 15:33:49 +0000137 /// getInstrItins - Return the instruction itineraies based on subtarget
Evan Cheng88e78d22009-06-19 01:51:50 +0000138 /// selection.
139 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
140
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141 /// getStackAlignment - Returns the minimum alignment known to hold of the
142 /// stack frame on entry to the function and which must be maintained by every
143 /// function for this subtarget.
144 unsigned getStackAlignment() const { return stackAlignment; }
Evan Chengc2999142009-08-28 23:18:09 +0000145
146 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
147 /// symbol.
Evan Chengba2cf3d2009-09-03 07:04:02 +0000148 bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149};
150} // End llvm namespace
151
152#endif // ARMSUBTARGET_H