blob: 2244e497dd756f8393488860843ad88451c65067 [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 {
23class Module;
24
25class MipsSubtarget : public TargetSubtarget {
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000026
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000027public:
28 enum MipsABIEnum {
29 O32, O64, N32, N64, EABI
30 };
31
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000032protected:
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000033
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000034 enum MipsArchEnum {
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000035 Mips1, Mips2, Mips3, Mips4, Mips32, Mips32r2, Mips64, Mips64r2
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000036 };
37
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000038 // Mips architecture version
39 MipsArchEnum MipsArchVersion;
40
41 // Mips supported ABIs
42 MipsABIEnum MipsABI;
43
44 // IsLittle - The target is Little Endian
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000045 bool IsLittle;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000046
47 // IsSingleFloat - The target only supports single precision float
48 // point operations. This enable the target to use all 32 32-bit
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000049 // floating point registers instead of only using even ones.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000050 bool IsSingleFloat;
51
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000052 // IsFP64bit - The target processor has 64-bit floating point registers.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000053 bool IsFP64bit;
54
55 // IsFP64bit - General-purpose registers are 64 bits wide
56 bool IsGP64bit;
57
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000058 // HasVFPU - Processor has a vector floating point unit.
59 bool HasVFPU;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000060
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000061 // IsABICall - Enable SRV4 code for SVR4-style dynamic objects
62 bool HasABICall;
63
64 // HasAbsoluteCall - Enable code that is not fully position-independent.
65 // Only works with HasABICall enabled.
66 bool HasAbsoluteCall;
67
68 // isLinux - Target system is Linux. Is false we consider ELFOS for now.
69 bool IsLinux;
70
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +000071 /// Features related to the presence of specific instructions.
72
73 // HasSEInReg - SEB and SEH (signext in register) instructions.
74 bool HasSEInReg;
75
76 // HasCondMov - Conditional mov (MOVZ, MOVN) instructions.
77 bool HasCondMov;
78
79 // HasMulDivAdd - Multiply add and sub (MADD, MADDu, MSUB, MSUBu)
80 // instructions.
81 bool HasMulDivAdd;
82
83 // HasMinMax - MIN and MAX instructions.
84 bool HasMinMax;
85
86 // HasSwap - Byte and half swap instructions.
87 bool HasSwap;
88
89 // HasBitCount - Count leading '1' and '0' bits.
90 bool HasBitCount;
91
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000092 InstrItineraryData InstrItins;
93
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000094public:
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000095
96 /// Only O32 and EABI supported right now.
97 bool isABI_EABI() const { return MipsABI == EABI; }
98 bool isABI_O32() const { return MipsABI == O32; }
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000099 unsigned getTargetABI() const { return MipsABI; }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000100
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000101 /// This constructor initializes the data members to match that
102 /// of the specified module.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000103 MipsSubtarget(const TargetMachine &TM, const Module &M,
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000104 const std::string &FS, bool little);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000105
106 /// ParseSubtargetFeatures - Parses features string setting specified
107 /// subtarget options. Definition of function is auto generated by tblgen.
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000108 std::string ParseSubtargetFeatures(const std::string &FS,
109 const std::string &CPU);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000110
Bruno Cardoso Lopesd3bdf192009-05-27 17:23:44 +0000111 bool isMips1() const { return MipsArchVersion == Mips1; }
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000112
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000113 bool isLittle() const { return IsLittle; }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000114 bool isFP64bit() const { return IsFP64bit; };
115 bool isGP64bit() const { return IsGP64bit; };
116 bool isGP32bit() const { return !IsGP64bit; };
117 bool isSingleFloat() const { return IsSingleFloat; };
118 bool isNotSingleFloat() const { return !IsSingleFloat; };
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +0000119 bool hasVFPU() const { return HasVFPU; };
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +0000120 bool hasABICall() const { return HasABICall; };
121 bool hasAbsoluteCall() const { return HasAbsoluteCall; };
122 bool isLinux() const { return IsLinux; };
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000123
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +0000124 /// Features related to the presence of specific instructions.
125 bool hasSEInReg() const { return HasSEInReg; };
126 bool hasCondMov() const { return HasCondMov; };
127 bool hasMulDivAdd() const { return HasMulDivAdd; };
128 bool hasMinMax() const { return HasMinMax; };
129 bool hasSwap() const { return HasSwap; };
130 bool hasBitCount() const { return HasBitCount; };
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000131};
132} // End llvm namespace
133
134#endif