blob: a4dd716360f375262983dd78713b2b6660f6449d [file] [log] [blame]
Jia Liuf54f60f2012-02-28 07:46:26 +00001//===-- Mips.td - Describe the Mips Target Machine ---------*- tablegen -*-===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Lopes35e43c42007-06-06 07:42:06 +00007//
Akira Hatanakae2489122011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +00009// This is the top level entry point for the Mips target.
Akira Hatanakae2489122011-04-15 21:51:11 +000010//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000011
Akira Hatanakae2489122011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000013// Target-independent interfaces
Akira Hatanakae2489122011-04-15 21:51:11 +000014//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000015
Evan Cheng977e7be2008-11-24 07:34:46 +000016include "llvm/Target/Target.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000017
Daniel Sanders3dc2c012014-05-07 10:27:09 +000018// 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 = [];
Daniel Sanders13d72092014-05-07 12:48:37 +000025 // 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 = [];
Daniel Sanders9c1b1be2014-05-07 13:57:22 +000029 // Predicates for the instruction group membership such as ISA's and ASE's
30 list<Predicate> InsnPredicates = [];
Daniel Sanders3dc2c012014-05-07 10:27:09 +000031 // Predicates for anything else
32 list<Predicate> AdditionalPredicates = [];
33 list<Predicate> Predicates = !listconcat(EncodingPredicates,
Daniel Sanders13d72092014-05-07 12:48:37 +000034 GPRPredicates,
35 FGRPredicates,
Daniel Sanders9c1b1be2014-05-07 13:57:22 +000036 InsnPredicates,
Daniel Sanders3dc2c012014-05-07 10:27:09 +000037 AdditionalPredicates);
38}
39
40// Like Requires<> but for the AdditionalPredicates list
41class AdditionalRequires<list<Predicate> preds> {
42 list<Predicate> AdditionalPredicates = preds;
43}
44
Akira Hatanakae2489122011-04-15 21:51:11 +000045//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000046// Register File, Calling Conv, Instruction Descriptions
Akira Hatanakae2489122011-04-15 21:51:11 +000047//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000048
49include "MipsRegisterInfo.td"
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000050include "MipsSchedule.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000051include "MipsInstrInfo.td"
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000052include "MipsCallingConv.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000053
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +000054def MipsInstrInfo : InstrInfo;
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000055
Akira Hatanakae2489122011-04-15 21:51:11 +000056//===----------------------------------------------------------------------===//
57// Mips Subtarget features //
58//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000059
Daniel Sandersfeb61302014-08-08 15:47:17 +000060def FeatureNoABICalls : SubtargetFeature<"noabicalls", "NoABICalls", "true",
61 "Disable SVR4-style position-independent code.">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000062def FeatureGP64Bit : SubtargetFeature<"gp64", "IsGP64bit", "true",
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000063 "General Purpose Registers are 64-bit wide.">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000064def FeatureFP64Bit : SubtargetFeature<"fp64", "IsFP64bit", "true",
Akira Hatanaka3048b022013-10-30 02:29:43 +000065 "Support 64-bit FP registers.">;
Zoran Jovanovic255d00d2014-07-10 15:36:12 +000066def FeatureFPXX : SubtargetFeature<"fpxx", "IsFPXX", "true",
67 "Support for FPXX.">;
Matheus Almeida0051f2d2014-04-16 15:48:55 +000068def FeatureNaN2008 : SubtargetFeature<"nan2008", "IsNaN2008bit", "true",
69 "IEEE 754-2008 NaN encoding.">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000070def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat",
Akira Hatanakae2489122011-04-15 21:51:11 +000071 "true", "Only supports single precision float">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000072def FeatureO32 : SubtargetFeature<"o32", "MipsABI", "O32",
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000073 "Enable o32 ABI">;
Akira Hatanaka2b372612011-09-20 20:28:08 +000074def FeatureN32 : SubtargetFeature<"n32", "MipsABI", "N32",
75 "Enable n32 ABI">;
76def FeatureN64 : SubtargetFeature<"n64", "MipsABI", "N64",
77 "Enable n64 ABI">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000078def FeatureEABI : SubtargetFeature<"eabi", "MipsABI", "EABI",
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000079 "Enable eabi ABI">;
Daniel Sanders7e527422014-07-10 13:38:23 +000080def FeatureNoOddSPReg : SubtargetFeature<"nooddspreg", "UseOddSPReg", "false",
81 "Disable odd numbered single-precision "
82 "registers">;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +000083def FeatureVFPU : SubtargetFeature<"vfpu", "HasVFPU",
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000084 "true", "Enable vector FPU instructions.">;
Daniel Sandersd2409532014-05-07 16:25:22 +000085def FeatureMips1 : SubtargetFeature<"mips1", "MipsArchVersion", "Mips1",
86 "Mips I ISA Support [highly experimental]">;
87def FeatureMips2 : SubtargetFeature<"mips2", "MipsArchVersion", "Mips2",
88 "Mips II ISA Support [highly experimental]",
89 [FeatureMips1]>;
Daniel Sandersf2056be2014-05-09 13:02:27 +000090def FeatureMips3_32 : SubtargetFeature<"mips3_32", "HasMips3_32", "true",
91 "Subset of MIPS-III that is also in MIPS32 "
92 "[highly experimental]">;
Daniel Sanders387fc152014-05-13 11:45:36 +000093def FeatureMips3_32r2 : SubtargetFeature<"mips3_32r2", "HasMips3_32r2", "true",
94 "Subset of MIPS-III that is also in MIPS32r2 "
95 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +000096def FeatureMips3 : SubtargetFeature<"mips3", "MipsArchVersion", "Mips3",
97 "MIPS III ISA Support [highly experimental]",
98 [FeatureMips2, FeatureMips3_32,
Daniel Sanders387fc152014-05-13 11:45:36 +000099 FeatureMips3_32r2, FeatureGP64Bit,
100 FeatureFP64Bit]>;
Daniel Sanderse57d8662014-05-09 14:06:17 +0000101def FeatureMips4_32 : SubtargetFeature<"mips4_32", "HasMips4_32", "true",
102 "Subset of MIPS-IV that is also in MIPS32 "
103 "[highly experimental]">;
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000104def FeatureMips4_32r2 : SubtargetFeature<"mips4_32r2", "HasMips4_32r2", "true",
105 "Subset of MIPS-IV that is also in MIPS32r2 "
106 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000107def FeatureMips4 : SubtargetFeature<"mips4", "MipsArchVersion",
108 "Mips4", "MIPS IV ISA Support",
Daniel Sanderse57d8662014-05-09 14:06:17 +0000109 [FeatureMips3, FeatureMips4_32,
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000110 FeatureMips4_32r2]>;
Daniel Sanders07cdea22014-05-12 12:52:44 +0000111def FeatureMips5_32r2 : SubtargetFeature<"mips5_32r2", "HasMips5_32r2", "true",
112 "Subset of MIPS-V that is also in MIPS32r2 "
113 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000114def FeatureMips5 : SubtargetFeature<"mips5", "MipsArchVersion", "Mips5",
115 "MIPS V ISA Support [highly experimental]",
Daniel Sanders07cdea22014-05-12 12:52:44 +0000116 [FeatureMips4, FeatureMips5_32r2]>;
Akira Hatanakae2489122011-04-15 21:51:11 +0000117def FeatureMips32 : SubtargetFeature<"mips32", "MipsArchVersion", "Mips32",
118 "Mips32 ISA Support",
Daniel Sandersf2056be2014-05-09 13:02:27 +0000119 [FeatureMips2, FeatureMips3_32,
Daniel Sanders070fd1c2014-05-12 12:41:59 +0000120 FeatureMips4_32]>;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +0000121def FeatureMips32r2 : SubtargetFeature<"mips32r2", "MipsArchVersion",
122 "Mips32r2", "Mips32r2 ISA Support",
Daniel Sanders387fc152014-05-13 11:45:36 +0000123 [FeatureMips3_32r2, FeatureMips4_32r2,
124 FeatureMips5_32r2, FeatureMips32]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000125def FeatureMips32r6 : SubtargetFeature<"mips32r6", "MipsArchVersion",
126 "Mips32r6",
127 "Mips32r6 ISA Support [experimental]",
128 [FeatureMips32r2, FeatureFP64Bit,
129 FeatureNaN2008]>;
Akira Hatanaka2b372612011-09-20 20:28:08 +0000130def FeatureMips64 : SubtargetFeature<"mips64", "MipsArchVersion",
131 "Mips64", "Mips64 ISA Support",
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000132 [FeatureMips5, FeatureMips32]>;
Akira Hatanaka2b372612011-09-20 20:28:08 +0000133def FeatureMips64r2 : SubtargetFeature<"mips64r2", "MipsArchVersion",
134 "Mips64r2", "Mips64r2 ISA Support",
135 [FeatureMips64, FeatureMips32r2]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000136def FeatureMips64r6 : SubtargetFeature<"mips64r6", "MipsArchVersion",
137 "Mips64r6",
138 "Mips64r6 ISA Support [experimental]",
Daniel Sanders0ac5ec52014-05-12 15:12:45 +0000139 [FeatureMips32r6, FeatureMips64r2,
140 FeatureNaN2008]>;
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000141
Akira Hatanaka0faaebf2012-05-16 22:19:56 +0000142def FeatureMips16 : SubtargetFeature<"mips16", "InMips16Mode", "true",
143 "Mips16 mode">;
144
Akira Hatanaka65ce9312012-09-21 23:41:49 +0000145def FeatureDSP : SubtargetFeature<"dsp", "HasDSP", "true", "Mips DSP ASE">;
146def FeatureDSPR2 : SubtargetFeature<"dspr2", "HasDSPR2", "true",
147 "Mips DSP-R2 ASE", [FeatureDSP]>;
148
Jack Carter3a2c2d42013-08-13 20:54:07 +0000149def FeatureMSA : SubtargetFeature<"msa", "HasMSA", "true", "Mips MSA ASE">;
150
Jack Carter428a06c2013-02-05 09:30:03 +0000151def FeatureMicroMips : SubtargetFeature<"micromips", "InMicroMipsMode", "true",
152 "microMips mode">;
153
Kai Nacke93fe5e82014-03-20 11:51:58 +0000154def FeatureCnMips : SubtargetFeature<"cnmips", "HasCnMips",
155 "true", "Octeon cnMIPS Support",
156 [FeatureMips64r2]>;
157
Akira Hatanakae2489122011-04-15 21:51:11 +0000158//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000159// Mips processors supported.
Akira Hatanakae2489122011-04-15 21:51:11 +0000160//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000161
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000162class Proc<string Name, list<SubtargetFeature> Features>
163 : Processor<Name, MipsGenericItineraries, Features>;
164
Daniel Sandersd2409532014-05-07 16:25:22 +0000165def : Proc<"mips1", [FeatureMips1, FeatureO32]>;
166def : Proc<"mips2", [FeatureMips2, FeatureO32]>;
Daniel Sanders5a1449d2014-02-20 14:58:19 +0000167def : Proc<"mips32", [FeatureMips32, FeatureO32]>;
168def : Proc<"mips32r2", [FeatureMips32r2, FeatureO32]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000169def : Proc<"mips32r6", [FeatureMips32r6, FeatureO32]>;
Daniel Sandersd2409532014-05-07 16:25:22 +0000170
171def : Proc<"mips3", [FeatureMips3, FeatureN64]>;
Daniel Sandersf7b32292014-04-03 12:13:36 +0000172def : Proc<"mips4", [FeatureMips4, FeatureN64]>;
Daniel Sandersd2409532014-05-07 16:25:22 +0000173def : Proc<"mips5", [FeatureMips5, FeatureN64]>;
Daniel Sanders5a1449d2014-02-20 14:58:19 +0000174def : Proc<"mips64", [FeatureMips64, FeatureN64]>;
175def : Proc<"mips64r2", [FeatureMips64r2, FeatureN64]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000176def : Proc<"mips64r6", [FeatureMips64r6, FeatureN64]>;
Daniel Sanders5a1449d2014-02-20 14:58:19 +0000177def : Proc<"mips16", [FeatureMips16, FeatureO32]>;
Kai Nacke93fe5e82014-03-20 11:51:58 +0000178def : Proc<"octeon", [FeatureMips64r2, FeatureN64, FeatureCnMips]>;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +0000179
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000180def MipsAsmParser : AsmParser {
181 let ShouldEmitMatchRegisterName = 0;
Vladimir Medicd3dade22013-08-01 09:25:27 +0000182 let MnemonicContainsDot = 1;
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000183}
Akira Hatanaka9c6028f2011-07-07 23:56:50 +0000184
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000185def MipsAsmParserVariant : AsmParserVariant {
186 int Variant = 0;
187
188 // Recognize hard coded registers.
189 string RegisterPrefix = "$";
190}
191
192def Mips : Target {
193 let InstructionSet = MipsInstrInfo;
194 let AssemblyParsers = [MipsAsmParser];
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000195 let AssemblyParserVariants = [MipsAsmParserVariant];
196}