blob: c56a2c7c8d182e0c40eb71c2e0e9d1366d788dcc [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- ARMInstrFormats.td - ARM Instruction Formats -------*- tablegen -*-===//
Bob Wilson3968c6a2010-03-23 17:23:59 +00002//
Evan Cheng2d37f192008-08-28 23:39:26 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bob Wilson3968c6a2010-03-23 17:23:59 +00007//
Evan Cheng2d37f192008-08-28 23:39:26 +00008//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// ARM Instruction Format Definitions.
13//
14
15// Format specifies the encoding used by the instruction. This is part of the
16// ad-hoc solution used to emit machine instruction encodings by our machine
17// code emitter.
Bob Wilson69ba1bc2010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng2d37f192008-08-28 23:39:26 +000020}
21
Evan Chengfabdcce2008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng2d37f192008-08-28 23:39:26 +000026
Evan Chengfabdcce2008-11-13 23:36:57 +000027def DPFrm : Format<4>;
Owen Anderson04912702011-07-21 23:38:37 +000028def DPSoRegRegFrm : Format<5>;
Evan Cheng2d37f192008-08-28 23:39:26 +000029
Evan Chengfabdcce2008-11-13 23:36:57 +000030def LdFrm : Format<6>;
31def StFrm : Format<7>;
32def LdMiscFrm : Format<8>;
33def StMiscFrm : Format<9>;
34def LdStMulFrm : Format<10>;
Evan Cheng2d37f192008-08-28 23:39:26 +000035
Johnny Chen0dab68f2010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +000037
Johnny Chen0dab68f2010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson96649842010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000041
Bob Wilson96649842010-08-11 00:01:18 +000042def VFPUnaryFrm : Format<15>;
43def VFPBinaryFrm : Format<16>;
44def VFPConv1Frm : Format<17>;
45def VFPConv2Frm : Format<18>;
46def VFPConv3Frm : Format<19>;
47def VFPConv4Frm : Format<20>;
48def VFPConv5Frm : Format<21>;
49def VFPLdStFrm : Format<22>;
50def VFPLdStMulFrm : Format<23>;
51def VFPMiscFrm : Format<24>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000052
Bob Wilson96649842010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng2d37f192008-08-28 23:39:26 +000055
Bob Wilson96649842010-08-11 00:01:18 +000056def NGetLnFrm : Format<27>;
57def NSetLnFrm : Format<28>;
58def NDupFrm : Format<29>;
59def NLdStFrm : Format<30>;
60def N1RegModImmFrm: Format<31>;
61def N2RegFrm : Format<32>;
62def NVCVTFrm : Format<33>;
63def NVDupLnFrm : Format<34>;
64def N2RegVShLFrm : Format<35>;
65def N2RegVShRFrm : Format<36>;
66def N3RegFrm : Format<37>;
67def N3RegVShFrm : Format<38>;
68def NVExtFrm : Format<39>;
69def NVMulSLFrm : Format<40>;
70def NVTBLFrm : Format<41>;
Owen Anderson04912702011-07-21 23:38:37 +000071def DPSoRegImmFrm : Format<42>;
Johnny Chenf833fad2010-03-20 00:17:00 +000072
Evan Cheng14965762009-07-08 01:46:35 +000073// Misc flags.
74
Bill Wendlingcbb08ca2010-12-01 02:42:55 +000075// The instruction has an Rn register operand.
Evan Cheng14965762009-07-08 01:46:35 +000076// UnaryDP - Indicates this is a unary data processing instruction, i.e.
77// it doesn't have a Rn operand.
78class UnaryDP { bit isUnaryDataProc = 1; }
79
80// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
81// a 16-bit Thumb instruction if certain conditions are met.
82class Xform16Bit { bit canXformTo16Bit = 1; }
Evan Cheng2d37f192008-08-28 23:39:26 +000083
Evan Cheng2d37f192008-08-28 23:39:26 +000084//===----------------------------------------------------------------------===//
Bob Wilsona4d86b62010-03-18 23:57:57 +000085// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Chengb23b50d2009-06-29 07:51:04 +000086//
87
Jim Grosbachec86bac2011-01-18 19:59:19 +000088// FIXME: Once the JIT is MC-ized, these can go away.
Evan Chengb23b50d2009-06-29 07:51:04 +000089// Addressing mode.
Jim Grosbache9298992010-10-05 18:14:55 +000090class AddrMode<bits<5> val> {
91 bits<5> Value = val;
Evan Chengb23b50d2009-06-29 07:51:04 +000092}
Bill Wendlingb70dc872010-08-31 07:50:46 +000093def AddrModeNone : AddrMode<0>;
94def AddrMode1 : AddrMode<1>;
95def AddrMode2 : AddrMode<2>;
96def AddrMode3 : AddrMode<3>;
97def AddrMode4 : AddrMode<4>;
98def AddrMode5 : AddrMode<5>;
99def AddrMode6 : AddrMode<6>;
100def AddrModeT1_1 : AddrMode<7>;
101def AddrModeT1_2 : AddrMode<8>;
102def AddrModeT1_4 : AddrMode<9>;
103def AddrModeT1_s : AddrMode<10>;
104def AddrModeT2_i12 : AddrMode<11>;
105def AddrModeT2_i8 : AddrMode<12>;
106def AddrModeT2_so : AddrMode<13>;
107def AddrModeT2_pc : AddrMode<14>;
Bob Wilsondeb35af2009-07-01 23:16:05 +0000108def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000109def AddrMode_i12 : AddrMode<16>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000110
Evan Chengb23b50d2009-06-29 07:51:04 +0000111// Load / store index mode.
112class IndexMode<bits<2> val> {
113 bits<2> Value = val;
114}
115def IndexModeNone : IndexMode<0>;
116def IndexModePre : IndexMode<1>;
117def IndexModePost : IndexMode<2>;
Bob Wilsonf1e8f7f2010-03-13 07:34:35 +0000118def IndexModeUpd : IndexMode<3>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000119
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000120// Instruction execution domain.
Evan Cheng04ad35b2011-02-22 19:53:14 +0000121class Domain<bits<3> val> {
122 bits<3> Value = val;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000123}
124def GenericDomain : Domain<0>;
125def VFPDomain : Domain<1>; // Instructions in VFP domain only
126def NeonDomain : Domain<2>; // Instructions in Neon domain only
127def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
Evan Cheng97e64282011-02-23 02:35:33 +0000128def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000129
Evan Chengb23b50d2009-06-29 07:51:04 +0000130//===----------------------------------------------------------------------===//
Evan Chengcd4cdd12009-07-11 06:43:01 +0000131// ARM special operands.
132//
133
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000134// ARM imod and iflag operands, used only by the CPS instruction.
135def imod_op : Operand<i32> {
136 let PrintMethod = "printCPSIMod";
137}
138
Jim Grosbacheeaab222011-07-25 20:38:18 +0000139def ProcIFlagsOperand : AsmOperandClass {
140 let Name = "ProcIFlags";
141 let ParserMethod = "parseProcIFlagsOperand";
142}
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000143def iflags_op : Operand<i32> {
144 let PrintMethod = "printCPSIFlag";
145 let ParserMatchClass = ProcIFlagsOperand;
146}
147
Evan Chengcd4cdd12009-07-11 06:43:01 +0000148// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
149// register whose default is 0 (no register).
Jim Grosbacheeaab222011-07-25 20:38:18 +0000150def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
Jim Grosbachf86cd372011-08-19 20:46:54 +0000151def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
Evan Chengcd4cdd12009-07-11 06:43:01 +0000152 (ops (i32 14), (i32 zero_reg))> {
153 let PrintMethod = "printPredicateOperand";
Daniel Dunbard8042b72010-08-11 06:36:53 +0000154 let ParserMatchClass = CondCodeOperand;
Jim Grosbachdbb60f92011-08-19 20:30:19 +0000155 let DecoderMethod = "DecodePredicateOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000156}
157
Tim Northover42180442013-08-22 09:57:11 +0000158// Selectable predicate operand for CMOV instructions. We can't use a normal
159// predicate because the default values interfere with instruction selection. In
160// all other respects it is identical though: pseudo-instruction expansion
161// relies on the MachineOperands being compatible.
162def cmovpred : Operand<i32>, PredicateOp,
163 ComplexPattern<i32, 2, "SelectCMOVPred"> {
164 let MIOperandInfo = (ops i32imm, i32imm);
165 let PrintMethod = "printPredicateOperand";
166}
167
Evan Chengcd4cdd12009-07-11 06:43:01 +0000168// Conditional code result for instructions whose 's' bit is set, e.g. subs.
Jim Grosbacheeaab222011-07-25 20:38:18 +0000169def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
Evan Chengcd4cdd12009-07-11 06:43:01 +0000170def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000171 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000172 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000173 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000174 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000175}
176
177// Same as cc_out except it defaults to setting CPSR.
178def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000179 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000180 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000181 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000182 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000183}
184
Johnny Chen9a3e2392010-03-10 18:59:38 +0000185// ARM special operands for disassembly only.
186//
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000187def SetEndAsmOperand : ImmAsmOperand {
Jim Grosbach0a547702011-07-22 17:44:50 +0000188 let Name = "SetEndImm";
189 let ParserMethod = "parseSetEndImm";
190}
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000191def setend_op : Operand<i32> {
192 let PrintMethod = "printSetendOperand";
Jim Grosbach0a547702011-07-22 17:44:50 +0000193 let ParserMatchClass = SetEndAsmOperand;
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000194}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000195
Jim Grosbacheeaab222011-07-25 20:38:18 +0000196def MSRMaskOperand : AsmOperandClass {
197 let Name = "MSRMask";
198 let ParserMethod = "parseMSRMaskOperand";
199}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000200def msr_mask : Operand<i32> {
201 let PrintMethod = "printMSRMaskOperand";
Owen Anderson60663402011-08-11 20:21:46 +0000202 let DecoderMethod = "DecodeMSRMask";
Bruno Cardoso Lopes9cd43972011-02-18 19:45:59 +0000203 let ParserMatchClass = MSRMaskOperand;
Johnny Chen9a3e2392010-03-10 18:59:38 +0000204}
205
Tim Northoveree843ef2014-08-15 10:47:12 +0000206def BankedRegOperand : AsmOperandClass {
207 let Name = "BankedReg";
208 let ParserMethod = "parseBankedRegOperand";
209}
210def banked_reg : Operand<i32> {
211 let PrintMethod = "printBankedRegOperand";
212 let DecoderMethod = "DecodeBankedReg";
213 let ParserMatchClass = BankedRegOperand;
214}
215
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000216// Shift Right Immediate - A shift right immediate is encoded differently from
217// other shift immediates. The imm6 field is encoded like so:
Bill Wendling3b1459b2011-03-01 01:00:59 +0000218//
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000219// Offset Encoding
220// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
221// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
222// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
223// 64 64 - <imm> is encoded in imm6<5:0>
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000224def shr_imm8_asm_operand : ImmAsmOperand { let Name = "ShrImm8"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000225def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000226 let EncoderMethod = "getShiftRight8Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000227 let DecoderMethod = "DecodeShiftRight8Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000228 let ParserMatchClass = shr_imm8_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000229}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000230def shr_imm16_asm_operand : ImmAsmOperand { let Name = "ShrImm16"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000231def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000232 let EncoderMethod = "getShiftRight16Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000233 let DecoderMethod = "DecodeShiftRight16Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000234 let ParserMatchClass = shr_imm16_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000235}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000236def shr_imm32_asm_operand : ImmAsmOperand { let Name = "ShrImm32"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000237def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000238 let EncoderMethod = "getShiftRight32Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000239 let DecoderMethod = "DecodeShiftRight32Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000240 let ParserMatchClass = shr_imm32_asm_operand;
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000241}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000242def shr_imm64_asm_operand : ImmAsmOperand { let Name = "ShrImm64"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000243def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000244 let EncoderMethod = "getShiftRight64Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000245 let DecoderMethod = "DecodeShiftRight64Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000246 let ParserMatchClass = shr_imm64_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000247}
248
Evan Chengcd4cdd12009-07-11 06:43:01 +0000249//===----------------------------------------------------------------------===//
Jim Grosbach6caa5572011-08-22 18:04:24 +0000250// ARM Assembler alias templates.
251//
252class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
253 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
254class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
255 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
256class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
257 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000258class VFP2InstAlias<string Asm, dag Result, bit Emit = 0b1>
259 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2]>;
Tim Northover5620faf2013-10-24 15:49:39 +0000260class VFP2DPInstAlias<string Asm, dag Result, bit Emit = 0b1>
261 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2,HasDPVFP]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000262class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
263 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
Jim Grosbach0a978ef2011-12-05 19:55:46 +0000264class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
265 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
Jim Grosbach6caa5572011-08-22 18:04:24 +0000266
Jim Grosbach9227f392011-12-13 20:08:32 +0000267
268class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
269 Requires<[HasVFP2]>;
270class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
271 Requires<[HasNEON]>;
272
Jim Grosbach6caa5572011-08-22 18:04:24 +0000273//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000274// ARM Instruction templates.
275//
276
Jim Grosbach6caa5572011-08-22 18:04:24 +0000277
Owen Anderson651b2302011-07-13 23:22:26 +0000278class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000279 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000280 : Instruction {
281 let Namespace = "ARM";
282
Evan Cheng2d37f192008-08-28 23:39:26 +0000283 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000284 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000285 IndexMode IM = im;
286 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000287 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000288 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000289 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000290 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000291 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000292 // The instruction is a 16-bit flag setting Thumb instruction. Used
293 // by the parser to determine whether to require the 'S' suffix on the
294 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
295 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000296
Chris Lattner7ff33462010-10-31 19:22:57 +0000297 // If this is a pseudo instruction, mark it isCodeGenOnly.
298 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000299
Jim Grosbach30694dc2011-08-15 16:52:24 +0000300 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000301 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000302 let TSFlags{6-5} = IndexModeBits;
303 let TSFlags{12-7} = Form;
304 let TSFlags{13} = isUnaryDataProc;
305 let TSFlags{14} = canXformTo16Bit;
306 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000307 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000308
Evan Cheng2d37f192008-08-28 23:39:26 +0000309 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000310 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000311}
312
Johnny Chenc28e6292009-12-15 17:24:14 +0000313class Encoding {
314 field bits<32> Inst;
James Molloyd9ba4fd2012-02-09 10:56:31 +0000315 // Mask of bits that cause an encoding to be UNPREDICTABLE.
316 // If a bit is set, then if the corresponding bit in the
317 // target encoding differs from its value in the "Inst" field,
318 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
319 field bits<32> Unpredictable = 0;
320 // SoftFail is the generic name for this field, but we alias it so
321 // as to make it more obvious what it means in ARM-land.
322 field bits<32> SoftFail = Unpredictable;
Johnny Chenc28e6292009-12-15 17:24:14 +0000323}
324
Owen Anderson651b2302011-07-13 23:22:26 +0000325class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000326 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000327 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
328 let DecoderNamespace = "ARM";
329}
Johnny Chenc28e6292009-12-15 17:24:14 +0000330
331// This Encoding-less class is used by Thumb1 to specify the encoding bits later
332// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000333class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000334 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000335 : InstTemplate<am, sz, im, f, d, cstr, itin> {
336 let DecoderNamespace = "Thumb";
337}
Johnny Chenc28e6292009-12-15 17:24:14 +0000338
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000339// Pseudo-instructions for alternate assembly syntax (never used by codegen).
340// These are aliases that require C++ handling to convert to the target
341// instruction, while InstAliases can be handled directly by tblgen.
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000342class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000343 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
344 "", NoItinerary> {
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000345 let OutOperandList = oops;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000346 let InOperandList = iops;
347 let Pattern = [];
348 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000349 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000350 let isPseudo = 1;
351}
352
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000353class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
354 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
355class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
356 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
357class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
358 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
359class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
360 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
361class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
362 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000363
364// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000365class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000366 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000367 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000368 let OutOperandList = oops;
369 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000370 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000371 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000372 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000373}
374
Jim Grosbachcfb66202010-11-18 01:15:56 +0000375// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000376class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000377 list<dag> pattern>
378 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000379 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000380 list<Predicate> Predicates = [IsARM];
381}
382
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000383// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000384class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000385 list<dag> pattern>
386 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000387 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000388 list<Predicate> Predicates = [IsThumb];
389}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000390
Jim Grosbachd42257c2010-12-15 18:48:45 +0000391// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000392class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000393 list<dag> pattern>
394 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000395 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000396 list<Predicate> Predicates = [IsThumb2];
397}
Jim Grosbach95dee402011-07-08 17:40:42 +0000398
Owen Anderson651b2302011-07-13 23:22:26 +0000399class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000400 InstrItinClass itin, list<dag> pattern,
401 dag Result>
402 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
403 PseudoInstExpansion<Result>;
404
Owen Anderson651b2302011-07-13 23:22:26 +0000405class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000406 InstrItinClass itin, list<dag> pattern,
407 dag Result>
408 : tPseudoInst<oops, iops, sz, itin, pattern>,
409 PseudoInstExpansion<Result>;
410
Owen Anderson651b2302011-07-13 23:22:26 +0000411class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000412 InstrItinClass itin, list<dag> pattern,
413 dag Result>
414 : t2PseudoInst<oops, iops, sz, itin, pattern>,
415 PseudoInstExpansion<Result>;
416
Evan Cheng2d37f192008-08-28 23:39:26 +0000417// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000418class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000419 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000420 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000421 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000422 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000423 bits<4> p;
424 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000425 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000426 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000427 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000428 let Pattern = pattern;
429 list<Predicate> Predicates = [IsARM];
430}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000431
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000432// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000433class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000434 IndexMode im, Format f, InstrItinClass itin,
435 string opc, string asm, string cstr,
436 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000437 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
438 let OutOperandList = oops;
439 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000440 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000441 let Pattern = pattern;
442 let isPredicable = 0;
443 list<Predicate> Predicates = [IsARM];
444}
Evan Cheng2d37f192008-08-28 23:39:26 +0000445
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000446// Same as I except it can optionally modify CPSR. Note it's modeled as an input
447// operand since by default it's a zero register. It will become an implicit def
448// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000449class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000450 IndexMode im, Format f, InstrItinClass itin,
451 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000452 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000453 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000454 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000455 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000456 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000457 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000458
Evan Cheng2d37f192008-08-28 23:39:26 +0000459 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000460 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000461 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000462 let Pattern = pattern;
463 list<Predicate> Predicates = [IsARM];
464}
465
Evan Chenga2827232008-09-01 07:19:00 +0000466// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000467class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000468 IndexMode im, Format f, InstrItinClass itin,
469 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000470 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000471 let OutOperandList = oops;
472 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000473 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000474 let Pattern = pattern;
475 list<Predicate> Predicates = [IsARM];
476}
477
David Goodwinb062c232009-08-06 16:52:47 +0000478class AI<dag oops, dag iops, Format f, InstrItinClass itin,
479 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000480 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000481 opc, asm, "", pattern>;
482class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
483 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000484 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000485 opc, asm, "", pattern>;
486class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000487 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000488 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000489 asm, "", pattern>;
David Peixottob76f55f2014-01-27 21:39:04 +0000490class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
491 string asm, list<dag> pattern>
492 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
493 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000494class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000495 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000496 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000497 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000498
499// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000500class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
501 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000502 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000503 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000504 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000505}
David Goodwinb062c232009-08-06 16:52:47 +0000506class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
507 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000508 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000509 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000510 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000511}
Evan Chengfa558782008-09-01 08:25:56 +0000512
513// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000514class JTI<dag oops, dag iops, InstrItinClass itin,
515 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000516 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000517 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000518
Joey Goulye6d165c2013-08-27 17:38:16 +0000519class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000520 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000521 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000522 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000523 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000524 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000525 let Inst{27-23} = 0b00011;
526 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000527 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000528 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000529 let Inst{15-12} = Rt;
Joey Goulye6d165c2013-08-27 17:38:16 +0000530 let Inst{11-10} = 0b11;
531 let Inst{9-8} = opcod2;
532 let Inst{7-0} = 0b10011111;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000533}
Joey Goulye6d165c2013-08-27 17:38:16 +0000534class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000535 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000536 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000537 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000538 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000539 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000540 let Inst{27-23} = 0b00011;
541 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000542 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000543 let Inst{19-16} = addr;
Joey Goulye6d165c2013-08-27 17:38:16 +0000544 let Inst{11-10} = 0b11;
545 let Inst{9-8} = opcod2;
546 let Inst{7-4} = 0b1001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000547 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000548}
Joey Goulye6d165c2013-08-27 17:38:16 +0000549// Atomic load/store instructions
550class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
551 string opc, string asm, list<dag> pattern>
552 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
553
554class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
555 string opc, string asm, list<dag> pattern>
556 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
557 bits<4> Rd;
558 let Inst{15-12} = Rd;
559}
560
561// Exclusive load/store instructions
562
563class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
564 string opc, string asm, list<dag> pattern>
565 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000566 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
Joey Goulye6d165c2013-08-27 17:38:16 +0000567
568class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
569 string opc, string asm, list<dag> pattern>
570 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000571 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
Joey Goulye6d165c2013-08-27 17:38:16 +0000572 bits<4> Rd;
573 let Inst{15-12} = Rd;
574}
575
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000576class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000577 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000578 bits<4> Rt;
579 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000580 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000581 let Inst{27-23} = 0b00010;
582 let Inst{22} = b;
583 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000584 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000585 let Inst{15-12} = Rt;
586 let Inst{11-4} = 0b00001001;
587 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000588
Silviu Barangaca45af92012-04-18 14:18:57 +0000589 let Unpredictable{11-8} = 0b1111;
Owen Andersondde461c2011-10-28 18:02:13 +0000590 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000591}
Joey Goulye6d165c2013-08-27 17:38:16 +0000592// Acquire/Release load/store instructions
593class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
594 string opc, string asm, list<dag> pattern>
595 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000596 Requires<[IsARM, HasAcquireRelease]>;
Joey Goulye6d165c2013-08-27 17:38:16 +0000597
598class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
599 string opc, string asm, list<dag> pattern>
600 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000601 Requires<[IsARM, HasAcquireRelease]> {
Joey Goulye6d165c2013-08-27 17:38:16 +0000602 let Inst{15-12} = 0b1111;
603}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000604
Evan Cheng624844b2008-09-01 01:51:14 +0000605// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000606class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
607 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000608 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000609 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000610 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000611 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000612}
David Goodwinb062c232009-08-06 16:52:47 +0000613class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
614 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000615 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000616 opc, asm, "", pattern> {
617 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000618 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000619}
620class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000621 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000622 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000623 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000624 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000625 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000626}
Evan Cheng624844b2008-09-01 01:51:14 +0000627
Evan Chengcccca872008-09-01 01:27:33 +0000628// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000629
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000630// LDR/LDRB/STR/STRB/...
631class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000632 Format f, InstrItinClass itin, string opc, string asm,
633 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000634 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000635 "", pattern> {
636 let Inst{27-25} = op;
637 let Inst{24} = 1; // 24 == P
638 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000639 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000640 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000641 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000642}
Jim Grosbach2f790742010-11-13 00:35:48 +0000643// Indexed load/stores
644class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000645 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000646 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000647 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000648 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000649 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000650 let Inst{27-26} = 0b01;
651 let Inst{24} = isPre; // P bit
652 let Inst{22} = isByte; // B bit
653 let Inst{21} = isPre; // W bit
654 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000655 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000656}
Owen Anderson2aedba62011-07-26 20:54:26 +0000657class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000658 IndexMode im, Format f, InstrItinClass itin, string opc,
659 string asm, string cstr, list<dag> pattern>
660 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
661 pattern> {
662 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000663 // {12} isAdd
664 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000665 bits<14> offset;
666 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000667 let Inst{25} = 1;
668 let Inst{23} = offset{12};
669 let Inst{19-16} = Rn;
670 let Inst{11-5} = offset{11-5};
671 let Inst{4} = 0;
672 let Inst{3-0} = offset{3-0};
673}
674
675class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
676 IndexMode im, Format f, InstrItinClass itin, string opc,
677 string asm, string cstr, list<dag> pattern>
678 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
679 pattern> {
680 // AM2 store w/ two operands: (GPR, am2offset)
681 // {12} isAdd
682 // {11-0} imm12/Rm
683 bits<14> offset;
684 bits<4> Rn;
685 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000686 let Inst{23} = offset{12};
687 let Inst{19-16} = Rn;
688 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000689}
Owen Anderson2aedba62011-07-26 20:54:26 +0000690
691
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000692// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
693// but for now use this class for STRT and STRBT.
694class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
695 IndexMode im, Format f, InstrItinClass itin, string opc,
696 string asm, string cstr, list<dag> pattern>
697 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
698 pattern> {
699 // AM2 store w/ two operands: (GPR, am2offset)
700 // {17-14} Rn
701 // {13} 1 == Rm, 0 == imm12
702 // {12} isAdd
703 // {11-0} imm12/Rm
704 bits<18> addr;
705 let Inst{25} = addr{13};
706 let Inst{23} = addr{12};
707 let Inst{19-16} = addr{17-14};
708 let Inst{11-0} = addr{11-0};
709}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000710
Evan Cheng624844b2008-09-01 01:51:14 +0000711// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000712class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
713 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000714 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000715 opc, asm, "", pattern> {
716 bits<14> addr;
717 bits<4> Rt;
718 let Inst{27-25} = 0b000;
719 let Inst{24} = 1; // P bit
720 let Inst{23} = addr{8}; // U bit
721 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
722 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000723 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000724 let Inst{19-16} = addr{12-9}; // Rn
725 let Inst{15-12} = Rt; // Rt
726 let Inst{11-8} = addr{7-4}; // imm7_4/zero
727 let Inst{7-4} = op;
728 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000729
730 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000731}
Evan Cheng169eccc2008-09-01 07:00:14 +0000732
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000733class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000734 IndexMode im, Format f, InstrItinClass itin, string opc,
735 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000736 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000737 opc, asm, cstr, pattern> {
738 bits<4> Rt;
739 let Inst{27-25} = 0b000;
740 let Inst{24} = isPre; // P bit
741 let Inst{21} = isPre; // W bit
742 let Inst{20} = op20; // L bit
743 let Inst{15-12} = Rt; // Rt
744 let Inst{7-4} = op;
745}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000746
747// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
748// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000749class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000750 IndexMode im, Format f, InstrItinClass itin, string opc,
751 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000752 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000753 // {13} 1 == imm8, 0 == Rm
754 // {12-9} Rn
755 // {8} isAdd
756 // {7-4} imm7_4/zero
757 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000758 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000759 bits<4> Rt;
760 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000761 let Inst{24} = 0; // P bit
762 let Inst{21} = 1;
763 let Inst{20} = isLoad; // L bit
764 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000765 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000766 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000767}
768
Evan Cheng169eccc2008-09-01 07:00:14 +0000769// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000770class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000771 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000772 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000773 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000774 bits<14> addr;
775 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000776 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000777 let Inst{24} = 1; // P bit
778 let Inst{23} = addr{8}; // U bit
779 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
780 let Inst{21} = 0; // W bit
781 let Inst{20} = 0; // L bit
782 let Inst{19-16} = addr{12-9}; // Rn
783 let Inst{15-12} = Rt; // Rt
784 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000785 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000786 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000787 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000788}
Evan Cheng169eccc2008-09-01 07:00:14 +0000789
Evan Cheng624844b2008-09-01 01:51:14 +0000790// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000791class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
792 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000793 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000794 bits<4> p;
795 bits<16> regs;
796 bits<4> Rn;
797 let Inst{31-28} = p;
798 let Inst{27-25} = 0b100;
799 let Inst{22} = 0; // S bit
800 let Inst{19-16} = Rn;
801 let Inst{15-0} = regs;
802}
Evan Cheng2d37f192008-08-28 23:39:26 +0000803
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000804// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000805class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
806 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000807 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000808 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000809 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000810 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000811 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000812}
David Goodwinb062c232009-08-06 16:52:47 +0000813class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
814 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000815 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000816 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000817 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000818 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000819}
820
821// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000822class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
823 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000824 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000825 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000826 bits<4> Rd;
827 bits<4> Rn;
828 bits<4> Rm;
829 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000830 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000831 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000832 let Inst{19-16} = Rd;
833 let Inst{11-8} = Rm;
834 let Inst{3-0} = Rn;
835}
836// MSW multiple w/ Ra operand
837class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
838 InstrItinClass itin, string opc, string asm, list<dag> pattern>
839 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
840 bits<4> Ra;
841 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000842}
Evan Cheng2d37f192008-08-28 23:39:26 +0000843
Evan Cheng36ae4032008-11-06 03:35:07 +0000844// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000845class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000846 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000847 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000848 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000849 bits<4> Rn;
850 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000851 let Inst{4} = 0;
852 let Inst{7} = 1;
853 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000854 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000855 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000856 let Inst{11-8} = Rm;
857 let Inst{3-0} = Rn;
858}
859class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
860 InstrItinClass itin, string opc, string asm, list<dag> pattern>
861 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
862 bits<4> Rd;
863 let Inst{19-16} = Rd;
864}
865
866// AMulxyI with Ra operand
867class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
868 InstrItinClass itin, string opc, string asm, list<dag> pattern>
869 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
870 bits<4> Ra;
871 let Inst{15-12} = Ra;
872}
873// SMLAL*
874class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
875 InstrItinClass itin, string opc, string asm, list<dag> pattern>
876 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
877 bits<4> RdLo;
878 bits<4> RdHi;
879 let Inst{19-16} = RdHi;
880 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000881}
882
Evan Cheng49d66522008-11-06 22:15:19 +0000883// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000884class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
885 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000886 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000887 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000888 // All AExtI instructions have Rd and Rm register operands.
889 bits<4> Rd;
890 bits<4> Rm;
891 let Inst{15-12} = Rd;
892 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000893 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000894 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000895 let Inst{27-20} = opcod;
Silviu Barangaddc67a72012-05-11 09:28:27 +0000896
897 let Unpredictable{9-8} = 0b11;
Evan Cheng49d66522008-11-06 22:15:19 +0000898}
899
Evan Cheng98dc53e2008-11-07 01:41:35 +0000900// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000901class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
902 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000903 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000904 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000905 bits<4> Rd;
906 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000907 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000908 let Inst{19-16} = 0b1111;
909 let Inst{15-12} = Rd;
910 let Inst{11-8} = 0b1111;
911 let Inst{7-4} = opc7_4;
912 let Inst{3-0} = Rm;
913}
914
Bob Wilsone8a549c2012-09-29 21:43:49 +0000915// Division instructions.
916class ADivA1I<bits<3> opcod, dag oops, dag iops,
917 InstrItinClass itin, string opc, string asm, list<dag> pattern>
918 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
919 opc, asm, "", pattern> {
920 bits<4> Rd;
921 bits<4> Rn;
922 bits<4> Rm;
923 let Inst{27-23} = 0b01110;
924 let Inst{22-20} = opcod;
925 let Inst{19-16} = Rd;
926 let Inst{15-12} = 0b1111;
927 let Inst{11-8} = Rm;
928 let Inst{7-4} = 0b0001;
929 let Inst{3-0} = Rn;
930}
931
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000932// PKH instructions
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000933def PKHLSLAsmOperand : ImmAsmOperand {
Jim Grosbach27c1e252011-07-21 17:23:04 +0000934 let Name = "PKHLSLImm";
935 let ParserMethod = "parsePKHLSLImm";
936}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000937def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
938 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000939 let ParserMatchClass = PKHLSLAsmOperand;
940}
941def PKHASRAsmOperand : AsmOperandClass {
942 let Name = "PKHASRImm";
943 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000944}
945def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
946 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000947 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000948}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000949
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000950class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
951 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000952 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000953 opc, asm, "", pattern> {
954 bits<4> Rd;
955 bits<4> Rn;
956 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000957 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000958 let Inst{27-20} = opcod;
959 let Inst{19-16} = Rn;
960 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000961 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000962 let Inst{6} = tb;
963 let Inst{5-4} = 0b01;
964 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000965}
966
Evan Cheng2d37f192008-08-28 23:39:26 +0000967//===----------------------------------------------------------------------===//
968
969// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
970class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
971 list<Predicate> Predicates = [IsARM];
972}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000973class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
974 list<Predicate> Predicates = [IsARM, HasV5T];
975}
Evan Cheng2d37f192008-08-28 23:39:26 +0000976class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
977 list<Predicate> Predicates = [IsARM, HasV5TE];
978}
Bob Wilsone8a549c2012-09-29 21:43:49 +0000979// ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
980class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
981 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
982}
Evan Cheng2d37f192008-08-28 23:39:26 +0000983class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
984 list<Predicate> Predicates = [IsARM, HasV6];
985}
James Molloyfa041152015-03-23 16:15:16 +0000986class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
987 list<Predicate> Predicates = [HasVFP2];
988}
989class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
990 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
991}
Evan Chengee98fa92008-08-29 06:41:12 +0000992//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000993// Thumb Instruction Format Definitions.
994//
995
Owen Anderson651b2302011-07-13 23:22:26 +0000996class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000997 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000998 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000999 let OutOperandList = oops;
1000 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001001 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +00001002 let Pattern = pattern;
1003 list<Predicate> Predicates = [IsThumb];
1004}
1005
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001006// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +00001007class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001008 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001009
Evan Cheng7cc6aca2009-08-04 23:47:55 +00001010// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001011class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1012 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001013 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +00001014 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +00001015
Johnny Chenc28e6292009-12-15 17:24:14 +00001016// tBL, tBX 32-bit instructions
1017class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001018 dag oops, dag iops, InstrItinClass itin, string asm,
1019 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001020 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001021 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +00001022 let Inst{31-27} = opcod1;
1023 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001024 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +00001025}
Evan Chengee98fa92008-08-29 06:41:12 +00001026
1027// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001028class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1029 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001030 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001031
Evan Chengbec1dba892009-06-23 19:38:13 +00001032// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +00001033class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001034 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001035 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001036 let OutOperandList = oops;
1037 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001038 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +00001039 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001040 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +00001041}
1042
David Goodwinb062c232009-08-06 16:52:47 +00001043class T1I<dag oops, dag iops, InstrItinClass itin,
1044 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001045 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001046class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1047 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001048 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001049
1050// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001051class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001052 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001053 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001054 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001055
1056// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +00001057class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001058 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001059 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001060 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001061 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1062 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001063 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001064 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +00001065 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001066 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +00001067 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +00001068}
1069
David Goodwinb062c232009-08-06 16:52:47 +00001070class T1sI<dag oops, dag iops, InstrItinClass itin,
1071 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001072 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001073
1074// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001075class T1sIt<dag oops, dag iops, InstrItinClass itin,
1076 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001077 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +00001078 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001079
1080// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +00001081class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001082 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001083 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001084 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001085 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001086 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001087 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001088 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001089 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +00001090}
1091
David Goodwinb062c232009-08-06 16:52:47 +00001092class T1pI<dag oops, dag iops, InstrItinClass itin,
1093 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001094 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001095
1096// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001097class T1pIt<dag oops, dag iops, InstrItinClass itin,
1098 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001099 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +00001100 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001101
Bob Wilson3968c6a2010-03-23 17:23:59 +00001102class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001103 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001104 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001105
Johnny Chen466231a2009-12-16 02:32:54 +00001106class Encoding16 : Encoding {
1107 let Inst{31-16} = 0x0000;
1108}
1109
Johnny Chenc28e6292009-12-15 17:24:14 +00001110// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +00001111class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001112 let Inst{15-10} = opcode;
1113}
1114
1115// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001116class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001117 let Inst{15-14} = 0b00;
1118 let Inst{13-9} = opcode;
1119}
1120
1121// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001122class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001123 let Inst{15-10} = 0b010000;
1124 let Inst{9-6} = opcode;
1125}
1126
1127// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001128class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001129 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001130 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001131}
1132
1133// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001134class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001135 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001136 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001137}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001138class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001139
Eric Christopher9b67db82011-05-27 03:50:53 +00001140class T1BranchCond<bits<4> opcode> : Encoding16 {
1141 let Inst{15-12} = opcode;
1142}
1143
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001144// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001145// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001146//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001147// 0b0110 => Immediate, 4 bytes
1148// 0b1000 => Immediate, 2 bytes
1149// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001150class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1151 InstrItinClass itin, string opc, string asm,
1152 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001153 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001154 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001155 bits<3> Rt;
1156 bits<8> addr;
1157 let Inst{8-6} = addr{5-3}; // Rm
1158 let Inst{5-3} = addr{2-0}; // Rn
1159 let Inst{2-0} = Rt;
1160}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001161class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1162 InstrItinClass itin, string opc, string asm,
1163 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001164 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001165 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001166 bits<3> Rt;
1167 bits<8> addr;
1168 let Inst{10-6} = addr{7-3}; // imm5
1169 let Inst{5-3} = addr{2-0}; // Rn
1170 let Inst{2-0} = Rt;
1171}
1172
Johnny Chenc28e6292009-12-15 17:24:14 +00001173// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001174class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001175 let Inst{15-12} = 0b1011;
1176 let Inst{11-5} = opcode;
1177}
1178
Evan Chengd76f0be2009-06-25 02:08:06 +00001179// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001180class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001181 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001182 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001183 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001184 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001185 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001186 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001187 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001188 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001189 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001190}
1191
Bill Wendlingb70dc872010-08-31 07:50:46 +00001192// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1193// input operand since by default it's a zero register. It will become an
1194// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001195//
Evan Chengd76f0be2009-06-25 02:08:06 +00001196// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1197// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001198class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001199 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001200 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001201 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001202 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1203 let Inst{20} = s;
1204
Evan Chengd76f0be2009-06-25 02:08:06 +00001205 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001206 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001207 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001208 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001209 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001210 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001211}
1212
1213// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001214class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001215 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001216 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001217 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001218 let OutOperandList = oops;
1219 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001220 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001221 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001222 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001223 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001224}
1225
Owen Anderson651b2302011-07-13 23:22:26 +00001226class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001227 InstrItinClass itin,
1228 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001229 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1230 let OutOperandList = oops;
1231 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001232 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001233 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001234 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001235 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001236}
1237
David Goodwinb062c232009-08-06 16:52:47 +00001238class T2I<dag oops, dag iops, InstrItinClass itin,
1239 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001240 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001241class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1242 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001243 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001244class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1245 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001246 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001247class T2Iso<dag oops, dag iops, InstrItinClass itin,
1248 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001249 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001250class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1251 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001252 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001253class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001254 string opc, string asm, string cstr, list<dag> pattern>
1255 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001256 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001257 bits<4> Rt;
1258 bits<4> Rt2;
1259 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001260 let Inst{31-25} = 0b1110100;
1261 let Inst{24} = P;
1262 let Inst{23} = addr{8};
1263 let Inst{22} = 1;
1264 let Inst{21} = W;
1265 let Inst{20} = isLoad;
1266 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001267 let Inst{15-12} = Rt{3-0};
1268 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001269 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001270}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001271class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1272 InstrItinClass itin, string opc, string asm, string cstr,
1273 list<dag> pattern>
1274 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001275 pattern> {
1276 bits<4> Rt;
1277 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001278 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001279 bits<9> imm;
1280 let Inst{31-25} = 0b1110100;
1281 let Inst{24} = P;
1282 let Inst{23} = imm{8};
1283 let Inst{22} = 1;
1284 let Inst{21} = W;
1285 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001286 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001287 let Inst{15-12} = Rt{3-0};
1288 let Inst{11-8} = Rt2{3-0};
1289 let Inst{7-0} = imm{7-0};
1290}
1291
David Goodwinb062c232009-08-06 16:52:47 +00001292class T2sI<dag oops, dag iops, InstrItinClass itin,
1293 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001294 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001295
David Goodwinb062c232009-08-06 16:52:47 +00001296class T2XI<dag oops, dag iops, InstrItinClass itin,
1297 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001298 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001299class T2JTI<dag oops, dag iops, InstrItinClass itin,
1300 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001301 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001302
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001303// Move to/from coprocessor instructions
Tim Northover2c45a382013-06-26 16:52:40 +00001304class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1305 list<dag> pattern>
1306 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001307 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001308}
1309
Bob Wilson947f04b2010-03-13 01:08:20 +00001310// Two-address instructions
1311class T2XIt<dag oops, dag iops, InstrItinClass itin,
1312 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001313 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001314
Jim Grosbachc086f682011-09-08 00:39:19 +00001315// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1316class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001317 dag oops, dag iops,
1318 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001319 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001320 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001321 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001322 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001323 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001324 let Pattern = pattern;
1325 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001326 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001327
1328 bits<4> Rt;
1329 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001330 let Inst{31-27} = 0b11111;
1331 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001332 let Inst{24} = signed;
1333 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001334 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001335 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001336 let Inst{19-16} = addr{12-9};
1337 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001338 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001339 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001340 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001341 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001342 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001343 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001344
1345 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001346}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001347
Jim Grosbachc086f682011-09-08 00:39:19 +00001348// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1349class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1350 dag oops, dag iops,
1351 AddrMode am, IndexMode im, InstrItinClass itin,
1352 string opc, string asm, string cstr, list<dag> pattern>
1353 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1354 let OutOperandList = oops;
1355 let InOperandList = !con(iops, (ins pred:$p));
1356 let AsmString = !strconcat(opc, "${p}", asm);
1357 let Pattern = pattern;
1358 list<Predicate> Predicates = [IsThumb2];
1359 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001360
Owen Andersone22c7322010-11-30 00:14:31 +00001361 bits<4> Rt;
1362 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001363 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001364 let Inst{31-27} = 0b11111;
1365 let Inst{26-25} = 0b00;
1366 let Inst{24} = signed;
1367 let Inst{23} = 0;
1368 let Inst{22-21} = opcod;
1369 let Inst{20} = load;
1370 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001371 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001372 let Inst{11} = 1;
1373 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1374 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001375 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001376 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001377 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001378
1379 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001380}
1381
David Goodwine5b969f2009-07-27 19:59:26 +00001382// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1383class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001384 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001385}
1386
1387// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1388class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001389 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001390}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001391
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001392// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1393class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1394 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1395}
1396
Evan Chengeab9ca72009-06-27 02:26:13 +00001397// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1398class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001399 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001400}
1401
Evan Chengee98fa92008-08-29 06:41:12 +00001402//===----------------------------------------------------------------------===//
1403
Evan Chengac2af2f2008-11-11 02:11:05 +00001404//===----------------------------------------------------------------------===//
1405// ARM VFP Instruction templates.
1406//
1407
David Goodwin81cdd212009-07-10 17:03:29 +00001408// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001409class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001410 IndexMode im, Format f, InstrItinClass itin,
1411 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001412 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001413 bits<4> p;
1414 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001415 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001416 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001417 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001418 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001419 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001420 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001421 list<Predicate> Predicates = [HasVFP2];
1422}
1423
1424// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001425class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001426 IndexMode im, Format f, InstrItinClass itin,
1427 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001428 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001429 bits<4> p;
1430 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001431 let OutOperandList = oops;
1432 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001433 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001434 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001435 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001436 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001437 list<Predicate> Predicates = [HasVFP2];
1438}
1439
David Goodwinb062c232009-08-06 16:52:47 +00001440class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1441 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001442 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001443 opc, asm, "", pattern> {
1444 let PostEncoderMethod = "VFPThumb2PostEncoder";
1445}
David Goodwin81cdd212009-07-10 17:03:29 +00001446
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001447// ARM VFP addrmode5 loads and stores
1448class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001449 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001450 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001451 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001452 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001453 // Instruction operands.
1454 bits<5> Dd;
1455 bits<13> addr;
1456
1457 // Encode instruction operands.
1458 let Inst{23} = addr{8}; // U (add = (U == '1'))
1459 let Inst{22} = Dd{4};
1460 let Inst{19-16} = addr{12-9}; // Rn
1461 let Inst{15-12} = Dd{3-0};
1462 let Inst{7-0} = addr{7-0}; // imm8
1463
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001464 let Inst{27-24} = opcod1;
1465 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001466 let Inst{11-9} = 0b101;
1467 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001468
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001469 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001470 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001471}
1472
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001473class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001474 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001475 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001476 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001477 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001478 // Instruction operands.
1479 bits<5> Sd;
1480 bits<13> addr;
1481
1482 // Encode instruction operands.
1483 let Inst{23} = addr{8}; // U (add = (U == '1'))
1484 let Inst{22} = Sd{0};
1485 let Inst{19-16} = addr{12-9}; // Rn
1486 let Inst{15-12} = Sd{4-1};
1487 let Inst{7-0} = addr{7-0}; // imm8
1488
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001489 let Inst{27-24} = opcod1;
1490 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001491 let Inst{11-9} = 0b101;
1492 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001493
1494 // Loads & stores operate on both NEON and VFP pipelines.
1495 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001496}
1497
Oliver Stannard65b85382016-01-25 10:26:26 +00001498class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1499 InstrItinClass itin,
1500 string opc, string asm, list<dag> pattern>
1501 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1502 VFPLdStFrm, itin, opc, asm, "", pattern> {
1503 list<Predicate> Predicates = [HasFullFP16];
1504
1505 // Instruction operands.
1506 bits<5> Sd;
1507 bits<13> addr;
1508
1509 // Encode instruction operands.
1510 let Inst{23} = addr{8}; // U (add = (U == '1'))
1511 let Inst{22} = Sd{0};
1512 let Inst{19-16} = addr{12-9}; // Rn
1513 let Inst{15-12} = Sd{4-1};
1514 let Inst{7-0} = addr{7-0}; // imm8
1515
1516 let Inst{27-24} = opcod1;
1517 let Inst{21-20} = opcod2;
1518 let Inst{11-8} = 0b1001; // Half precision
1519
1520 // Loads & stores operate on both NEON and VFP pipelines.
1521 let D = VFPNeonDomain;
1522}
1523
Bob Wilson6b853c32010-09-16 00:31:02 +00001524// VFP Load / store multiple pseudo instructions.
1525class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1526 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001527 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001528 cstr, itin> {
1529 let OutOperandList = oops;
1530 let InOperandList = !con(iops, (ins pred:$p));
1531 let Pattern = pattern;
1532 list<Predicate> Predicates = [HasVFP2];
1533}
1534
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001535// Load / store multiple
Tim Northover4173e292013-05-31 15:55:51 +00001536
1537// Unknown precision
1538class AXXI4<dag oops, dag iops, IndexMode im,
1539 string asm, string cstr, list<dag> pattern>
1540 : VFPXI<oops, iops, AddrMode4, 4, im,
1541 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1542 // Instruction operands.
1543 bits<4> Rn;
1544 bits<13> regs;
1545
1546 // Encode instruction operands.
1547 let Inst{19-16} = Rn;
1548 let Inst{22} = 0;
1549 let Inst{15-12} = regs{11-8};
1550 let Inst{7-1} = regs{7-1};
1551
1552 let Inst{27-25} = 0b110;
1553 let Inst{11-8} = 0b1011;
1554 let Inst{0} = 1;
1555}
1556
1557// Double precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001558class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001559 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001560 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001561 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001562 // Instruction operands.
1563 bits<4> Rn;
1564 bits<13> regs;
1565
1566 // Encode instruction operands.
1567 let Inst{19-16} = Rn;
1568 let Inst{22} = regs{12};
1569 let Inst{15-12} = regs{11-8};
Tim Northover4173e292013-05-31 15:55:51 +00001570 let Inst{7-1} = regs{7-1};
Bill Wendling345b48f2010-11-17 00:45:23 +00001571
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001572 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001573 let Inst{11-9} = 0b101;
1574 let Inst{8} = 1; // Double precision
Tim Northover4173e292013-05-31 15:55:51 +00001575 let Inst{0} = 0;
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001576}
1577
Tim Northover4173e292013-05-31 15:55:51 +00001578// Single Precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001579class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001580 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001581 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001582 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001583 // Instruction operands.
1584 bits<4> Rn;
1585 bits<13> regs;
1586
1587 // Encode instruction operands.
1588 let Inst{19-16} = Rn;
1589 let Inst{22} = regs{8};
1590 let Inst{15-12} = regs{12-9};
1591 let Inst{7-0} = regs{7-0};
1592
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001593 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001594 let Inst{11-9} = 0b101;
1595 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001596}
1597
Evan Chengac2af2f2008-11-11 02:11:05 +00001598// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001599class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1600 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1601 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001602 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001603 // Instruction operands.
1604 bits<5> Dd;
1605 bits<5> Dm;
1606
1607 // Encode instruction operands.
1608 let Inst{3-0} = Dm{3-0};
1609 let Inst{5} = Dm{4};
1610 let Inst{15-12} = Dd{3-0};
1611 let Inst{22} = Dd{4};
1612
Johnny Chen34a6afc2010-01-29 23:21:10 +00001613 let Inst{27-23} = opcod1;
1614 let Inst{21-20} = opcod2;
1615 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001616 let Inst{11-9} = 0b101;
1617 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001618 let Inst{7-6} = opcod4;
1619 let Inst{4} = opcod5;
Tim Northover5620faf2013-10-24 15:49:39 +00001620
1621 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001622}
1623
Joey Gouly0f12aa22013-07-09 11:26:18 +00001624// Double precision, unary, not-predicated
1625class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1626 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1627 string asm, list<dag> pattern>
1628 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1629 // Instruction operands.
1630 bits<5> Dd;
1631 bits<5> Dm;
1632
1633 let Inst{31-28} = 0b1111;
1634
1635 // Encode instruction operands.
1636 let Inst{3-0} = Dm{3-0};
1637 let Inst{5} = Dm{4};
1638 let Inst{15-12} = Dd{3-0};
1639 let Inst{22} = Dd{4};
1640
1641 let Inst{27-23} = opcod1;
1642 let Inst{21-20} = opcod2;
1643 let Inst{19-16} = opcod3;
1644 let Inst{11-9} = 0b101;
1645 let Inst{8} = 1; // Double precision
1646 let Inst{7-6} = opcod4;
1647 let Inst{4} = opcod5;
1648}
1649
Evan Chengac2af2f2008-11-11 02:11:05 +00001650// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001651class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001652 dag iops, InstrItinClass itin, string opc, string asm,
1653 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001654 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001655 // Instruction operands.
1656 bits<5> Dd;
1657 bits<5> Dn;
1658 bits<5> Dm;
1659
1660 // Encode instruction operands.
1661 let Inst{3-0} = Dm{3-0};
1662 let Inst{5} = Dm{4};
1663 let Inst{19-16} = Dn{3-0};
1664 let Inst{7} = Dn{4};
1665 let Inst{15-12} = Dd{3-0};
1666 let Inst{22} = Dd{4};
1667
Johnny Chen34a6afc2010-01-29 23:21:10 +00001668 let Inst{27-23} = opcod1;
1669 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001670 let Inst{11-9} = 0b101;
1671 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001672 let Inst{6} = op6;
1673 let Inst{4} = op4;
Tim Northover5620faf2013-10-24 15:49:39 +00001674
1675 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001676}
1677
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001678// FP, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001679class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001680 InstrItinClass itin, string asm, list<dag> pattern>
Joey Gouly2d0175e2013-07-09 09:59:04 +00001681 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1682 asm, "", pattern>
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001683{
1684 // Instruction operands.
1685 bits<5> Dd;
1686 bits<5> Dn;
1687 bits<5> Dm;
1688
1689 let Inst{31-28} = 0b1111;
1690
1691 // Encode instruction operands.
1692 let Inst{3-0} = Dm{3-0};
1693 let Inst{5} = Dm{4};
1694 let Inst{19-16} = Dn{3-0};
1695 let Inst{7} = Dn{4};
1696 let Inst{15-12} = Dd{3-0};
1697 let Inst{22} = Dd{4};
1698
1699 let Inst{27-23} = opcod1;
1700 let Inst{21-20} = opcod2;
1701 let Inst{11-9} = 0b101;
1702 let Inst{8} = 1; // double precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001703 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001704 let Inst{4} = 0;
Tim Northover5620faf2013-10-24 15:49:39 +00001705
1706 let Predicates = [HasVFP2, HasDPVFP];
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001707}
1708
Joey Gouly2d0175e2013-07-09 09:59:04 +00001709// Single precision, unary, predicated
Johnny Chen34a6afc2010-01-29 23:21:10 +00001710class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1711 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1712 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001713 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001714 // Instruction operands.
1715 bits<5> Sd;
1716 bits<5> Sm;
1717
1718 // Encode instruction operands.
1719 let Inst{3-0} = Sm{4-1};
1720 let Inst{5} = Sm{0};
1721 let Inst{15-12} = Sd{4-1};
1722 let Inst{22} = Sd{0};
1723
Johnny Chen34a6afc2010-01-29 23:21:10 +00001724 let Inst{27-23} = opcod1;
1725 let Inst{21-20} = opcod2;
1726 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001727 let Inst{11-9} = 0b101;
1728 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001729 let Inst{7-6} = opcod4;
1730 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001731}
1732
Joey Gouly2d0175e2013-07-09 09:59:04 +00001733// Single precision, unary, non-predicated
1734class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1735 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1736 string asm, list<dag> pattern>
1737 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1738 VFPUnaryFrm, itin, asm, "", pattern> {
1739 // Instruction operands.
1740 bits<5> Sd;
1741 bits<5> Sm;
1742
1743 let Inst{31-28} = 0b1111;
1744
1745 // Encode instruction operands.
1746 let Inst{3-0} = Sm{4-1};
1747 let Inst{5} = Sm{0};
1748 let Inst{15-12} = Sd{4-1};
1749 let Inst{22} = Sd{0};
1750
1751 let Inst{27-23} = opcod1;
1752 let Inst{21-20} = opcod2;
1753 let Inst{19-16} = opcod3;
1754 let Inst{11-9} = 0b101;
1755 let Inst{8} = 0; // Single precision
1756 let Inst{7-6} = opcod4;
1757 let Inst{4} = opcod5;
1758}
1759
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001760// Single precision unary, if no NEON. Same as ASuI except not available if
1761// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001762class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1763 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1764 string asm, list<dag> pattern>
1765 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1766 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001767 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1768}
1769
Evan Chengac2af2f2008-11-11 02:11:05 +00001770// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001771class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1772 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001773 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001774 // Instruction operands.
1775 bits<5> Sd;
1776 bits<5> Sn;
1777 bits<5> Sm;
1778
1779 // Encode instruction operands.
1780 let Inst{3-0} = Sm{4-1};
1781 let Inst{5} = Sm{0};
1782 let Inst{19-16} = Sn{4-1};
1783 let Inst{7} = Sn{0};
1784 let Inst{15-12} = Sd{4-1};
1785 let Inst{22} = Sd{0};
1786
Johnny Chen34a6afc2010-01-29 23:21:10 +00001787 let Inst{27-23} = opcod1;
1788 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001789 let Inst{11-9} = 0b101;
1790 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001791 let Inst{6} = op6;
1792 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001793}
1794
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001795// Single precision, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001796class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001797 InstrItinClass itin, string asm, list<dag> pattern>
1798 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1799 VFPBinaryFrm, itin, asm, "", pattern>
1800{
1801 // Instruction operands.
1802 bits<5> Sd;
1803 bits<5> Sn;
1804 bits<5> Sm;
1805
1806 let Inst{31-28} = 0b1111;
1807
1808 // Encode instruction operands.
1809 let Inst{3-0} = Sm{4-1};
1810 let Inst{5} = Sm{0};
1811 let Inst{19-16} = Sn{4-1};
1812 let Inst{7} = Sn{0};
1813 let Inst{15-12} = Sd{4-1};
1814 let Inst{22} = Sd{0};
1815
1816 let Inst{27-23} = opcod1;
1817 let Inst{21-20} = opcod2;
1818 let Inst{11-9} = 0b101;
1819 let Inst{8} = 0; // Single precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001820 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001821 let Inst{4} = 0;
1822}
1823
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001824// Single precision binary, if no NEON. Same as ASbI except not available if
1825// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001826class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001827 dag iops, InstrItinClass itin, string opc, string asm,
1828 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001829 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001830 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001831
1832 // Instruction operands.
1833 bits<5> Sd;
1834 bits<5> Sn;
1835 bits<5> Sm;
1836
1837 // Encode instruction operands.
1838 let Inst{3-0} = Sm{4-1};
1839 let Inst{5} = Sm{0};
1840 let Inst{19-16} = Sn{4-1};
1841 let Inst{7} = Sn{0};
1842 let Inst{15-12} = Sd{4-1};
1843 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001844}
1845
Oliver Stannard65b85382016-01-25 10:26:26 +00001846// Half precision, unary, predicated
1847class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1848 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1849 string asm, list<dag> pattern>
1850 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1851 list<Predicate> Predicates = [HasFullFP16];
1852
1853 // Instruction operands.
1854 bits<5> Sd;
1855 bits<5> Sm;
1856
1857 // Encode instruction operands.
1858 let Inst{3-0} = Sm{4-1};
1859 let Inst{5} = Sm{0};
1860 let Inst{15-12} = Sd{4-1};
1861 let Inst{22} = Sd{0};
1862
1863 let Inst{27-23} = opcod1;
1864 let Inst{21-20} = opcod2;
1865 let Inst{19-16} = opcod3;
1866 let Inst{11-8} = 0b1001; // Half precision
1867 let Inst{7-6} = opcod4;
1868 let Inst{4} = opcod5;
1869}
1870
1871// Half precision, unary, non-predicated
1872class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1873 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1874 string asm, list<dag> pattern>
1875 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1876 VFPUnaryFrm, itin, asm, "", pattern> {
1877 list<Predicate> Predicates = [HasFullFP16];
1878
1879 // Instruction operands.
1880 bits<5> Sd;
1881 bits<5> Sm;
1882
1883 let Inst{31-28} = 0b1111;
1884
1885 // Encode instruction operands.
1886 let Inst{3-0} = Sm{4-1};
1887 let Inst{5} = Sm{0};
1888 let Inst{15-12} = Sd{4-1};
1889 let Inst{22} = Sd{0};
1890
1891 let Inst{27-23} = opcod1;
1892 let Inst{21-20} = opcod2;
1893 let Inst{19-16} = opcod3;
1894 let Inst{11-8} = 0b1001; // Half precision
1895 let Inst{7-6} = opcod4;
1896 let Inst{4} = opcod5;
1897}
1898
1899// Half precision, binary
1900class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1901 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1902 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1903 list<Predicate> Predicates = [HasFullFP16];
1904
1905 // Instruction operands.
1906 bits<5> Sd;
1907 bits<5> Sn;
1908 bits<5> Sm;
1909
1910 // Encode instruction operands.
1911 let Inst{3-0} = Sm{4-1};
1912 let Inst{5} = Sm{0};
1913 let Inst{19-16} = Sn{4-1};
1914 let Inst{7} = Sn{0};
1915 let Inst{15-12} = Sd{4-1};
1916 let Inst{22} = Sd{0};
1917
1918 let Inst{27-23} = opcod1;
1919 let Inst{21-20} = opcod2;
1920 let Inst{11-8} = 0b1001; // Half precision
1921 let Inst{6} = op6;
1922 let Inst{4} = op4;
1923}
1924
1925// Half precision, binary, not predicated
1926class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1927 InstrItinClass itin, string asm, list<dag> pattern>
1928 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1929 VFPBinaryFrm, itin, asm, "", pattern> {
1930 list<Predicate> Predicates = [HasFullFP16];
1931
1932 // Instruction operands.
1933 bits<5> Sd;
1934 bits<5> Sn;
1935 bits<5> Sm;
1936
1937 let Inst{31-28} = 0b1111;
1938
1939 // Encode instruction operands.
1940 let Inst{3-0} = Sm{4-1};
1941 let Inst{5} = Sm{0};
1942 let Inst{19-16} = Sn{4-1};
1943 let Inst{7} = Sn{0};
1944 let Inst{15-12} = Sd{4-1};
1945 let Inst{22} = Sd{0};
1946
1947 let Inst{27-23} = opcod1;
1948 let Inst{21-20} = opcod2;
1949 let Inst{11-8} = 0b1001; // Half precision
1950 let Inst{6} = opcod3;
1951 let Inst{4} = 0;
1952}
1953
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001954// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001955class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1956 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1957 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001958 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001959 let Inst{27-23} = opcod1;
1960 let Inst{21-20} = opcod2;
1961 let Inst{19-16} = opcod3;
1962 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001963 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001964 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001965}
1966
Johnny Chen39640592010-02-11 18:47:03 +00001967// VFP conversion between floating-point and fixed-point
1968class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001969 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1970 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001971 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
Jim Grosbachf0d25112011-12-22 19:55:21 +00001972 bits<5> fbits;
Johnny Chen39640592010-02-11 18:47:03 +00001973 // size (fixed-point number): sx == 0 ? 16 : 32
1974 let Inst{7} = op5; // sx
Jim Grosbachf0d25112011-12-22 19:55:21 +00001975 let Inst{5} = fbits{0};
1976 let Inst{3-0} = fbits{4-1};
Johnny Chen39640592010-02-11 18:47:03 +00001977}
1978
David Goodwin85b5b022009-08-10 22:17:39 +00001979// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001980class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001981 dag oops, dag iops, InstrItinClass itin,
1982 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001983 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1984 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001985 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1986}
1987
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001988class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001989 InstrItinClass itin,
1990 string opc, string asm, list<dag> pattern>
1991 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001992 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001993 let Inst{11-8} = opcod2;
1994 let Inst{4} = 1;
1995}
1996
David Goodwinb062c232009-08-06 16:52:47 +00001997class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1998 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1999 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00002000
Bob Wilson3968c6a2010-03-23 17:23:59 +00002001class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00002002 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2003 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002004
David Goodwinb062c232009-08-06 16:52:47 +00002005class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2006 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2007 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002008
David Goodwinb062c232009-08-06 16:52:47 +00002009class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2010 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2011 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00002012
Evan Chengac2af2f2008-11-11 02:11:05 +00002013//===----------------------------------------------------------------------===//
2014
Bob Wilson2e076c42009-06-22 23:27:02 +00002015//===----------------------------------------------------------------------===//
2016// ARM NEON Instruction templates.
2017//
Evan Chengee98fa92008-08-29 06:41:12 +00002018
Johnny Chenf833fad2010-03-20 00:17:00 +00002019class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2020 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2021 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002022 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002023 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002024 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002025 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00002026 let Pattern = pattern;
2027 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00002028 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00002029}
2030
2031// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00002032class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2033 InstrItinClass itin, string opc, string asm, string cstr,
2034 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002035 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002036 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002037 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002038 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00002039 let Pattern = pattern;
2040 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00002041 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00002042}
2043
Joey Goulydf686002013-07-17 13:59:38 +00002044// Same as NeonI except it is not predicated
2045class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2046 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2047 list<dag> pattern>
2048 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2049 let OutOperandList = oops;
2050 let InOperandList = iops;
2051 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2052 let Pattern = pattern;
2053 list<Predicate> Predicates = [HasNEON];
2054 let DecoderNamespace = "NEON";
2055
2056 let Inst{31-28} = 0b1111;
2057}
2058
Bob Wilson50820a22009-10-07 21:53:04 +00002059class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2060 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002061 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00002062 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2063 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00002064 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002065 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00002066 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002067 let Inst{11-8} = op11_8;
2068 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002069
Chris Lattner63274cb2010-11-15 05:19:05 +00002070 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00002071 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00002072
Owen Andersonad402342010-11-02 00:05:05 +00002073 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00002074 bits<6> Rn;
2075 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002076
Owen Andersonad402342010-11-02 00:05:05 +00002077 let Inst{22} = Vd{4};
2078 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00002079 let Inst{19-16} = Rn{3-0};
2080 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00002081}
2082
Owen Anderson9f20daf2010-11-02 20:47:39 +00002083class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2084 dag oops, dag iops, InstrItinClass itin,
2085 string opc, string dt, string asm, string cstr, list<dag> pattern>
2086 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2087 dt, asm, cstr, pattern> {
2088 bits<3> lane;
2089}
2090
Bob Wilson9392b0e2010-08-25 23:27:42 +00002091class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00002092 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00002093 itin> {
2094 let OutOperandList = oops;
2095 let InOperandList = !con(iops, (ins pred:$p));
2096 list<Predicate> Predicates = [HasNEON];
2097}
2098
Jim Grosbach233b3a22010-10-06 20:36:55 +00002099class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2100 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002101 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00002102 itin> {
2103 let OutOperandList = oops;
2104 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00002105 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00002106 list<Predicate> Predicates = [HasNEON];
2107}
2108
Johnny Chenac5024b2010-03-23 16:43:47 +00002109class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002110 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00002111 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2112 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002113 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00002114 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00002115 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00002116}
2117
Johnny Chen020023a2010-03-23 20:40:44 +00002118class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002119 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00002120 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002121 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002122 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00002123 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00002124 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00002125}
2126
2127// NEON "one register and a modified immediate" format.
2128class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2129 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00002130 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002131 string opc, string dt, string asm, string cstr,
2132 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00002133 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002134 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002135 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002136 let Inst{11-8} = op11_8;
2137 let Inst{7} = op7;
2138 let Inst{6} = op6;
2139 let Inst{5} = op5;
2140 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002141
Owen Anderson284cb362010-10-26 17:40:54 +00002142 // Instruction operands.
2143 bits<5> Vd;
2144 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00002145
Owen Anderson284cb362010-10-26 17:40:54 +00002146 let Inst{15-12} = Vd{3-0};
2147 let Inst{22} = Vd{4};
2148 let Inst{24} = SIMM{7};
2149 let Inst{18-16} = SIMM{6-4};
2150 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00002151 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00002152}
2153
2154// NEON 2 vector register format.
2155class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2156 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00002157 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002158 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002159 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002160 let Inst{24-23} = op24_23;
2161 let Inst{21-20} = op21_20;
2162 let Inst{19-18} = op19_18;
2163 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002164 let Inst{11-7} = op11_7;
2165 let Inst{6} = op6;
2166 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002167
Owen Anderson24774462010-10-25 18:43:52 +00002168 // Instruction operands.
2169 bits<5> Vd;
2170 bits<5> Vm;
2171
2172 let Inst{15-12} = Vd{3-0};
2173 let Inst{22} = Vd{4};
2174 let Inst{3-0} = Vm{3-0};
2175 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002176}
2177
Joey Gouly943dd592013-07-18 11:53:22 +00002178// Same as N2V but not predicated.
Amara Emerson33089092013-09-19 11:59:01 +00002179class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
Joey Gouly943dd592013-07-18 11:53:22 +00002180 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
Tim Northover6ad1f5c2014-04-28 13:53:00 +00002181 string Dt, list<dag> pattern>
Joey Gouly943dd592013-07-18 11:53:22 +00002182 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2183 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2184 bits<5> Vd;
2185 bits<5> Vm;
2186
2187 // Encode instruction operands
2188 let Inst{22} = Vd{4};
2189 let Inst{15-12} = Vd{3-0};
2190 let Inst{5} = Vm{4};
2191 let Inst{3-0} = Vm{3-0};
2192
2193 // Encode constant bits
2194 let Inst{27-23} = 0b00111;
2195 let Inst{21-20} = 0b11;
Amara Emerson33089092013-09-19 11:59:01 +00002196 let Inst{19-18} = op19_18;
Joey Gouly943dd592013-07-18 11:53:22 +00002197 let Inst{17-16} = op17_16;
2198 let Inst{11} = 0;
2199 let Inst{10-8} = op10_8;
2200 let Inst{7} = op7;
2201 let Inst{6} = op6;
2202 let Inst{4} = 0;
2203
2204 let DecoderNamespace = "NEON";
2205}
2206
Evan Cheng738a97a2009-11-23 21:57:23 +00002207// Same as N2V except it doesn't have a datatype suffix.
2208class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002209 bits<5> op11_7, bit op6, bit op4,
2210 dag oops, dag iops, InstrItinClass itin,
2211 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002212 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002213 let Inst{24-23} = op24_23;
2214 let Inst{21-20} = op21_20;
2215 let Inst{19-18} = op19_18;
2216 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002217 let Inst{11-7} = op11_7;
2218 let Inst{6} = op6;
2219 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002220
Owen Anderson24774462010-10-25 18:43:52 +00002221 // Instruction operands.
2222 bits<5> Vd;
2223 bits<5> Vm;
2224
2225 let Inst{15-12} = Vd{3-0};
2226 let Inst{22} = Vd{4};
2227 let Inst{3-0} = Vm{3-0};
2228 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002229}
2230
2231// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00002232class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00002233 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002234 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00002235 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002236 let Inst{24} = op24;
2237 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002238 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002239 let Inst{7} = op7;
2240 let Inst{6} = op6;
2241 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002242
Owen Anderson3665fee2010-10-26 20:56:57 +00002243 // Instruction operands.
2244 bits<5> Vd;
2245 bits<5> Vm;
2246 bits<6> SIMM;
2247
2248 let Inst{15-12} = Vd{3-0};
2249 let Inst{22} = Vd{4};
2250 let Inst{3-0} = Vm{3-0};
2251 let Inst{5} = Vm{4};
2252 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002253}
2254
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002255// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00002256
Jim Grosbacheca54e42011-05-19 17:34:53 +00002257class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2258 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2259 string opc, string dt, string asm, string cstr,
2260 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00002261 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002262 let Inst{24} = op24;
2263 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00002264 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002265 let Inst{11-8} = op11_8;
2266 let Inst{6} = op6;
2267 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00002268}
2269
2270class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2271 dag oops, dag iops, Format f, InstrItinClass itin,
2272 string opc, string dt, string asm, string cstr, list<dag> pattern>
2273 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2274 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Owen Anderson9e44cf22010-10-21 20:21:49 +00002275 // Instruction operands.
2276 bits<5> Vd;
2277 bits<5> Vn;
2278 bits<5> Vm;
2279
2280 let Inst{15-12} = Vd{3-0};
2281 let Inst{22} = Vd{4};
2282 let Inst{19-16} = Vn{3-0};
2283 let Inst{7} = Vn{4};
2284 let Inst{3-0} = Vm{3-0};
2285 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002286}
2287
Joey Goulydf686002013-07-17 13:59:38 +00002288class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2289 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
Tim Northover6ad1f5c2014-04-28 13:53:00 +00002290 string OpcodeStr, string Dt, list<dag> pattern>
Joey Goulydf686002013-07-17 13:59:38 +00002291 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2292 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2293 bits<5> Vd;
2294 bits<5> Vn;
2295 bits<5> Vm;
2296
2297 // Encode instruction operands
2298 let Inst{22} = Vd{4};
2299 let Inst{15-12} = Vd{3-0};
2300 let Inst{19-16} = Vn{3-0};
2301 let Inst{7} = Vn{4};
2302 let Inst{5} = Vm{4};
2303 let Inst{3-0} = Vm{3-0};
2304
2305 // Encode constant bits
2306 let Inst{27-23} = op27_23;
2307 let Inst{21-20} = op21_20;
2308 let Inst{11-8} = op11_8;
2309 let Inst{6} = op6;
2310 let Inst{4} = op4;
2311}
2312
Jim Grosbacheca54e42011-05-19 17:34:53 +00002313class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2314 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2315 string opc, string dt, string asm, string cstr,
2316 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002317 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2318 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2319
2320 // Instruction operands.
2321 bits<5> Vd;
2322 bits<5> Vn;
2323 bits<5> Vm;
2324 bit lane;
2325
2326 let Inst{15-12} = Vd{3-0};
2327 let Inst{22} = Vd{4};
2328 let Inst{19-16} = Vn{3-0};
2329 let Inst{7} = Vn{4};
2330 let Inst{3-0} = Vm{3-0};
2331 let Inst{5} = lane;
2332}
2333
Jim Grosbacheca54e42011-05-19 17:34:53 +00002334class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2335 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2336 string opc, string dt, string asm, string cstr,
2337 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002338 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2339 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2340
2341 // Instruction operands.
2342 bits<5> Vd;
2343 bits<5> Vn;
2344 bits<5> Vm;
2345 bits<2> lane;
2346
2347 let Inst{15-12} = Vd{3-0};
2348 let Inst{22} = Vd{4};
2349 let Inst{19-16} = Vn{3-0};
2350 let Inst{7} = Vn{4};
2351 let Inst{2-0} = Vm{2-0};
2352 let Inst{5} = lane{1};
2353 let Inst{3} = lane{0};
2354}
2355
Johnny Chen8a687232010-03-23 21:35:03 +00002356// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00002357class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2358 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002359 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002360 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002361 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002362 let Inst{24} = op24;
2363 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002364 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002365 let Inst{11-8} = op11_8;
2366 let Inst{6} = op6;
2367 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002368
Owen Andersondff239c2010-10-25 18:28:30 +00002369 // Instruction operands.
2370 bits<5> Vd;
2371 bits<5> Vn;
2372 bits<5> Vm;
2373
2374 let Inst{15-12} = Vd{3-0};
2375 let Inst{22} = Vd{4};
2376 let Inst{19-16} = Vn{3-0};
2377 let Inst{7} = Vn{4};
2378 let Inst{3-0} = Vm{3-0};
2379 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002380}
2381
2382// NEON VMOVs between scalar and core registers.
2383class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002384 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002385 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002386 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002387 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002388 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002389 let Inst{11-8} = opcod2;
2390 let Inst{6-5} = opcod3;
2391 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00002392 // A8.6.303, A8.6.328, A8.6.329
2393 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00002394
2395 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002396 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002397 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00002398 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00002399 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00002400
Chris Lattner63274cb2010-11-15 05:19:05 +00002401 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00002402 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00002403
Owen Andersoned9652f2010-10-27 21:28:09 +00002404 bits<5> V;
2405 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00002406 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00002407 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00002408
Owen Anderson40d24a42010-10-27 19:25:54 +00002409 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00002410 let Inst{7} = V{4};
2411 let Inst{19-16} = V{3-0};
2412 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002413}
2414class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002415 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002416 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002417 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002418 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002419class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002420 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002421 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002422 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002423 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002424class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002425 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002426 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002427 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002428 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00002429
Johnny Chen45ab3f32010-03-25 17:01:27 +00002430// Vector Duplicate Lane (from scalar to all elements)
2431class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2432 InstrItinClass itin, string opc, string dt, string asm,
2433 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00002434 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00002435 let Inst{24-23} = 0b11;
2436 let Inst{21-20} = 0b11;
2437 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002438 let Inst{11-7} = 0b11000;
2439 let Inst{6} = op6;
2440 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00002441
Owen Anderson40d24a42010-10-27 19:25:54 +00002442 bits<5> Vd;
2443 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002444
Owen Anderson40d24a42010-10-27 19:25:54 +00002445 let Inst{22} = Vd{4};
2446 let Inst{15-12} = Vd{3-0};
2447 let Inst{5} = Vm{4};
2448 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00002449}
2450
David Goodwin3b9c52c2009-08-04 17:53:06 +00002451// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2452// for single-precision FP.
2453class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2454 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2455}
Jim Grosbach7996b152011-11-14 22:28:39 +00002456
2457// VFP/NEON Instruction aliases for type suffices.
2458class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
Jim Grosbachfdf9e152011-12-05 20:29:59 +00002459 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002460
Jim Grosbach3d6c0e02011-11-14 23:11:19 +00002461multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002462 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2463 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2464 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2465 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002466}
2467
Jim Grosbach681db342012-01-24 17:23:29 +00002468multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result> {
2469 let Predicates = [HasNEON] in {
2470 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2471 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2472 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2473 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2474}
2475}
2476
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002477// The same alias classes using AsmPseudo instead, for the more complex
2478// stuff in NEON that InstAlias can't quite handle.
2479// Note that we can't use anonymous defm references here like we can
2480// above, as we care about the ultimate instruction enum names generated, unlike
2481// for instalias defs.
2482class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
Jim Grosbachdda976b2011-12-02 22:01:52 +00002483 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
Jim Grosbach585ce302011-12-07 01:17:58 +00002484
2485// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2486def : TokenAlias<".s8", ".i8">;
2487def : TokenAlias<".u8", ".i8">;
2488def : TokenAlias<".s16", ".i16">;
2489def : TokenAlias<".u16", ".i16">;
2490def : TokenAlias<".s32", ".i32">;
2491def : TokenAlias<".u32", ".i32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002492def : TokenAlias<".s64", ".i64">;
2493def : TokenAlias<".u64", ".i64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002494
2495def : TokenAlias<".i8", ".8">;
2496def : TokenAlias<".i16", ".16">;
2497def : TokenAlias<".i32", ".32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002498def : TokenAlias<".i64", ".64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002499
2500def : TokenAlias<".p8", ".8">;
2501def : TokenAlias<".p16", ".16">;
2502
2503def : TokenAlias<".f32", ".32">;
2504def : TokenAlias<".f64", ".64">;
2505def : TokenAlias<".f", ".f32">;
2506def : TokenAlias<".d", ".f64">;