1//===-- Mips.td - Describe the Mips Target Machine ---------*- tablegen -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9// This is the top level entry point for the Mips target.
10//===----------------------------------------------------------------------===//
11
12//===----------------------------------------------------------------------===//
13// Target-independent interfaces
14//===----------------------------------------------------------------------===//
15
16include "llvm/Target/Target.td"
17
18// The overall idea of the PredicateControl class is to chop the Predicates list
19// into subsets that are usually overridden independently. This allows
20// subclasses to partially override the predicates of their superclasses without
21// having to re-add all the existing predicates.
22class PredicateControl {
23  // Predicates for the encoding scheme in use such as HasStdEnc
24  list<Predicate> EncodingPredicates = [];
25  // Predicates for the GPR size such as IsGP64bit
26  list<Predicate> GPRPredicates = [];
27  // Predicates for the FGR size and layout such as IsFP64bit
28  list<Predicate> FGRPredicates = [];
29  // Predicates for the instruction group membership such as ISA's and ASE's
30  list<Predicate> InsnPredicates = [];
31  // Predicates for anything else
32  list<Predicate> AdditionalPredicates = [];
33  list<Predicate> Predicates = !listconcat(EncodingPredicates,
34                                           GPRPredicates,
35                                           FGRPredicates,
36                                           InsnPredicates,
37                                           AdditionalPredicates);
38}
39
40// Like Requires<> but for the AdditionalPredicates list
41class AdditionalRequires<list<Predicate> preds> {
42  list<Predicate> AdditionalPredicates = preds;
43}
44
45//===----------------------------------------------------------------------===//
46// Register File, Calling Conv, Instruction Descriptions
47//===----------------------------------------------------------------------===//
48
49include "MipsRegisterInfo.td"
50include "MipsSchedule.td"
51include "MipsInstrInfo.td"
52include "MipsCallingConv.td"
53
54def MipsInstrInfo : InstrInfo;
55
56//===----------------------------------------------------------------------===//
57// Mips Subtarget features                                                    //
58//===----------------------------------------------------------------------===//
59
60def FeatureGP64Bit     : SubtargetFeature<"gp64", "IsGP64bit", "true",
61                                "General Purpose Registers are 64-bit wide.">;
62def FeatureFP64Bit     : SubtargetFeature<"fp64", "IsFP64bit", "true",
63                                "Support 64-bit FP registers.">;
64def FeatureNaN2008     : SubtargetFeature<"nan2008", "IsNaN2008bit", "true",
65                                "IEEE 754-2008 NaN encoding.">;
66def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat",
67                                "true", "Only supports single precision float">;
68def FeatureO32         : SubtargetFeature<"o32", "MipsABI", "O32",
69                                "Enable o32 ABI">;
70def FeatureN32         : SubtargetFeature<"n32", "MipsABI", "N32",
71                                "Enable n32 ABI">;
72def FeatureN64         : SubtargetFeature<"n64", "MipsABI", "N64",
73                                "Enable n64 ABI">;
74def FeatureEABI        : SubtargetFeature<"eabi", "MipsABI", "EABI",
75                                "Enable eabi ABI">;
76def FeatureVFPU        : SubtargetFeature<"vfpu", "HasVFPU",
77                                "true", "Enable vector FPU instructions.">;
78def FeatureMips1       : SubtargetFeature<"mips1", "MipsArchVersion", "Mips1",
79                                "Mips I ISA Support [highly experimental]">;
80def FeatureMips2       : SubtargetFeature<"mips2", "MipsArchVersion", "Mips2",
81                                "Mips II ISA Support [highly experimental]",
82                                [FeatureMips1]>;
83def FeatureMips3_32    : SubtargetFeature<"mips3_32", "HasMips3_32", "true",
84                                "Subset of MIPS-III that is also in MIPS32 "
85                                "[highly experimental]">;
86def FeatureMips3_32r2  : SubtargetFeature<"mips3_32r2", "HasMips3_32r2", "true",
87                                "Subset of MIPS-III that is also in MIPS32r2 "
88                                "[highly experimental]">;
89def FeatureMips3       : SubtargetFeature<"mips3", "MipsArchVersion", "Mips3",
90                                "MIPS III ISA Support [highly experimental]",
91                                [FeatureMips2, FeatureMips3_32,
92                                 FeatureMips3_32r2, FeatureGP64Bit,
93                                 FeatureFP64Bit]>;
94def FeatureMips4_32    : SubtargetFeature<"mips4_32", "HasMips4_32", "true",
95                                "Subset of MIPS-IV that is also in MIPS32 "
96                                "[highly experimental]">;
97def FeatureMips4_32r2  : SubtargetFeature<"mips4_32r2", "HasMips4_32r2", "true",
98                                "Subset of MIPS-IV that is also in MIPS32r2 "
99                                "[highly experimental]">;
100def FeatureMips4       : SubtargetFeature<"mips4", "MipsArchVersion",
101                                "Mips4", "MIPS IV ISA Support",
102                                [FeatureMips3, FeatureMips4_32,
103                                 FeatureMips4_32r2]>;
104def FeatureMips5_32r2  : SubtargetFeature<"mips5_32r2", "HasMips5_32r2", "true",
105                                "Subset of MIPS-V that is also in MIPS32r2 "
106                                "[highly experimental]">;
107def FeatureMips5       : SubtargetFeature<"mips5", "MipsArchVersion", "Mips5",
108                                "MIPS V ISA Support [highly experimental]",
109                                [FeatureMips4, FeatureMips5_32r2]>;
110def FeatureMips32      : SubtargetFeature<"mips32", "MipsArchVersion", "Mips32",
111                                "Mips32 ISA Support",
112                                [FeatureMips2, FeatureMips3_32,
113                                 FeatureMips4_32]>;
114def FeatureMips32r2    : SubtargetFeature<"mips32r2", "MipsArchVersion",
115                                "Mips32r2", "Mips32r2 ISA Support",
116                                [FeatureMips3_32r2, FeatureMips4_32r2,
117                                 FeatureMips5_32r2, FeatureMips32]>;
118def FeatureMips32r6    : SubtargetFeature<"mips32r6", "MipsArchVersion",
119                                "Mips32r6",
120                                "Mips32r6 ISA Support [experimental]",
121                                [FeatureMips32r2, FeatureFP64Bit,
122                                 FeatureNaN2008]>;
123def FeatureMips64      : SubtargetFeature<"mips64", "MipsArchVersion",
124                                "Mips64", "Mips64 ISA Support",
125                                [FeatureMips5, FeatureMips32]>;
126def FeatureMips64r2    : SubtargetFeature<"mips64r2", "MipsArchVersion",
127                                "Mips64r2", "Mips64r2 ISA Support",
128                                [FeatureMips64, FeatureMips32r2]>;
129def FeatureMips64r6    : SubtargetFeature<"mips64r6", "MipsArchVersion",
130                                "Mips64r6",
131                                "Mips64r6 ISA Support [experimental]",
132                                [FeatureMips32r6, FeatureMips64r2,
133                                 FeatureNaN2008]>;
134
135def FeatureMips16  : SubtargetFeature<"mips16", "InMips16Mode", "true",
136                                      "Mips16 mode">;
137
138def FeatureDSP : SubtargetFeature<"dsp", "HasDSP", "true", "Mips DSP ASE">;
139def FeatureDSPR2 : SubtargetFeature<"dspr2", "HasDSPR2", "true",
140                                    "Mips DSP-R2 ASE", [FeatureDSP]>;
141
142def FeatureMSA : SubtargetFeature<"msa", "HasMSA", "true", "Mips MSA ASE">;
143
144def FeatureMicroMips  : SubtargetFeature<"micromips", "InMicroMipsMode", "true",
145                                         "microMips mode">;
146
147def FeatureCnMips     : SubtargetFeature<"cnmips", "HasCnMips",
148                                "true", "Octeon cnMIPS Support",
149                                [FeatureMips64r2]>;
150
151//===----------------------------------------------------------------------===//
152// Mips processors supported.
153//===----------------------------------------------------------------------===//
154
155class Proc<string Name, list<SubtargetFeature> Features>
156 : Processor<Name, MipsGenericItineraries, Features>;
157
158def : Proc<"mips1", [FeatureMips1, FeatureO32]>;
159def : Proc<"mips2", [FeatureMips2, FeatureO32]>;
160def : Proc<"mips32", [FeatureMips32, FeatureO32]>;
161def : Proc<"mips32r2", [FeatureMips32r2, FeatureO32]>;
162def : Proc<"mips32r6", [FeatureMips32r6, FeatureO32]>;
163
164def : Proc<"mips3", [FeatureMips3, FeatureN64]>;
165def : Proc<"mips4", [FeatureMips4, FeatureN64]>;
166def : Proc<"mips5", [FeatureMips5, FeatureN64]>;
167def : Proc<"mips64", [FeatureMips64, FeatureN64]>;
168def : Proc<"mips64r2", [FeatureMips64r2, FeatureN64]>;
169def : Proc<"mips64r6", [FeatureMips64r6, FeatureN64]>;
170def : Proc<"mips16", [FeatureMips16, FeatureO32]>;
171def : Proc<"octeon", [FeatureMips64r2, FeatureN64, FeatureCnMips]>;
172
173def MipsAsmParser : AsmParser {
174  let ShouldEmitMatchRegisterName = 0;
175  let MnemonicContainsDot = 1;
176}
177
178def MipsAsmParserVariant : AsmParserVariant {
179  int Variant = 0;
180
181  // Recognize hard coded registers.
182  string RegisterPrefix = "$";
183}
184
185def Mips : Target {
186  let InstructionSet = MipsInstrInfo;
187  let AssemblyParsers = [MipsAsmParser];
188  let AssemblyParserVariants = [MipsAsmParserVariant];
189}
190