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