Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 1 | //=====-- MipsSubtarget.h - Define Subtarget for the Mips -----*- C++ -*--====// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 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 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file declares the Mips specific subclass of TargetSubtarget. |
| 11 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 13 | |
| 14 | #ifndef MIPSSUBTARGET_H |
| 15 | #define MIPSSUBTARGET_H |
| 16 | |
| 17 | #include "llvm/Target/TargetSubtarget.h" |
Evan Cheng | ab8be96 | 2011-06-29 01:14:12 +0000 | [diff] [blame^] | 18 | #include "llvm/MC/MCInstrItineraries.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 19 | #include <string> |
| 20 | |
| 21 | namespace llvm { |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 22 | |
| 23 | class MipsSubtarget : public TargetSubtarget { |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 24 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 25 | public: |
| 26 | enum MipsABIEnum { |
| 27 | O32, O64, N32, N64, EABI |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 28 | }; |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 29 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 30 | protected: |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 31 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 32 | enum MipsArchEnum { |
Bruno Cardoso Lopes | 7d5652d | 2010-11-12 00:38:32 +0000 | [diff] [blame] | 33 | Mips1, Mips2, Mips3, Mips4, Mips32, Mips32r2 |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 36 | // Mips architecture version |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 37 | MipsArchEnum MipsArchVersion; |
| 38 | |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 39 | // Mips supported ABIs |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 40 | MipsABIEnum MipsABI; |
| 41 | |
| 42 | // IsLittle - The target is Little Endian |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 43 | bool IsLittle; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 44 | |
| 45 | // IsSingleFloat - The target only supports single precision float |
| 46 | // 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] | 47 | // floating point registers instead of only using even ones. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 48 | bool IsSingleFloat; |
| 49 | |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 50 | // IsFP64bit - The target processor has 64-bit floating point registers. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 51 | bool IsFP64bit; |
| 52 | |
| 53 | // IsFP64bit - General-purpose registers are 64 bits wide |
| 54 | bool IsGP64bit; |
| 55 | |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 56 | // HasVFPU - Processor has a vector floating point unit. |
| 57 | bool HasVFPU; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 58 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 59 | // isLinux - Target system is Linux. Is false we consider ELFOS for now. |
| 60 | bool IsLinux; |
| 61 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 62 | /// Features related to the presence of specific instructions. |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 63 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 64 | // HasSEInReg - SEB and SEH (signext in register) instructions. |
| 65 | bool HasSEInReg; |
| 66 | |
| 67 | // HasCondMov - Conditional mov (MOVZ, MOVN) instructions. |
| 68 | bool HasCondMov; |
| 69 | |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 70 | // HasMulDivAdd - Multiply add and sub (MADD, MADDu, MSUB, MSUBu) |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 71 | // instructions. |
| 72 | bool HasMulDivAdd; |
| 73 | |
| 74 | // HasMinMax - MIN and MAX instructions. |
| 75 | bool HasMinMax; |
| 76 | |
| 77 | // HasSwap - Byte and half swap instructions. |
| 78 | bool HasSwap; |
| 79 | |
| 80 | // HasBitCount - Count leading '1' and '0' bits. |
| 81 | bool HasBitCount; |
| 82 | |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 83 | InstrItineraryData InstrItins; |
| 84 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 85 | public: |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 86 | |
| 87 | /// Only O32 and EABI supported right now. |
| 88 | bool isABI_EABI() const { return MipsABI == EABI; } |
| 89 | bool isABI_O32() const { return MipsABI == O32; } |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 90 | unsigned getTargetABI() const { return MipsABI; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 91 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 92 | /// This constructor initializes the data members to match that |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 93 | /// of the specified triple. |
Eli Friedman | e2c7408 | 2009-08-03 02:22:28 +0000 | [diff] [blame] | 94 | MipsSubtarget(const std::string &TT, const std::string &FS, bool little); |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 95 | |
| 96 | /// ParseSubtargetFeatures - Parses features string setting specified |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 97 | /// subtarget options. Definition of function is auto generated by tblgen. |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame] | 98 | std::string ParseSubtargetFeatures(const std::string &FS, |
| 99 | const std::string &CPU); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 100 | |
Bruno Cardoso Lopes | d3bdf19 | 2009-05-27 17:23:44 +0000 | [diff] [blame] | 101 | bool isMips1() const { return MipsArchVersion == Mips1; } |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 102 | bool isMips32() const { return MipsArchVersion >= Mips32; } |
Bruno Cardoso Lopes | 2c2304c | 2010-11-08 21:42:32 +0000 | [diff] [blame] | 103 | bool isMips32r2() const { return MipsArchVersion == Mips32r2; } |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 104 | |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 105 | bool isLittle() const { return IsLittle; } |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 106 | bool isFP64bit() const { return IsFP64bit; } |
| 107 | bool isGP64bit() const { return IsGP64bit; } |
| 108 | bool isGP32bit() const { return !IsGP64bit; } |
| 109 | bool isSingleFloat() const { return IsSingleFloat; } |
| 110 | bool isNotSingleFloat() const { return !IsSingleFloat; } |
| 111 | bool hasVFPU() const { return HasVFPU; } |
| 112 | bool isLinux() const { return IsLinux; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 113 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 114 | /// Features related to the presence of specific instructions. |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 115 | bool hasSEInReg() const { return HasSEInReg; } |
| 116 | bool hasCondMov() const { return HasCondMov; } |
| 117 | bool hasMulDivAdd() const { return HasMulDivAdd; } |
| 118 | bool hasMinMax() const { return HasMinMax; } |
| 119 | bool hasSwap() const { return HasSwap; } |
| 120 | bool hasBitCount() const { return HasBitCount; } |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 121 | }; |
| 122 | } // End llvm namespace |
| 123 | |
| 124 | #endif |