| Jia Liu | f54f60f | 2012-02-28 07:46:26 +0000 | [diff] [blame] | 1 | //===-- MipsSubtarget.h - Define Subtarget for the Mips ---------*- C++ -*-===// | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 2 | // | 
|  | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
| Chris Lattner | f3ebc3f | 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 | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // | 
| Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 9 | // | 
| Evan Cheng | 0d639a2 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file declares the Mips specific subclass of TargetSubtargetInfo. | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 11 | // | 
| Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 13 |  | 
|  | 14 | #ifndef MIPSSUBTARGET_H | 
|  | 15 | #define MIPSSUBTARGET_H | 
|  | 16 |  | 
| Jack Carter | c1b17ed | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 17 | #include "MCTargetDesc/MipsReginfo.h" | 
| Evan Cheng | 8264e27 | 2011-06-29 01:14:12 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCInstrItineraries.h" | 
| Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetSubtargetInfo.h" | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 20 | #include <string> | 
|  | 21 |  | 
| Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 22 | #define GET_SUBTARGETINFO_HEADER | 
| Evan Cheng | c9c090d | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 23 | #include "MipsGenSubtargetInfo.inc" | 
| Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 24 |  | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 25 | namespace llvm { | 
| Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 26 | class StringRef; | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 27 |  | 
| Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 28 | class MipsSubtarget : public MipsGenSubtargetInfo { | 
| David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 29 | virtual void anchor(); | 
| Bruno Cardoso Lopes | 87beec9 | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 30 |  | 
| Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 31 | public: | 
| Akira Hatanaka | 3efff6c | 2011-09-14 17:22:51 +0000 | [diff] [blame] | 32 | // NOTE: O64 will not be supported. | 
| Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 33 | enum MipsABIEnum { | 
| Akira Hatanaka | 6de4d12 | 2011-09-21 02:45:29 +0000 | [diff] [blame] | 34 | UnknownABI, O32, N32, N64, EABI | 
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 35 | }; | 
| Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 36 |  | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 37 | protected: | 
| Bruno Cardoso Lopes | 87beec9 | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 38 |  | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 39 | enum MipsArchEnum { | 
| Akira Hatanaka | 2b37261 | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 40 | Mips32, Mips32r2, Mips64, Mips64r2 | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 41 | }; | 
|  | 42 |  | 
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 43 | // Mips architecture version | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 44 | MipsArchEnum MipsArchVersion; | 
|  | 45 |  | 
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 46 | // Mips supported ABIs | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 47 | MipsABIEnum MipsABI; | 
|  | 48 |  | 
|  | 49 | // IsLittle - The target is Little Endian | 
| Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 50 | bool IsLittle; | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 51 |  | 
|  | 52 | // IsSingleFloat - The target only supports single precision float | 
|  | 53 | // point operations. This enable the target to use all 32 32-bit | 
| Bruno Cardoso Lopes | 7ceec57 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 54 | // floating point registers instead of only using even ones. | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 55 | bool IsSingleFloat; | 
|  | 56 |  | 
| Bruno Cardoso Lopes | 7ceec57 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 57 | // IsFP64bit - The target processor has 64-bit floating point registers. | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 58 | bool IsFP64bit; | 
|  | 59 |  | 
|  | 60 | // IsFP64bit - General-purpose registers are 64 bits wide | 
|  | 61 | bool IsGP64bit; | 
|  | 62 |  | 
| Bruno Cardoso Lopes | bcc2139 | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 63 | // HasVFPU - Processor has a vector floating point unit. | 
|  | 64 | bool HasVFPU; | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 65 |  | 
| Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 66 | // isLinux - Target system is Linux. Is false we consider ELFOS for now. | 
|  | 67 | bool IsLinux; | 
|  | 68 |  | 
| Akira Hatanaka | ad49502 | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 69 | // UseSmallSection - Small section is used. | 
|  | 70 | bool UseSmallSection; | 
|  | 71 |  | 
| Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 72 | /// Features related to the presence of specific instructions. | 
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 73 |  | 
| Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 74 | // HasSEInReg - SEB and SEH (signext in register) instructions. | 
|  | 75 | bool HasSEInReg; | 
|  | 76 |  | 
|  | 77 | // HasCondMov - Conditional mov (MOVZ, MOVN) instructions. | 
|  | 78 | bool HasCondMov; | 
|  | 79 |  | 
| Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 80 | // HasSwap - Byte and half swap instructions. | 
|  | 81 | bool HasSwap; | 
|  | 82 |  | 
|  | 83 | // HasBitCount - Count leading '1' and '0' bits. | 
|  | 84 | bool HasBitCount; | 
|  | 85 |  | 
| Akira Hatanaka | 3bc1beb | 2012-11-15 21:17:13 +0000 | [diff] [blame] | 86 | // HasFPIdx -- Floating point indexed load/store instructions. | 
|  | 87 | bool HasFPIdx; | 
|  | 88 |  | 
| Akira Hatanaka | 0faaebf | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 89 | // InMips16 -- can process Mips16 instructions | 
|  | 90 | bool InMips16Mode; | 
|  | 91 |  | 
| Jack Carter | 428a06c | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 92 | // InMicroMips -- can process MicroMips instructions | 
|  | 93 | bool InMicroMipsMode; | 
|  | 94 |  | 
| Akira Hatanaka | 65ce931 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 95 | // HasDSP, HasDSPR2 -- supports DSP ASE. | 
|  | 96 | bool HasDSP, HasDSPR2; | 
|  | 97 |  | 
| Akira Hatanaka | 89d50b3 | 2012-08-16 03:48:05 +0000 | [diff] [blame] | 98 | // IsAndroid -- target is android | 
|  | 99 | bool IsAndroid; | 
|  | 100 |  | 
| Bruno Cardoso Lopes | 87beec9 | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 101 | InstrItineraryData InstrItins; | 
|  | 102 |  | 
| Jack Carter | c1b17ed | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 103 | // The instance to the register info section object | 
|  | 104 | MipsReginfo MRI; | 
|  | 105 |  | 
| Jack Carter | 7f37810 | 2013-01-30 02:16:36 +0000 | [diff] [blame] | 106 | // Relocation Model | 
|  | 107 | Reloc::Model RM; | 
|  | 108 |  | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 109 | public: | 
| Akira Hatanaka | 047473e | 2012-03-28 00:24:17 +0000 | [diff] [blame] | 110 | virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, | 
|  | 111 | AntiDepBreakMode& Mode, | 
|  | 112 | RegClassVector& CriticalPathRCs) const; | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 113 |  | 
|  | 114 | /// Only O32 and EABI supported right now. | 
|  | 115 | bool isABI_EABI() const { return MipsABI == EABI; } | 
| Akira Hatanaka | 2b37261 | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 116 | bool isABI_N64() const { return MipsABI == N64; } | 
|  | 117 | bool isABI_N32() const { return MipsABI == N32; } | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 118 | bool isABI_O32() const { return MipsABI == O32; } | 
| Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 119 | unsigned getTargetABI() const { return MipsABI; } | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 120 |  | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 121 | /// This constructor initializes the data members to match that | 
| Daniel Dunbar | 31b44e8 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 122 | /// of the specified triple. | 
| Evan Cheng | fe6e405 | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 123 | MipsSubtarget(const std::string &TT, const std::string &CPU, | 
| Akira Hatanaka | ad49502 | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 124 | const std::string &FS, bool little, Reloc::Model RM); | 
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 125 |  | 
|  | 126 | /// ParseSubtargetFeatures - Parses features string setting specified | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 127 | /// subtarget options.  Definition of function is auto generated by tblgen. | 
| Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 128 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 129 |  | 
| Akira Hatanaka | bb49e72 | 2011-09-20 23:53:09 +0000 | [diff] [blame] | 130 | bool hasMips32() const { return MipsArchVersion >= Mips32; } | 
|  | 131 | bool hasMips32r2() const { return MipsArchVersion == Mips32r2 || | 
| Akira Hatanaka | 2b37261 | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 132 | MipsArchVersion == Mips64r2; } | 
| Akira Hatanaka | 6e506eb | 2011-09-21 02:24:25 +0000 | [diff] [blame] | 133 | bool hasMips64() const { return MipsArchVersion >= Mips64; } | 
|  | 134 | bool hasMips64r2() const { return MipsArchVersion == Mips64r2; } | 
| Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 135 |  | 
| Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 136 | bool isLittle() const { return IsLittle; } | 
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 137 | bool isFP64bit() const { return IsFP64bit; } | 
|  | 138 | bool isGP64bit() const { return IsGP64bit; } | 
|  | 139 | bool isGP32bit() const { return !IsGP64bit; } | 
|  | 140 | bool isSingleFloat() const { return IsSingleFloat; } | 
|  | 141 | bool isNotSingleFloat() const { return !IsSingleFloat; } | 
|  | 142 | bool hasVFPU() const { return HasVFPU; } | 
| Akira Hatanaka | 0faaebf | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 143 | bool inMips16Mode() const { return InMips16Mode; } | 
| Jack Carter | 428a06c | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 144 | bool inMicroMipsMode() const { return InMicroMipsMode; } | 
| Akira Hatanaka | 65ce931 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 145 | bool hasDSP() const { return HasDSP; } | 
|  | 146 | bool hasDSPR2() const { return HasDSPR2; } | 
| Akira Hatanaka | 89d50b3 | 2012-08-16 03:48:05 +0000 | [diff] [blame] | 147 | bool isAndroid() const { return IsAndroid; } | 
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 148 | bool isLinux() const { return IsLinux; } | 
| Akira Hatanaka | ad49502 | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 149 | bool useSmallSection() const { return UseSmallSection; } | 
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 150 |  | 
| Akira Hatanaka | cdf4fd8 | 2012-05-22 03:10:09 +0000 | [diff] [blame] | 151 | bool hasStandardEncoding() const { return !inMips16Mode(); } | 
|  | 152 |  | 
| Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 153 | /// Features related to the presence of specific instructions. | 
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 154 | bool hasSEInReg()   const { return HasSEInReg; } | 
|  | 155 | bool hasCondMov()   const { return HasCondMov; } | 
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 156 | bool hasSwap()      const { return HasSwap; } | 
|  | 157 | bool hasBitCount()  const { return HasBitCount; } | 
| Akira Hatanaka | 3bc1beb | 2012-11-15 21:17:13 +0000 | [diff] [blame] | 158 | bool hasFPIdx()     const { return HasFPIdx; } | 
| Jack Carter | c1b17ed | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 159 |  | 
|  | 160 | // Grab MipsRegInfo object | 
|  | 161 | const MipsReginfo &getMReginfo() const { return MRI; } | 
| Jack Carter | 7f37810 | 2013-01-30 02:16:36 +0000 | [diff] [blame] | 162 |  | 
|  | 163 | // Grab relocation model | 
|  | 164 | Reloc::Model getRelocationModel() const {return RM;} | 
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 165 | }; | 
|  | 166 | } // End llvm namespace | 
|  | 167 |  | 
|  | 168 | #endif |