blob: fcf3490e15fe1320d09effb2bebae5f02f99e9f9 [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
17#include "llvm/Target/TargetSubtarget.h"
18#include <string>
19
20namespace llvm {
21class Module;
22
23class ARMSubtarget : public TargetSubtarget {
24protected:
25 enum ARMArchEnum {
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000026 V4T, V5T, V5TE, V6, V7A
Evan Chenga8e29892007-01-19 07:51:42 +000027 };
28
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000029 enum ARMFPEnum {
30 None, VFPv2, VFPv3, NEON
31 };
32
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000033 enum ThumbTypeEnum {
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000034 Thumb1,
35 Thumb2
36 };
37
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000038 /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE,
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000039 /// V6, V6T2, V7A.
Evan Chenga8e29892007-01-19 07:51:42 +000040 ARMArchEnum ARMArchVersion;
41
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000042 /// ARMFPUType - Floating Point Unit type.
43 ARMFPEnum ARMFPUType;
Evan Chenga8e29892007-01-19 07:51:42 +000044
Anton Korobeynikov70459be2009-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 Korobeynikovd4022c32009-05-29 23:41:08 +000049 ThumbTypeEnum ThumbMode;
Evan Chenga8e29892007-01-19 07:51:42 +000050
Evan Chenga8e29892007-01-19 07:51:42 +000051 /// 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;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000056
Evan Chenga8e29892007-01-19 07:51:42 +000057 /// 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 Korobeynikov41a02432009-05-23 19:50:50 +000061 /// CPUString - String name of used CPU.
62 std::string CPUString;
63
Evan Chenga8e29892007-01-19 07:51:42 +000064 public:
Evan Cheng1a3771e2007-01-19 19:22:40 +000065 enum {
66 isELF, isDarwin
67 } TargetType;
68
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000069 enum {
70 ARM_ABI_APCS,
71 ARM_ABI_AAPCS // ARM EABI
72 } TargetABI;
73
Evan Chenga8e29892007-01-19 07:51:42 +000074 /// This constructor initializes the data members to match that
75 /// of the specified module.
76 ///
Anton Korobeynikovd4022c32009-05-29 23:41:08 +000077 ARMSubtarget(const Module &M, const std::string &FS, bool isThumb);
Evan Chenga8e29892007-01-19 07:51:42 +000078
Dan Gohman707e0182008-04-12 04:36:06 +000079 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
80 /// that still makes it profitable to inline the call.
Rafael Espindolae0703c82007-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 Korobeynikov6d7d2aa2009-05-23 19:51:43 +000086 /// ParseSubtargetFeatures - Parses features string setting specified
Evan Chenga8e29892007-01-19 07:51:42 +000087 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov41a02432009-05-23 19:50:50 +000088 std::string ParseSubtargetFeatures(const std::string &FS,
89 const std::string &CPU);
Evan Chenga8e29892007-01-19 07:51:42 +000090
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000091 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
92 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
Evan Chenga8e29892007-01-19 07:51:42 +000093 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000094 bool hasV6Ops() const { return ARMArchVersion >= V6; }
95 bool hasV7Ops() const { return ARMArchVersion >= V7A; }
Evan Chenga8e29892007-01-19 07:51:42 +000096
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +000097 bool hasVFP2() const { return ARMFPUType >= VFPv2; }
98 bool hasVFP3() const { return ARMFPUType >= VFPv3; }
99 bool hasNEON() const { return ARMFPUType >= NEON; }
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000100
Evan Cheng1a3771e2007-01-19 19:22:40 +0000101 bool isTargetDarwin() const { return TargetType == isDarwin; }
102 bool isTargetELF() const { return TargetType == isELF; }
103
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000104 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
105 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
106
Anton Korobeynikov70459be2009-06-01 20:00:48 +0000107 bool isThumb() const { return IsThumb; }
Anton Korobeynikova7b0ded2009-06-08 20:31:02 +0000108 bool isThumb1() const { return IsThumb && (ThumbMode == Thumb1); }
Anton Korobeynikov70459be2009-06-01 20:00:48 +0000109 bool isThumb2() const { return IsThumb && (ThumbMode >= Thumb2); }
Evan Chenga8e29892007-01-19 07:51:42 +0000110
111 bool useThumbBacktraces() const { return UseThumbBacktraces; }
112 bool isR9Reserved() const { return IsR9Reserved; }
113
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000114 const std::string & getCPUString() const { return CPUString; }
115
Evan Chenga8e29892007-01-19 07:51:42 +0000116 /// getStackAlignment - Returns the minimum alignment known to hold of the
117 /// stack frame on entry to the function and which must be maintained by every
118 /// function for this subtarget.
119 unsigned getStackAlignment() const { return stackAlignment; }
120};
121} // End llvm namespace
122
123#endif // ARMSUBTARGET_H