blob: b56b55e200aff2fb7ce573a6c34a6be748e14573 [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"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018#include "llvm/Target/TargetSubtarget.h"
19#include <string>
20
21namespace llvm {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000022
23class ARMSubtarget : public TargetSubtarget {
24protected:
25 enum ARMArchEnum {
Anton Korobeynikov48000e92009-06-08 21:20:36 +000026 V4T, V5T, V5TE, V6, V6T2, V7A
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027 };
28
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000029 enum ARMFPEnum {
30 None, VFPv2, VFPv3, NEON
31 };
32
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000033 enum ThumbTypeEnum {
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000034 Thumb1,
35 Thumb2
36 };
37
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000038 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000039 /// V6, V6T2, V7A.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040 ARMArchEnum ARMArchVersion;
41
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000042 /// ARMFPUType - Floating Point Unit type.
43 ARMFPEnum ARMFPUType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044
David Goodwin8916f802009-08-05 16:01:19 +000045 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
46 /// specified. Use the method useNEONForSinglePrecisionFP() to
47 /// determine if NEON should actually be used.
David Goodwindd19ce42009-08-04 17:53:06 +000048 bool UseNEONForSinglePrecisionFP;
49
Anton Korobeynikove7540d62009-06-01 20:00:48 +000050 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
51 bool IsThumb;
52
53 /// ThumbMode - Indicates supported Thumb version.
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000054 ThumbTypeEnum ThumbMode;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056 /// IsR9Reserved - True if R9 is a not available as general purpose register.
57 bool IsR9Reserved;
58
59 /// stackAlignment - The minimum alignment known to hold of the stack frame on
60 /// entry to the function and which must be maintained by every function.
61 unsigned stackAlignment;
62
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000063 /// CPUString - String name of used CPU.
64 std::string CPUString;
65
Evan Cheng88e78d22009-06-19 01:51:50 +000066 /// Selected instruction itineraries (one entry per itinerary class.)
67 InstrItineraryData InstrItins;
68
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069 public:
70 enum {
71 isELF, isDarwin
72 } TargetType;
73
74 enum {
75 ARM_ABI_APCS,
76 ARM_ABI_AAPCS // ARM EABI
77 } TargetABI;
78
79 /// This constructor initializes the data members to match that
Daniel Dunbarb711cf02009-08-02 22:11:08 +000080 /// of the specified triple.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081 ///
Daniel Dunbarb711cf02009-08-02 22:11:08 +000082 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083
Dan Gohmane8b391e2008-04-12 04:36:06 +000084 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
85 /// that still makes it profitable to inline the call.
Rafael Espindola948da402007-10-31 14:39:58 +000086 unsigned getMaxInlineSizeThreshold() const {
87 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
88 // Change this once Thumb ldmia / stmia support is added.
89 return isThumb() ? 0 : 64;
90 }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000091 /// ParseSubtargetFeatures - Parses features string setting specified
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000093 std::string ParseSubtargetFeatures(const std::string &FS,
94 const std::string &CPU);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000096 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
97 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000099 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Bob Wilsoneab41ba2009-06-25 16:03:07 +0000100 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000101 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000102
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +0000103 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
104 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
105 bool hasNEON() const { return ARMFPUType >= NEON; }
David Goodwindd19ce42009-08-04 17:53:06 +0000106 bool useNEONForSinglePrecisionFP() const {
107 return hasNEON() && UseNEONForSinglePrecisionFP; }
108
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000109 bool isTargetDarwin() const { return TargetType == isDarwin; }
110 bool isTargetELF() const { return TargetType == isELF; }
111
112 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
113 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
114
Anton Korobeynikove7540d62009-06-01 20:00:48 +0000115 bool isThumb() const { return IsThumb; }
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000116 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
Evan Cheng86ae71d2009-07-06 22:29:14 +0000117 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
Evan Chengb1b2abc2009-07-02 06:38:40 +0000118 bool hasThumb2() const { return ThumbMode >= Thumb2; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000119
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120 bool isR9Reserved() const { return IsR9Reserved; }
121
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000122 const std::string & getCPUString() const { return CPUString; }
123
Evan Cheng88e78d22009-06-19 01:51:50 +0000124 /// getInstrItins - Return the instruction itineraies based on subtarget
125 /// selection.
126 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
127
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000128 /// getStackAlignment - Returns the minimum alignment known to hold of the
129 /// stack frame on entry to the function and which must be maintained by every
130 /// function for this subtarget.
131 unsigned getStackAlignment() const { return stackAlignment; }
132};
133} // End llvm namespace
134
135#endif // ARMSUBTARGET_H