blob: 518967b924302bf0c7fd3ffd637c36c0c94bb66c [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
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058 /// IsR9Reserved - True if R9 is a not available as general purpose register.
59 bool IsR9Reserved;
60
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;
64
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000065 /// CPUString - String name of used CPU.
66 std::string CPUString;
67
Evan Cheng88e78d22009-06-19 01:51:50 +000068 /// Selected instruction itineraries (one entry per itinerary class.)
69 InstrItineraryData InstrItins;
Jim Grosbach770d7182009-08-11 15:33:49 +000070
Dan Gohmanf17a25c2007-07-18 16:29:46 +000071 public:
72 enum {
73 isELF, isDarwin
74 } TargetType;
75
76 enum {
77 ARM_ABI_APCS,
78 ARM_ABI_AAPCS // ARM EABI
79 } TargetABI;
80
81 /// This constructor initializes the data members to match that
Daniel Dunbarb711cf02009-08-02 22:11:08 +000082 /// of the specified triple.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083 ///
Daniel Dunbarb711cf02009-08-02 22:11:08 +000084 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085
Dan Gohmane8b391e2008-04-12 04:36:06 +000086 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
87 /// that still makes it profitable to inline the call.
Rafael Espindola948da402007-10-31 14:39:58 +000088 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;
92 }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000093 /// ParseSubtargetFeatures - Parses features string setting specified
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000095 std::string ParseSubtargetFeatures(const std::string &FS,
96 const std::string &CPU);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000098 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
99 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000101 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Bob Wilsoneab41ba2009-06-25 16:03:07 +0000102 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000103 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000105 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
106 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
107 bool hasNEON() const { return ARMFPUType >= NEON; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000108 bool useNEONForSinglePrecisionFP() const {
David Goodwindd19ce42009-08-04 17:53:06 +0000109 return hasNEON() && UseNEONForSinglePrecisionFP; }
Jim Grosbach770d7182009-08-11 15:33:49 +0000110
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111 bool isTargetDarwin() const { return TargetType == isDarwin; }
112 bool isTargetELF() const { return TargetType == isELF; }
113
114 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
115 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
116
Anton Korobeynikove7540d62009-06-01 20:00:48 +0000117 bool isThumb() const { return IsThumb; }
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000118 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
Evan Cheng86ae71d2009-07-06 22:29:14 +0000119 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
Evan Chengb1b2abc2009-07-02 06:38:40 +0000120 bool hasThumb2() const { return ThumbMode >= Thumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000121
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122 bool isR9Reserved() const { return IsR9Reserved; }
123
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000124 const std::string & getCPUString() const { return CPUString; }
125
Jim Grosbach770d7182009-08-11 15:33:49 +0000126 /// getInstrItins - Return the instruction itineraies based on subtarget
Evan Cheng88e78d22009-06-19 01:51:50 +0000127 /// selection.
128 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
129
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130 /// 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; }
Evan Chengc2999142009-08-28 23:18:09 +0000134
135 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
136 /// symbol.
Evan Chengba2cf3d2009-09-03 07:04:02 +0000137 bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) const;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138};
139} // End llvm namespace
140
141#endif // ARMSUBTARGET_H