blob: c43924b53df5657615e59f56bdd4c3cb0bcfb2e1 [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 {
26 V4T, V5T, V5TE, V6
27 };
28
29 /// ARMArchVersion - ARM architecture vecrsion: V4T (base), V5T, V5TE,
30 /// and V6.
31 ARMArchEnum ARMArchVersion;
32
33 /// HasVFP2 - True if the processor supports Vector Floating Point (VFP) V2
34 /// instructions.
35 bool HasVFP2;
36
37 /// IsThumb - True if we are in thumb mode, false if in ARM mode.
38 bool IsThumb;
39
Evan Chenga8e29892007-01-19 07:51:42 +000040 /// UseThumbBacktraces - True if we use thumb style backtraces.
41 bool UseThumbBacktraces;
42
43 /// IsR9Reserved - True if R9 is a not available as general purpose register.
44 bool IsR9Reserved;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000045
Evan Chenga8e29892007-01-19 07:51:42 +000046 /// stackAlignment - The minimum alignment known to hold of the stack frame on
47 /// entry to the function and which must be maintained by every function.
48 unsigned stackAlignment;
49
50 public:
Evan Cheng1a3771e2007-01-19 19:22:40 +000051 enum {
52 isELF, isDarwin
53 } TargetType;
54
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000055 enum {
56 ARM_ABI_APCS,
57 ARM_ABI_AAPCS // ARM EABI
58 } TargetABI;
59
Evan Chenga8e29892007-01-19 07:51:42 +000060 /// This constructor initializes the data members to match that
61 /// of the specified module.
62 ///
Evan Cheng04321f72007-02-23 03:14:31 +000063 ARMSubtarget(const Module &M, const std::string &FS, bool thumb);
Evan Chenga8e29892007-01-19 07:51:42 +000064
Rafael Espindolae0703c82007-10-31 14:39:58 +000065 unsigned getMaxInlineSizeThreshold() const {
66 // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb.
67 // Change this once Thumb ldmia / stmia support is added.
68 return isThumb() ? 0 : 64;
69 }
Evan Chenga8e29892007-01-19 07:51:42 +000070 /// ParseSubtargetFeatures - Parses features string setting specified
71 /// subtarget options. Definition of function is auto generated by tblgen.
72 void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
73
74 bool hasV4TOps() const { return ARMArchVersion >= V4T; }
75 bool hasV5TOps() const { return ARMArchVersion >= V5T; }
76 bool hasV5TEOps() const { return ARMArchVersion >= V5TE; }
77 bool hasV6Ops() const { return ARMArchVersion >= V6; }
78
79 bool hasVFP2() const { return HasVFP2; }
80
Evan Cheng1a3771e2007-01-19 19:22:40 +000081 bool isTargetDarwin() const { return TargetType == isDarwin; }
82 bool isTargetELF() const { return TargetType == isELF; }
83
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +000084 bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
85 bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
86
Evan Chenga8e29892007-01-19 07:51:42 +000087 bool isThumb() const { return IsThumb; }
88
89 bool useThumbBacktraces() const { return UseThumbBacktraces; }
90 bool isR9Reserved() const { return IsR9Reserved; }
91
92 /// getStackAlignment - Returns the minimum alignment known to hold of the
93 /// stack frame on entry to the function and which must be maintained by every
94 /// function for this subtarget.
95 unsigned getStackAlignment() const { return stackAlignment; }
96};
97} // End llvm namespace
98
99#endif // ARMSUBTARGET_H