8bb46884194563920dfe469c9e1ecca5cb27156c
[oota-llvm.git] / lib / Target / Mips / Mips.td
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
16 include "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.
22 class 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 anything else
30   list<Predicate> AdditionalPredicates = [];
31   list<Predicate> Predicates = !listconcat(EncodingPredicates,
32                                            GPRPredicates,
33                                            FGRPredicates,
34                                            AdditionalPredicates);
35 }
36
37 // Like Requires<> but for the AdditionalPredicates list
38 class AdditionalRequires<list<Predicate> preds> {
39   list<Predicate> AdditionalPredicates = preds;
40 }
41
42 //===----------------------------------------------------------------------===//
43 // Register File, Calling Conv, Instruction Descriptions
44 //===----------------------------------------------------------------------===//
45
46 include "MipsRegisterInfo.td"
47 include "MipsSchedule.td"
48 include "MipsInstrInfo.td"
49 include "MipsCallingConv.td"
50
51 def MipsInstrInfo : InstrInfo;
52
53 //===----------------------------------------------------------------------===//
54 // Mips Subtarget features                                                    //
55 //===----------------------------------------------------------------------===//
56
57 def FeatureGP64Bit     : SubtargetFeature<"gp64", "IsGP64bit", "true",
58                                 "General Purpose Registers are 64-bit wide.">;
59 def FeatureFP64Bit     : SubtargetFeature<"fp64", "IsFP64bit", "true",
60                                 "Support 64-bit FP registers.">;
61 def FeatureNaN2008     : SubtargetFeature<"nan2008", "IsNaN2008bit", "true",
62                                 "IEEE 754-2008 NaN encoding.">;
63 def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat",
64                                 "true", "Only supports single precision float">;
65 def FeatureO32         : SubtargetFeature<"o32", "MipsABI", "O32",
66                                 "Enable o32 ABI">;
67 def FeatureN32         : SubtargetFeature<"n32", "MipsABI", "N32",
68                                 "Enable n32 ABI">;
69 def FeatureN64         : SubtargetFeature<"n64", "MipsABI", "N64",
70                                 "Enable n64 ABI">;
71 def FeatureEABI        : SubtargetFeature<"eabi", "MipsABI", "EABI",
72                                 "Enable eabi ABI">;
73 def FeatureVFPU        : SubtargetFeature<"vfpu", "HasVFPU",
74                                 "true", "Enable vector FPU instructions.">;
75 def FeatureSEInReg     : SubtargetFeature<"seinreg", "HasSEInReg", "true",
76                                 "Enable 'signext in register' instructions.">;
77 def FeatureCondMov     : SubtargetFeature<"condmov", "HasCondMov", "true",
78                                 "Enable 'conditional move' instructions.">;
79 def FeatureSwap        : SubtargetFeature<"swap", "HasSwap", "true",
80                                 "Enable 'byte/half swap' instructions.">;
81 def FeatureBitCount    : SubtargetFeature<"bitcount", "HasBitCount", "true",
82                                 "Enable 'count leading bits' instructions.">;
83 def FeatureFPIdx       : SubtargetFeature<"fpidx", "HasFPIdx", "true",
84                                 "Enable 'FP indexed load/store' instructions.">;
85 def FeatureMips32      : SubtargetFeature<"mips32", "MipsArchVersion", "Mips32",
86                                 "Mips32 ISA Support",
87                                 [FeatureCondMov, FeatureBitCount]>;
88 def FeatureMips32r2    : SubtargetFeature<"mips32r2", "MipsArchVersion",
89                                 "Mips32r2", "Mips32r2 ISA Support",
90                                 [FeatureMips32, FeatureSEInReg, FeatureSwap,
91                                  FeatureFPIdx]>;
92 def FeatureMips4       : SubtargetFeature<"mips4", "MipsArchVersion",
93                                 "Mips4", "MIPS IV ISA Support",
94                                 [FeatureGP64Bit, FeatureFP64Bit, FeatureFPIdx,
95                                  FeatureCondMov]>;
96 def FeatureMips64      : SubtargetFeature<"mips64", "MipsArchVersion",
97                                 "Mips64", "Mips64 ISA Support",
98                                 [FeatureMips4, FeatureMips32, FeatureFPIdx]>;
99 def FeatureMips64r2    : SubtargetFeature<"mips64r2", "MipsArchVersion",
100                                 "Mips64r2", "Mips64r2 ISA Support",
101                                 [FeatureMips64, FeatureMips32r2]>;
102
103 def FeatureMips16  : SubtargetFeature<"mips16", "InMips16Mode", "true",
104                                       "Mips16 mode">;
105
106 def FeatureDSP : SubtargetFeature<"dsp", "HasDSP", "true", "Mips DSP ASE">;
107 def FeatureDSPR2 : SubtargetFeature<"dspr2", "HasDSPR2", "true",
108                                     "Mips DSP-R2 ASE", [FeatureDSP]>;
109
110 def FeatureMSA : SubtargetFeature<"msa", "HasMSA", "true", "Mips MSA ASE">;
111
112 def FeatureMicroMips  : SubtargetFeature<"micromips", "InMicroMipsMode", "true",
113                                          "microMips mode">;
114
115 def FeatureCnMips     : SubtargetFeature<"cnmips", "HasCnMips",
116                                 "true", "Octeon cnMIPS Support",
117                                 [FeatureMips64r2]>;
118
119 //===----------------------------------------------------------------------===//
120 // Mips processors supported.
121 //===----------------------------------------------------------------------===//
122
123 class Proc<string Name, list<SubtargetFeature> Features>
124  : Processor<Name, MipsGenericItineraries, Features>;
125
126 def : Proc<"mips32", [FeatureMips32, FeatureO32]>;
127 def : Proc<"mips32r2", [FeatureMips32r2, FeatureO32]>;
128 def : Proc<"mips4", [FeatureMips4, FeatureN64]>;
129 def : Proc<"mips64", [FeatureMips64, FeatureN64]>;
130 def : Proc<"mips64r2", [FeatureMips64r2, FeatureN64]>;
131 def : Proc<"mips16", [FeatureMips16, FeatureO32]>;
132 def : Proc<"octeon", [FeatureMips64r2, FeatureN64, FeatureCnMips]>;
133
134 def MipsAsmParser : AsmParser {
135   let ShouldEmitMatchRegisterName = 0;
136   let MnemonicContainsDot = 1;
137 }
138
139 def MipsAsmParserVariant : AsmParserVariant {
140   int Variant = 0;
141
142   // Recognize hard coded registers.
143   string RegisterPrefix = "$";
144 }
145
146 def Mips : Target {
147   let InstructionSet = MipsInstrInfo;
148   let AssemblyParsers = [MipsAsmParser];
149   let AssemblyParserVariants = [MipsAsmParserVariant];
150 }