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