Bruno Cardoso Lopes | 972f589 | 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 | 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 | // |
| 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 { |
| 23 | class Module; |
| 24 | |
| 25 | class MipsSubtarget : public TargetSubtarget { |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 26 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 27 | protected: |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 28 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 29 | enum MipsArchEnum { |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 30 | Mips1, Mips2, Mips3, Mips4, Mips32, Mips32r2, Mips64, Mips64r2 |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | enum MipsABIEnum { |
| 34 | O32, EABI |
| 35 | }; |
| 36 | |
| 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 | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 44 | bool IsLittle; |
Bruno Cardoso Lopes | 225ca9c | 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 | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 48 | // floating point registers instead of only using even ones. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 49 | bool IsSingleFloat; |
| 50 | |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 51 | // IsFP64bit - The target processor has 64-bit floating point registers. |
Bruno Cardoso Lopes | 225ca9c | 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 | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 57 | // HasVFPU - Processor has a vector floating point unit. |
| 58 | bool HasVFPU; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 59 | |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 60 | // HasSEInReg - Target has SEB and SEH (signext in register) instructions. |
| 61 | bool HasSEInReg; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 62 | |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 63 | InstrItineraryData InstrItins; |
| 64 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 65 | public: |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 66 | |
| 67 | /// Only O32 and EABI supported right now. |
| 68 | bool isABI_EABI() const { return MipsABI == EABI; } |
| 69 | bool isABI_O32() const { return MipsABI == O32; } |
| 70 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 71 | /// This constructor initializes the data members to match that |
| 72 | /// of the specified module. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 73 | MipsSubtarget(const TargetMachine &TM, const Module &M, |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 74 | const std::string &FS, bool little); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 75 | |
| 76 | /// ParseSubtargetFeatures - Parses features string setting specified |
| 77 | /// subtarget options. Definition of function is auto generated by tblgen. |
| 78 | void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); |
| 79 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 80 | bool hasMips2Ops() const { return MipsArchVersion >= Mips2; } |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 81 | |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 82 | bool isLittle() const { return IsLittle; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 83 | bool isFP64bit() const { return IsFP64bit; }; |
| 84 | bool isGP64bit() const { return IsGP64bit; }; |
| 85 | bool isGP32bit() const { return !IsGP64bit; }; |
| 86 | bool isSingleFloat() const { return IsSingleFloat; }; |
| 87 | bool isNotSingleFloat() const { return !IsSingleFloat; }; |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 88 | bool hasVFPU() const { return HasVFPU; }; |
| 89 | bool hasSEInReg() const { return HasSEInReg; }; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 90 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 91 | }; |
| 92 | } // End llvm namespace |
| 93 | |
| 94 | #endif |