blob: 73f9736188dac852b47bd3a37a232702660a83a8 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +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 Cheng8557c2b2009-06-19 01:51:50 +000017#include "llvm/Target/TargetInstrItineraries.h"
Evan Chenga8e29892007-01-19 07:51:42 +000018#include "llvm/Target/TargetSubtarget.h"
19#include <string>
20
21namespace llvm {
Evan Chenge4e4ed32009-08-28 23:18:09 +000022class GlobalValue;
Evan Chenga8e29892007-01-19 07:51:42 +000023
24class ARMSubtarget : public TargetSubtarget {
25protected:
26 enum ARMArchEnum {
Anton Korobeynikovfbbf1ee2009-06-08 21:20:36 +000027 V4T, V5T, V5TE, V6, V6T2, V7A
Evan Chenga8e29892007-01-19 07:51:42 +000028 };
29
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000030 enum ARMFPEnum {
31 None, VFPv2, VFPv3, NEON
32 };
33
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000034 enum ThumbTypeEnum {
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000035 Thumb1,
36 Thumb2
37 };
38
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000039 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000040 /// V6, V6T2, V7A.
Evan Chenga8e29892007-01-19 07:51:42 +000041 ARMArchEnum ARMArchVersion;
42
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000043 /// ARMFPUType - Floating Point Unit type.
44 ARMFPEnum ARMFPUType;
Evan Chenga8e29892007-01-19 07:51:42 +000045
David Goodwin1f0e4042009-08-05 16:01:19 +000046 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
47 /// specified. Use the method useNEONForSinglePrecisionFP() to
48 /// determine if NEON should actually be used.
David Goodwin42a83f22009-08-04 17:53:06 +000049 bool UseNEONForSinglePrecisionFP;
50
Anton Korobeynikov70459be2009-06-01 20:00:48 +000051 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
52 bool IsThumb;
53
54 /// ThumbMode - Indicates supported Thumb version.
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000055 ThumbTypeEnum ThumbMode;
Evan Chenga8e29892007-01-19 07:51:42 +000056
Evan Chenga8e29892007-01-19 07:51:42 +000057 /// IsR9Reserved - True if R9 is a not available as general purpose register.
58 bool IsR9Reserved;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000059
Evan Chenga8e29892007-01-19 07:51:42 +000060 /// stackAlignment - The minimum alignment known to hold of the stack frame on
61 /// entry to the function and which must be maintained by every function.
62 unsigned stackAlignment;
63
Anton Korobeynikov41a02432009-05-23 19:50:50 +000064 /// CPUString - String name of used CPU.
65 std::string CPUString;
66
Evan Cheng8557c2b2009-06-19 01:51:50 +000067 /// Selected instruction itineraries (one entry per itinerary class.)
68 InstrItineraryData InstrItins;
Jim Grosbach764ab522009-08-11 15:33:49 +000069
Evan Chenga8e29892007-01-19 07:51:42 +000070 public:
Evan Cheng1a3771e2007-01-19 19:22:40 +000071 enum {
72 isELF, isDarwin
73 } TargetType;
74
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000075 enum {
76 ARM_ABI_APCS,
77 ARM_ABI_AAPCS // ARM EABI
78 } TargetABI;
79
Evan Chenga8e29892007-01-19 07:51:42 +000080 /// This constructor initializes the data members to match that
Daniel Dunbar3be03402009-08-02 22:11:08 +000081 /// of the specified triple.
Evan Chenga8e29892007-01-19 07:51:42 +000082 ///
Daniel Dunbar3be03402009-08-02 22:11:08 +000083 ARMSubtarget(const std::string &TT, const std::string &FS, bool isThumb);
Evan Chenga8e29892007-01-19 07:51:42 +000084
Dan Gohman707e0182008-04-12 04:36:06 +000085 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
86 /// that still makes it profitable to inline the call.
Rafael Espindolae0703c82007-10-31 14:39:58 +000087 unsigned getMaxInlineSizeThreshold() const {
88 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
89 // Change this once Thumb ldmia / stmia support is added.
90 return isThumb() ? 0 : 64;
91 }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000092 /// ParseSubtargetFeatures - Parses features string setting specified
Evan Chenga8e29892007-01-19 07:51:42 +000093 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov41a02432009-05-23 19:50:50 +000094 std::string ParseSubtargetFeatures(const std::string &FS,
95 const std::string &CPU);
Evan Chenga8e29892007-01-19 07:51:42 +000096
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000097 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
98 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Evan Chenga8e29892007-01-19 07:51:42 +000099 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +0000100 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Bob Wilsone481f122009-06-25 16:03:07 +0000101 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +0000102 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Evan Chenga8e29892007-01-19 07:51:42 +0000103
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +0000104 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
105 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
106 bool hasNEON() const { return ARMFPUType >= NEON; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000107 bool useNEONForSinglePrecisionFP() const {
David Goodwin42a83f22009-08-04 17:53:06 +0000108 return hasNEON() && UseNEONForSinglePrecisionFP; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000109
Evan Cheng1a3771e2007-01-19 19:22:40 +0000110 bool isTargetDarwin() const { return TargetType == isDarwin; }
111 bool isTargetELF() const { return TargetType == isELF; }
112
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000113 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
114 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
115
Anton Korobeynikov70459be2009-06-01 20:00:48 +0000116 bool isThumb() const { return IsThumb; }
Anton Korobeynikovbb629622009-06-15 21:46:20 +0000117 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
Evan Cheng3147fb22009-07-06 22:29:14 +0000118 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
Evan Chengd770d9e2009-07-02 06:38:40 +0000119 bool hasThumb2() const { return ThumbMode >= Thumb2; }
Evan Chenga8e29892007-01-19 07:51:42 +0000120
Evan Chenga8e29892007-01-19 07:51:42 +0000121 bool isR9Reserved() const { return IsR9Reserved; }
122
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000123 const std::string & getCPUString() const { return CPUString; }
124
Jim Grosbach764ab522009-08-11 15:33:49 +0000125 /// getInstrItins - Return the instruction itineraies based on subtarget
Evan Cheng8557c2b2009-06-19 01:51:50 +0000126 /// selection.
127 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
128
Evan Chenga8e29892007-01-19 07:51:42 +0000129 /// getStackAlignment - Returns the minimum alignment known to hold of the
130 /// stack frame on entry to the function and which must be maintained by every
131 /// function for this subtarget.
132 unsigned getStackAlignment() const { return stackAlignment; }
Evan Chenge4e4ed32009-08-28 23:18:09 +0000133
134 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
135 /// symbol.
136 bool GVIsIndirectSymbol(GlobalValue *GV, bool isStatic) const;
Evan Chenga8e29892007-01-19 07:51:42 +0000137};
138} // End llvm namespace
139
140#endif // ARMSUBTARGET_H