blob: 2485fef887ea3cd169a94cff123e0ce90422de94 [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//=====-- MipsSubtarget.h - Define Subtarget for the Mips -----*- C++ -*--====//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00007//
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
22namespace llvm {
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000023
24class MipsSubtarget : public TargetSubtarget {
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000025
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000026public:
27 enum MipsABIEnum {
28 O32, O64, N32, N64, EABI
29 };
30
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000031protected:
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000032
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000033 enum MipsArchEnum {
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000034 Mips1, Mips2, Mips3, Mips4, Mips32, Mips32r2, Mips64, Mips64r2
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000035 };
36
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000037 // Mips architecture version
38 MipsArchEnum MipsArchVersion;
39
40 // Mips supported ABIs
41 MipsABIEnum MipsABI;
42
43 // IsLittle - The target is Little Endian
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000044 bool IsLittle;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000045
46 // IsSingleFloat - The target only supports single precision float
47 // point operations. This enable the target to use all 32 32-bit
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000048 // floating point registers instead of only using even ones.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000049 bool IsSingleFloat;
50
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000051 // IsFP64bit - The target processor has 64-bit floating point registers.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000052 bool IsFP64bit;
53
54 // IsFP64bit - General-purpose registers are 64 bits wide
55 bool IsGP64bit;
56
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000057 // HasVFPU - Processor has a vector floating point unit.
58 bool HasVFPU;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000059
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000060 // IsABICall - Enable SRV4 code for SVR4-style dynamic objects
61 bool HasABICall;
62
63 // HasAbsoluteCall - Enable code that is not fully position-independent.
64 // Only works with HasABICall enabled.
65 bool HasAbsoluteCall;
66
67 // isLinux - Target system is Linux. Is false we consider ELFOS for now.
68 bool IsLinux;
69
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +000070 /// Features related to the presence of specific instructions.
71
72 // HasSEInReg - SEB and SEH (signext in register) instructions.
73 bool HasSEInReg;
74
75 // HasCondMov - Conditional mov (MOVZ, MOVN) instructions.
76 bool HasCondMov;
77
78 // HasMulDivAdd - Multiply add and sub (MADD, MADDu, MSUB, MSUBu)
79 // instructions.
80 bool HasMulDivAdd;
81
82 // HasMinMax - MIN and MAX instructions.
83 bool HasMinMax;
84
85 // HasSwap - Byte and half swap instructions.
86 bool HasSwap;
87
88 // HasBitCount - Count leading '1' and '0' bits.
89 bool HasBitCount;
90
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000091 InstrItineraryData InstrItins;
92
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000093public:
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000094
95 /// Only O32 and EABI supported right now.
96 bool isABI_EABI() const { return MipsABI == EABI; }
97 bool isABI_O32() const { return MipsABI == O32; }
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000098 unsigned getTargetABI() const { return MipsABI; }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000099
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000100 /// This constructor initializes the data members to match that
Daniel Dunbar3be03402009-08-02 22:11:08 +0000101 /// of the specified triple.
102 MipsSubtarget(const TargetMachine &TM, const std::string &TT,
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000103 const std::string &FS, bool little);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000104
105 /// ParseSubtargetFeatures - Parses features string setting specified
106 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000107 std::string ParseSubtargetFeatures(const std::string &FS,
108 const std::string &CPU);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000109
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +0000110 bool isMips1() const { return MipsArchVersion == Mips1; }
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000111
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000112 bool isLittle() const { return IsLittle; }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000113 bool isFP64bit() const { return IsFP64bit; };
114 bool isGP64bit() const { return IsGP64bit; };
115 bool isGP32bit() const { return !IsGP64bit; };
116 bool isSingleFloat() const { return IsSingleFloat; };
117 bool isNotSingleFloat() const { return !IsSingleFloat; };
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +0000118 bool hasVFPU() const { return HasVFPU; };
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +0000119 bool hasABICall() const { return HasABICall; };
120 bool hasAbsoluteCall() const { return HasAbsoluteCall; };
121 bool isLinux() const { return IsLinux; };
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000122
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +0000123 /// Features related to the presence of specific instructions.
124 bool hasSEInReg() const { return HasSEInReg; };
125 bool hasCondMov() const { return HasCondMov; };
126 bool hasMulDivAdd() const { return HasMulDivAdd; };
127 bool hasMinMax() const { return HasMinMax; };
128 bool hasSwap() const { return HasSwap; };
129 bool hasBitCount() const { return HasBitCount; };
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000130};
131} // End llvm namespace
132
133#endif