blob: 60c3bd13ed7bbe6a63693a5302c9b244fe77f44e [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 {
22class Module;
23
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
Anton Korobeynikov70459be2009-06-01 20:00:48 +000046 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
47 bool IsThumb;
48
49 /// ThumbMode - Indicates supported Thumb version.
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000050 ThumbTypeEnum ThumbMode;
Evan Chenga8e29892007-01-19 07:51:42 +000051
Evan Chenga8e29892007-01-19 07:51:42 +000052 /// IsR9Reserved - True if R9 is a not available as general purpose register.
53 bool IsR9Reserved;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000054
Evan Chenga8e29892007-01-19 07:51:42 +000055 /// stackAlignment - The minimum alignment known to hold of the stack frame on
56 /// entry to the function and which must be maintained by every function.
57 unsigned stackAlignment;
58
Anton Korobeynikov41a02432009-05-23 19:50:50 +000059 /// CPUString - String name of used CPU.
60 std::string CPUString;
61
Evan Cheng8557c2b2009-06-19 01:51:50 +000062 /// Selected instruction itineraries (one entry per itinerary class.)
63 InstrItineraryData InstrItins;
64
Evan Chenga8e29892007-01-19 07:51:42 +000065 public:
Evan Cheng1a3771e2007-01-19 19:22:40 +000066 enum {
67 isELF, isDarwin
68 } TargetType;
69
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000070 enum {
71 ARM_ABI_APCS,
72 ARM_ABI_AAPCS // ARM EABI
73 } TargetABI;
74
Evan Chenga8e29892007-01-19 07:51:42 +000075 /// This constructor initializes the data members to match that
76 /// of the specified module.
77 ///
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000078 ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
Evan Chenga8e29892007-01-19 07:51:42 +000079
Dan Gohman707e0182008-04-12 04:36:06 +000080 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
81 /// that still makes it profitable to inline the call.
Rafael Espindolae0703c82007-10-31 14:39:58 +000082 unsigned getMaxInlineSizeThreshold() const {
83 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
84 // Change this once Thumb ldmia / stmia support is added.
85 return isThumb() ? 0 : 64;
86 }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000087 /// ParseSubtargetFeatures - Parses features string setting specified
Evan Chenga8e29892007-01-19 07:51:42 +000088 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov41a02432009-05-23 19:50:50 +000089 std::string ParseSubtargetFeatures(const std::string &FS,
90 const std::string &CPU);
Evan Chenga8e29892007-01-19 07:51:42 +000091
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000092 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
93 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Evan Chenga8e29892007-01-19 07:51:42 +000094 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000095 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Bob Wilsone481f122009-06-25 16:03:07 +000096 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000097 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Evan Chenga8e29892007-01-19 07:51:42 +000098
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000099 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
100 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
101 bool hasNEON() const { return ARMFPUType >= NEON; }
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000102
Evan Cheng1a3771e2007-01-19 19:22:40 +0000103 bool isTargetDarwin() const { return TargetType == isDarwin; }
104 bool isTargetELF() const { return TargetType == isELF; }
105
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000106 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
107 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
108
Anton Korobeynikov70459be2009-06-01 20:00:48 +0000109 bool isThumb() const { return IsThumb; }
Anton Korobeynikovbb629622009-06-15 21:46:20 +0000110 bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); }
Evan Cheng3147fb22009-07-06 22:29:14 +0000111 bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); }
Evan Chengd770d9e2009-07-02 06:38:40 +0000112 bool hasThumb2() const { return ThumbMode >= Thumb2; }
Evan Chenga8e29892007-01-19 07:51:42 +0000113
Evan Chenga8e29892007-01-19 07:51:42 +0000114 bool isR9Reserved() const { return IsR9Reserved; }
115
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000116 const std::string & getCPUString() const { return CPUString; }
117
Evan Cheng8557c2b2009-06-19 01:51:50 +0000118 /// getInstrItins - Return the instruction itineraies based on subtarget
119 /// selection.
120 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
121
Evan Chenga8e29892007-01-19 07:51:42 +0000122 /// getStackAlignment - Returns the minimum alignment known to hold of the
123 /// stack frame on entry to the function and which must be maintained by every
124 /// function for this subtarget.
125 unsigned getStackAlignment() const { return stackAlignment; }
126};
127} // End llvm namespace
128
129#endif // ARMSUBTARGET_H