Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 1 | //=====-- MipsSubtarget.h - Define Subtarget for the Mips -----*- 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. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file declares the Mips specific subclass of TargetSubtarget. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef MIPSSUBTARGET_H |
| 15 | #define MIPSSUBTARGET_H |
| 16 | |
| 17 | #include "llvm/Target/TargetSubtarget.h" |
| 18 | #include "llvm/Target/TargetMachine.h" |
| 19 | |
| 20 | #include <string> |
| 21 | |
| 22 | namespace llvm { |
| 23 | class Module; |
| 24 | |
| 25 | class MipsSubtarget : public TargetSubtarget { |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 26 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 27 | public: |
| 28 | enum MipsABIEnum { |
| 29 | O32, O64, N32, N64, EABI |
| 30 | }; |
| 31 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 32 | protected: |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 33 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 34 | enum MipsArchEnum { |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 35 | Mips1, Mips2, Mips3, Mips4, Mips32, Mips32r2, Mips64, Mips64r2 |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 38 | // Mips architecture version |
| 39 | MipsArchEnum MipsArchVersion; |
| 40 | |
| 41 | // Mips supported ABIs |
| 42 | MipsABIEnum MipsABI; |
| 43 | |
| 44 | // IsLittle - The target is Little Endian |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 45 | bool IsLittle; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 46 | |
| 47 | // IsSingleFloat - The target only supports single precision float |
| 48 | // point operations. This enable the target to use all 32 32-bit |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 49 | // floating point registers instead of only using even ones. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 50 | bool IsSingleFloat; |
| 51 | |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 52 | // IsFP64bit - The target processor has 64-bit floating point registers. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 53 | bool IsFP64bit; |
| 54 | |
| 55 | // IsFP64bit - General-purpose registers are 64 bits wide |
| 56 | bool IsGP64bit; |
| 57 | |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 58 | // HasVFPU - Processor has a vector floating point unit. |
| 59 | bool HasVFPU; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 60 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 61 | // IsABICall - Enable SRV4 code for SVR4-style dynamic objects |
| 62 | bool HasABICall; |
| 63 | |
| 64 | // HasAbsoluteCall - Enable code that is not fully position-independent. |
| 65 | // Only works with HasABICall enabled. |
| 66 | bool HasAbsoluteCall; |
| 67 | |
| 68 | // isLinux - Target system is Linux. Is false we consider ELFOS for now. |
| 69 | bool IsLinux; |
| 70 | |
Bruno Cardoso Lopes | 91fd532 | 2008-07-21 18:52:34 +0000 | [diff] [blame] | 71 | // Put global and static items less than or equal to SSectionThreshold |
| 72 | // bytes into the small data or bss section. The default is 8. |
| 73 | unsigned SSectionThreshold; |
| 74 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame^] | 75 | /// Features related to the presence of specific instructions. |
| 76 | |
| 77 | // HasSEInReg - SEB and SEH (signext in register) instructions. |
| 78 | bool HasSEInReg; |
| 79 | |
| 80 | // HasCondMov - Conditional mov (MOVZ, MOVN) instructions. |
| 81 | bool HasCondMov; |
| 82 | |
| 83 | // HasMulDivAdd - Multiply add and sub (MADD, MADDu, MSUB, MSUBu) |
| 84 | // instructions. |
| 85 | bool HasMulDivAdd; |
| 86 | |
| 87 | // HasMinMax - MIN and MAX instructions. |
| 88 | bool HasMinMax; |
| 89 | |
| 90 | // HasSwap - Byte and half swap instructions. |
| 91 | bool HasSwap; |
| 92 | |
| 93 | // HasBitCount - Count leading '1' and '0' bits. |
| 94 | bool HasBitCount; |
| 95 | |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 96 | InstrItineraryData InstrItins; |
| 97 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 98 | public: |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 99 | |
| 100 | /// Only O32 and EABI supported right now. |
| 101 | bool isABI_EABI() const { return MipsABI == EABI; } |
| 102 | bool isABI_O32() const { return MipsABI == O32; } |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 103 | unsigned getTargetABI() const { return MipsABI; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 104 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 105 | /// This constructor initializes the data members to match that |
| 106 | /// of the specified module. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 107 | MipsSubtarget(const TargetMachine &TM, const Module &M, |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 108 | const std::string &FS, bool little); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 109 | |
| 110 | /// ParseSubtargetFeatures - Parses features string setting specified |
| 111 | /// subtarget options. Definition of function is auto generated by tblgen. |
| 112 | void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); |
| 113 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 114 | bool hasMips2Ops() const { return MipsArchVersion >= Mips2; } |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 115 | |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 116 | bool isLittle() const { return IsLittle; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 117 | bool isFP64bit() const { return IsFP64bit; }; |
| 118 | bool isGP64bit() const { return IsGP64bit; }; |
| 119 | bool isGP32bit() const { return !IsGP64bit; }; |
| 120 | bool isSingleFloat() const { return IsSingleFloat; }; |
| 121 | bool isNotSingleFloat() const { return !IsSingleFloat; }; |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 122 | bool hasVFPU() const { return HasVFPU; }; |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 123 | bool hasABICall() const { return HasABICall; }; |
| 124 | bool hasAbsoluteCall() const { return HasAbsoluteCall; }; |
| 125 | bool isLinux() const { return IsLinux; }; |
Bruno Cardoso Lopes | 91fd532 | 2008-07-21 18:52:34 +0000 | [diff] [blame] | 126 | unsigned getSSectionThreshold() const { return SSectionThreshold; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 127 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame^] | 128 | /// Features related to the presence of specific instructions. |
| 129 | bool hasSEInReg() const { return HasSEInReg; }; |
| 130 | bool hasCondMov() const { return HasCondMov; }; |
| 131 | bool hasMulDivAdd() const { return HasMulDivAdd; }; |
| 132 | bool hasMinMax() const { return HasMinMax; }; |
| 133 | bool hasSwap() const { return HasSwap; }; |
| 134 | bool hasBitCount() const { return HasBitCount; }; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 135 | }; |
| 136 | } // End llvm namespace |
| 137 | |
| 138 | #endif |