Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1 | //=====---- ARMSubtarget.h - Define Subtarget for the ARM -----*- C++ -*--====// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 7 | // |
| 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 | |
| 20 | namespace llvm { |
| 21 | class Module; |
| 22 | |
| 23 | class ARMSubtarget : public TargetSubtarget { |
| 24 | protected: |
| 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 Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 40 | /// 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 Venancio | 3630e78 | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 45 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 46 | /// 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 | |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame^] | 50 | /// CPUString - String name of used CPU. |
| 51 | std::string CPUString; |
| 52 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 53 | public: |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 54 | enum { |
| 55 | isELF, isDarwin |
| 56 | } TargetType; |
| 57 | |
Lauro Ramos Venancio | 3630e78 | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 58 | enum { |
| 59 | ARM_ABI_APCS, |
| 60 | ARM_ABI_AAPCS // ARM EABI |
| 61 | } TargetABI; |
| 62 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 63 | /// This constructor initializes the data members to match that |
| 64 | /// of the specified module. |
| 65 | /// |
Evan Cheng | 04321f7 | 2007-02-23 03:14:31 +0000 | [diff] [blame] | 66 | ARMSubtarget(const Module &M, const std::string &FS, bool thumb); |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 67 | |
Dan Gohman | 707e018 | 2008-04-12 04:36:06 +0000 | [diff] [blame] | 68 | /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size |
| 69 | /// that still makes it profitable to inline the call. |
Rafael Espindola | e0703c8 | 2007-10-31 14:39:58 +0000 | [diff] [blame] | 70 | unsigned getMaxInlineSizeThreshold() const { |
| 71 | // FIXME: For now, we don't lower memcpy's to loads / stores for Thumb. |
| 72 | // Change this once Thumb ldmia / stmia support is added. |
| 73 | return isThumb() ? 0 : 64; |
| 74 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 75 | /// ParseSubtargetFeatures - Parses features string setting specified |
| 76 | /// subtarget options. Definition of function is auto generated by tblgen. |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame^] | 77 | std::string ParseSubtargetFeatures(const std::string &FS, |
| 78 | const std::string &CPU); |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 79 | |
| 80 | bool hasV4TOps() const { return ARMArchVersion >= V4T; } |
| 81 | bool hasV5TOps() const { return ARMArchVersion >= V5T; } |
| 82 | bool hasV5TEOps() const { return ARMArchVersion >= V5TE; } |
| 83 | bool hasV6Ops() const { return ARMArchVersion >= V6; } |
| 84 | |
| 85 | bool hasVFP2() const { return HasVFP2; } |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame^] | 86 | |
Evan Cheng | 1a3771e | 2007-01-19 19:22:40 +0000 | [diff] [blame] | 87 | bool isTargetDarwin() const { return TargetType == isDarwin; } |
| 88 | bool isTargetELF() const { return TargetType == isELF; } |
| 89 | |
Lauro Ramos Venancio | 3630e78 | 2007-02-13 19:52:28 +0000 | [diff] [blame] | 90 | bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; } |
| 91 | bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; } |
| 92 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 93 | bool isThumb() const { return IsThumb; } |
| 94 | |
| 95 | bool useThumbBacktraces() const { return UseThumbBacktraces; } |
| 96 | bool isR9Reserved() const { return IsR9Reserved; } |
| 97 | |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame^] | 98 | const std::string & getCPUString() const { return CPUString; } |
| 99 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 100 | /// getStackAlignment - Returns the minimum alignment known to hold of the |
| 101 | /// stack frame on entry to the function and which must be maintained by every |
| 102 | /// function for this subtarget. |
| 103 | unsigned getStackAlignment() const { return stackAlignment; } |
| 104 | }; |
| 105 | } // End llvm namespace |
| 106 | |
| 107 | #endif // ARMSUBTARGET_H |