Jia Liu | bb481f8 | 2012-02-28 07:46:26 +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 | ab8be96 | 2011-06-29 01:14:12 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCInstrItineraries.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetSubtargetInfo.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 { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 28 | virtual void anchor(); |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 29 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 30 | public: |
Akira Hatanaka | 0b7b6a0 | 2011-09-14 17:22:51 +0000 | [diff] [blame] | 31 | // NOTE: O64 will not be supported. |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 32 | enum MipsABIEnum { |
Akira Hatanaka | 8c1b4bf | 2011-09-21 02:45:29 +0000 | [diff] [blame] | 33 | UnknownABI, O32, N32, N64, EABI |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 34 | }; |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 35 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 36 | protected: |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 37 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 38 | enum MipsArchEnum { |
Akira Hatanaka | 1daa5be | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 39 | Mips32, Mips32r2, Mips64, Mips64r2 |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 42 | // Mips architecture version |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 43 | MipsArchEnum MipsArchVersion; |
| 44 | |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 45 | // Mips supported ABIs |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 46 | MipsABIEnum MipsABI; |
| 47 | |
| 48 | // IsLittle - The target is Little Endian |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 49 | bool IsLittle; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 50 | |
| 51 | // IsSingleFloat - The target only supports single precision float |
| 52 | // 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] | 53 | // floating point registers instead of only using even ones. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 54 | bool IsSingleFloat; |
| 55 | |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 56 | // IsFP64bit - The target processor has 64-bit floating point registers. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 57 | bool IsFP64bit; |
| 58 | |
| 59 | // IsFP64bit - General-purpose registers are 64 bits wide |
| 60 | bool IsGP64bit; |
| 61 | |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 62 | // HasVFPU - Processor has a vector floating point unit. |
| 63 | bool HasVFPU; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 64 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 65 | // isLinux - Target system is Linux. Is false we consider ELFOS for now. |
| 66 | bool IsLinux; |
| 67 | |
Akira Hatanaka | e7338cd | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 68 | // UseSmallSection - Small section is used. |
| 69 | bool UseSmallSection; |
| 70 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 71 | /// Features related to the presence of specific instructions. |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 72 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 73 | // HasSEInReg - SEB and SEH (signext in register) instructions. |
| 74 | bool HasSEInReg; |
| 75 | |
| 76 | // HasCondMov - Conditional mov (MOVZ, MOVN) instructions. |
| 77 | bool HasCondMov; |
| 78 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 79 | // HasSwap - Byte and half swap instructions. |
| 80 | bool HasSwap; |
| 81 | |
| 82 | // HasBitCount - Count leading '1' and '0' bits. |
| 83 | bool HasBitCount; |
| 84 | |
Akira Hatanaka | 0301bc5 | 2012-11-15 21:17:13 +0000 | [diff] [blame] | 85 | // HasFPIdx -- Floating point indexed load/store instructions. |
| 86 | bool HasFPIdx; |
| 87 | |
Akira Hatanaka | 66e19c3 | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 88 | // InMips16 -- can process Mips16 instructions |
| 89 | bool InMips16Mode; |
| 90 | |
Akira Hatanaka | a9adbf6 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 91 | // HasDSP, HasDSPR2 -- supports DSP ASE. |
| 92 | bool HasDSP, HasDSPR2; |
| 93 | |
Akira Hatanaka | bb2e1b5 | 2012-08-16 03:48:05 +0000 | [diff] [blame] | 94 | // IsAndroid -- target is android |
| 95 | bool IsAndroid; |
| 96 | |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 97 | InstrItineraryData InstrItins; |
| 98 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 99 | public: |
Akira Hatanaka | 81a424b | 2012-03-28 00:24:17 +0000 | [diff] [blame] | 100 | virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, |
| 101 | AntiDepBreakMode& Mode, |
| 102 | RegClassVector& CriticalPathRCs) const; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 103 | |
| 104 | /// Only O32 and EABI supported right now. |
| 105 | bool isABI_EABI() const { return MipsABI == EABI; } |
Akira Hatanaka | 1daa5be | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 106 | bool isABI_N64() const { return MipsABI == N64; } |
| 107 | bool isABI_N32() const { return MipsABI == N32; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 108 | bool isABI_O32() const { return MipsABI == O32; } |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 109 | unsigned getTargetABI() const { return MipsABI; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 110 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 111 | /// This constructor initializes the data members to match that |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 112 | /// of the specified triple. |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 113 | MipsSubtarget(const std::string &TT, const std::string &CPU, |
Akira Hatanaka | e7338cd | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 114 | const std::string &FS, bool little, Reloc::Model RM); |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 115 | |
| 116 | /// ParseSubtargetFeatures - Parses features string setting specified |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 117 | /// subtarget options. Definition of function is auto generated by tblgen. |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 118 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 119 | |
Akira Hatanaka | 5663344 | 2011-09-20 23:53:09 +0000 | [diff] [blame] | 120 | bool hasMips32() const { return MipsArchVersion >= Mips32; } |
| 121 | bool hasMips32r2() const { return MipsArchVersion == Mips32r2 || |
Akira Hatanaka | 1daa5be | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 122 | MipsArchVersion == Mips64r2; } |
Akira Hatanaka | 50fa74e | 2011-09-21 02:24:25 +0000 | [diff] [blame] | 123 | bool hasMips64() const { return MipsArchVersion >= Mips64; } |
| 124 | bool hasMips64r2() const { return MipsArchVersion == Mips64r2; } |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 125 | |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 126 | bool isLittle() const { return IsLittle; } |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 127 | bool isFP64bit() const { return IsFP64bit; } |
| 128 | bool isGP64bit() const { return IsGP64bit; } |
| 129 | bool isGP32bit() const { return !IsGP64bit; } |
| 130 | bool isSingleFloat() const { return IsSingleFloat; } |
| 131 | bool isNotSingleFloat() const { return !IsSingleFloat; } |
| 132 | bool hasVFPU() const { return HasVFPU; } |
Akira Hatanaka | 66e19c3 | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 133 | bool inMips16Mode() const { return InMips16Mode; } |
Akira Hatanaka | a9adbf6 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 134 | bool hasDSP() const { return HasDSP; } |
| 135 | bool hasDSPR2() const { return HasDSPR2; } |
Akira Hatanaka | bb2e1b5 | 2012-08-16 03:48:05 +0000 | [diff] [blame] | 136 | bool isAndroid() const { return IsAndroid; } |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 137 | bool isLinux() const { return IsLinux; } |
Akira Hatanaka | e7338cd | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 138 | bool useSmallSection() const { return UseSmallSection; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 139 | |
Akira Hatanaka | 18f3c78 | 2012-05-22 03:10:09 +0000 | [diff] [blame] | 140 | bool hasStandardEncoding() const { return !inMips16Mode(); } |
| 141 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 142 | /// Features related to the presence of specific instructions. |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 143 | bool hasSEInReg() const { return HasSEInReg; } |
| 144 | bool hasCondMov() const { return HasCondMov; } |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 145 | bool hasSwap() const { return HasSwap; } |
| 146 | bool hasBitCount() const { return HasBitCount; } |
Akira Hatanaka | 0301bc5 | 2012-11-15 21:17:13 +0000 | [diff] [blame] | 147 | bool hasFPIdx() const { return HasFPIdx; } |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 148 | }; |
| 149 | } // End llvm namespace |
| 150 | |
| 151 | #endif |