blob: 07040558d878ebec5c13603bd900fd2d284a5489 [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
17#include "llvm/Target/TargetSubtarget.h"
18#include <string>
19
20namespace llvm {
21class Module;
22
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
Anton Korobeynikove7540d62009-06-01 20:00:48 +000045 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
46 bool IsThumb;
47
48 /// ThumbMode - Indicates supported Thumb version.
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000049 ThumbTypeEnum ThumbMode;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050
51 /// UseThumbBacktraces - True if we use thumb style backtraces.
52 bool UseThumbBacktraces;
53
54 /// IsR9Reserved - True if R9 is a not available as general purpose register.
55 bool IsR9Reserved;
56
57 /// stackAlignment - The minimum alignment known to hold of the stack frame on
58 /// entry to the function and which must be maintained by every function.
59 unsigned stackAlignment;
60
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000061 /// CPUString - String name of used CPU.
62 std::string CPUString;
63
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064 public:
65 enum {
66 isELF, isDarwin
67 } TargetType;
68
69 enum {
70 ARM_ABI_APCS,
71 ARM_ABI_AAPCS // ARM EABI
72 } TargetABI;
73
74 /// This constructor initializes the data members to match that
75 /// of the specified module.
76 ///
Anton Korobeynikovf2e14752009-05-29 23:41:08 +000077 ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000078
Dan Gohmane8b391e2008-04-12 04:36:06 +000079 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
80 /// that still makes it profitable to inline the call.
Rafael Espindola948da402007-10-31 14:39:58 +000081 unsigned getMaxInlineSizeThreshold() const {
82 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
83 // Change this once Thumb ldmia / stmia support is added.
84 return isThumb() ? 0 : 64;
85 }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000086 /// ParseSubtargetFeatures - Parses features string setting specified
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +000088 std::string ParseSubtargetFeatures(const std::string &FS,
89 const std::string &CPU);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000091 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
92 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000093 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000094 bool hasV6Ops() const { return ARMArchVersion >= V6; }
Anton Korobeynikov48000e92009-06-08 21:20:36 +000095 bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; }
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000096 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097
Anton Korobeynikov1bf0f082009-05-23 19:51:43 +000098 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
99 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
100 bool hasNEON() const { return ARMFPUType >= NEON; }
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000101
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000102 bool isTargetDarwin() const { return TargetType == isDarwin; }
103 bool isTargetELF() const { return TargetType == isELF; }
104
105 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
106 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
107
Anton Korobeynikove7540d62009-06-01 20:00:48 +0000108 bool isThumb() const { return IsThumb; }
Anton Korobeynikov9f2fe502009-06-08 20:31:02 +0000109 bool isThumb1() const { return IsThumb && (ThumbMode == Thumb1); }
Anton Korobeynikove7540d62009-06-01 20:00:48 +0000110 bool isThumb2() const { return IsThumb && (ThumbMode >= Thumb2); }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111
112 bool useThumbBacktraces() const { return UseThumbBacktraces; }
113 bool isR9Reserved() const { return IsR9Reserved; }
114
Anton Korobeynikov7357d8f2009-05-23 19:50:50 +0000115 const std::string & getCPUString() const { return CPUString; }
116
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117 /// getStackAlignment - Returns the minimum alignment known to hold of the
118 /// stack frame on entry to the function and which must be maintained by every
119 /// function for this subtarget.
120 unsigned getStackAlignment() const { return stackAlignment; }
121};
122} // End llvm namespace
123
124#endif // ARMSUBTARGET_H