]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZOperands.td
MFV: r366539
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / SystemZ / SystemZOperands.td
1 //===-- SystemZOperands.td - SystemZ instruction operands ----*- tblgen-*--===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 //===----------------------------------------------------------------------===//
10 // Class definitions
11 //===----------------------------------------------------------------------===//
12
13 class ImmediateAsmOperand<string name>
14   : AsmOperandClass {
15   let Name = name;
16   let RenderMethod = "addImmOperands";
17 }
18 class ImmediateTLSAsmOperand<string name>
19   : AsmOperandClass {
20   let Name = name;
21   let RenderMethod = "addImmTLSOperands";
22 }
23
24 class ImmediateOp<ValueType vt, string asmop> : Operand<vt> {
25   let PrintMethod = "print"#asmop#"Operand";
26   let DecoderMethod = "decode"#asmop#"Operand";
27   let ParserMatchClass = !cast<AsmOperandClass>(asmop);
28   let OperandType = "OPERAND_IMMEDIATE";
29 }
30
31 class ImmOpWithPattern<ValueType vt, string asmop, code pred, SDNodeXForm xform,
32       SDNode ImmNode = imm> :
33   ImmediateOp<vt, asmop>, PatLeaf<(vt ImmNode), pred, xform>;
34
35 // class ImmediatePatLeaf<ValueType vt, code pred,
36 //       SDNodeXForm xform, SDNode ImmNode>
37 //   : PatLeaf<(vt ImmNode), pred, xform>;
38
39
40 // Constructs both a DAG pattern and instruction operand for an immediate
41 // of type VT.  PRED returns true if a node is acceptable and XFORM returns
42 // the operand value associated with the node.  ASMOP is the name of the
43 // associated asm operand, and also forms the basis of the asm print method.
44 multiclass Immediate<ValueType vt, code pred, SDNodeXForm xform, string asmop> {
45   // def "" : ImmediateOp<vt, asmop>,
46   //          PatLeaf<(vt imm), pred, xform>;
47   def "" : ImmOpWithPattern<vt, asmop, pred, xform>;
48
49 //  def _timm : PatLeaf<(vt timm), pred, xform>;
50   def _timm : ImmOpWithPattern<vt, asmop, pred, xform, timm>;
51 }
52
53 // Constructs an asm operand for a PC-relative address.  SIZE says how
54 // many bits there are.
55 class PCRelAsmOperand<string size> : ImmediateAsmOperand<"PCRel"#size> {
56   let PredicateMethod = "isImm";
57   let ParserMethod = "parsePCRel"#size;
58 }
59 class PCRelTLSAsmOperand<string size>
60   : ImmediateTLSAsmOperand<"PCRelTLS"#size> {
61   let PredicateMethod = "isImmTLS";
62   let ParserMethod = "parsePCRelTLS"#size;
63 }
64
65 // Constructs an operand for a PC-relative address with address type VT.
66 // ASMOP is the associated asm operand.
67 let OperandType = "OPERAND_PCREL" in {
68   class PCRelOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> {
69     let PrintMethod = "printPCRelOperand";
70     let ParserMatchClass = asmop;
71   }
72   class PCRelTLSOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> {
73     let PrintMethod = "printPCRelTLSOperand";
74     let ParserMatchClass = asmop;
75   }
76 }
77
78 // Constructs both a DAG pattern and instruction operand for a PC-relative
79 // address with address size VT.  SELF is the name of the operand and
80 // ASMOP is the associated asm operand.
81 class PCRelAddress<ValueType vt, string self, AsmOperandClass asmop>
82   : ComplexPattern<vt, 1, "selectPCRelAddress",
83                    [z_pcrel_wrapper, z_pcrel_offset]>,
84     PCRelOperand<vt, asmop> {
85   let MIOperandInfo = (ops !cast<Operand>(self));
86 }
87
88 // Constructs an AsmOperandClass for addressing mode FORMAT, treating the
89 // registers as having BITSIZE bits and displacements as having DISPSIZE bits.
90 // LENGTH is "LenN" for addresses with an N-bit length field, otherwise it
91 // is "".
92 class AddressAsmOperand<string format, string bitsize, string dispsize,
93                         string length = "">
94   : AsmOperandClass {
95   let Name = format#bitsize#"Disp"#dispsize#length;
96   let ParserMethod = "parse"#format#bitsize;
97   let RenderMethod = "add"#format#"Operands";
98 }
99
100 // Constructs an instruction operand for an addressing mode.  FORMAT,
101 // BITSIZE, DISPSIZE and LENGTH are the parameters to an associated
102 // AddressAsmOperand.  OPERANDS is a list of individual operands
103 // (base register, displacement, etc.).
104 class AddressOperand<string bitsize, string dispsize, string length,
105                      string format, dag operands>
106   : Operand<!cast<ValueType>("i"#bitsize)> {
107   let PrintMethod = "print"#format#"Operand";
108   let EncoderMethod = "get"#format#dispsize#length#"Encoding";
109   let DecoderMethod =
110     "decode"#format#bitsize#"Disp"#dispsize#length#"Operand";
111   let OperandType = "OPERAND_MEMORY";
112   let MIOperandInfo = operands;
113   let ParserMatchClass =
114     !cast<AddressAsmOperand>(format#bitsize#"Disp"#dispsize#length);
115 }
116
117 // Constructs both a DAG pattern and instruction operand for an addressing mode.
118 // FORMAT, BITSIZE, DISPSIZE and LENGTH are the parameters to an associated
119 // AddressAsmOperand.  OPERANDS is a list of NUMOPS individual operands
120 // (base register, displacement, etc.).  SELTYPE is the type of the memory
121 // operand for selection purposes; sometimes we want different selection
122 // choices for the same underlying addressing mode.  SUFFIX is similarly
123 // a suffix appended to the displacement for selection purposes;
124 // e.g. we want to reject small 20-bit displacements if a 12-bit form
125 // also exists, but we want to accept them otherwise.
126 class AddressingMode<string seltype, string bitsize, string dispsize,
127                      string suffix, string length, int numops, string format,
128                      dag operands>
129   : ComplexPattern<!cast<ValueType>("i"#bitsize), numops,
130                    "select"#seltype#dispsize#suffix#length,
131                    [add, sub, or, frameindex, z_adjdynalloc]>,
132     AddressOperand<bitsize, dispsize, length, format, operands>;
133
134 // An addressing mode with a base and displacement but no index.
135 class BDMode<string type, string bitsize, string dispsize, string suffix>
136   : AddressingMode<type, bitsize, dispsize, suffix, "", 2, "BDAddr",
137                    (ops !cast<RegisterOperand>("ADDR"#bitsize),
138                         !cast<Operand>("disp"#dispsize#"imm"#bitsize))>;
139
140 // An addressing mode with a base, displacement and index.
141 class BDXMode<string type, string bitsize, string dispsize, string suffix>
142   : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDXAddr",
143                    (ops !cast<RegisterOperand>("ADDR"#bitsize),
144                         !cast<Operand>("disp"#dispsize#"imm"#bitsize),
145                         !cast<RegisterOperand>("ADDR"#bitsize))>;
146
147 // A BDMode paired with an immediate length operand of LENSIZE bits.
148 class BDLMode<string type, string bitsize, string dispsize, string suffix,
149               string lensize>
150   : AddressingMode<type, bitsize, dispsize, suffix, "Len"#lensize, 3,
151                    "BDLAddr",
152                    (ops !cast<RegisterOperand>("ADDR"#bitsize),
153                         !cast<Operand>("disp"#dispsize#"imm"#bitsize),
154                         !cast<Operand>("imm"#bitsize))>;
155
156 // A BDMode paired with a register length operand.
157 class BDRMode<string type, string bitsize, string dispsize, string suffix>
158   : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDRAddr",
159                    (ops !cast<RegisterOperand>("ADDR"#bitsize),
160                         !cast<Operand>("disp"#dispsize#"imm"#bitsize),
161                         !cast<RegisterOperand>("GR"#bitsize))>;
162
163 // An addressing mode with a base, displacement and a vector index.
164 class BDVMode<string bitsize, string dispsize>
165   : AddressOperand<bitsize, dispsize, "", "BDVAddr",
166                    (ops !cast<RegisterOperand>("ADDR"#bitsize),
167                         !cast<Operand>("disp"#dispsize#"imm"#bitsize),
168                         !cast<RegisterOperand>("VR128"))>;
169
170 //===----------------------------------------------------------------------===//
171 // Extracting immediate operands from nodes
172 // These all create MVT::i64 nodes to ensure the value is not sign-extended
173 // when converted from an SDNode to a MachineOperand later on.
174 //===----------------------------------------------------------------------===//
175
176 // Bits 0-15 (counting from the lsb).
177 def LL16 : SDNodeXForm<imm, [{
178   uint64_t Value = N->getZExtValue() & 0x000000000000FFFFULL;
179   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
180 }]>;
181
182 // Bits 16-31 (counting from the lsb).
183 def LH16 : SDNodeXForm<imm, [{
184   uint64_t Value = (N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16;
185   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
186 }]>;
187
188 // Bits 32-47 (counting from the lsb).
189 def HL16 : SDNodeXForm<imm, [{
190   uint64_t Value = (N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32;
191   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
192 }]>;
193
194 // Bits 48-63 (counting from the lsb).
195 def HH16 : SDNodeXForm<imm, [{
196   uint64_t Value = (N->getZExtValue() & 0xFFFF000000000000ULL) >> 48;
197   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
198 }]>;
199
200 // Low 32 bits.
201 def LF32 : SDNodeXForm<imm, [{
202   uint64_t Value = N->getZExtValue() & 0x00000000FFFFFFFFULL;
203   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
204 }]>;
205
206 // High 32 bits.
207 def HF32 : SDNodeXForm<imm, [{
208   uint64_t Value = N->getZExtValue() >> 32;
209   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
210 }]>;
211
212 // Negated variants.
213 def NEGLH16 : SDNodeXForm<imm, [{
214   uint64_t Value = (-N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16;
215   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
216 }]>;
217
218 def NEGLF32 : SDNodeXForm<imm, [{
219   uint64_t Value = -N->getZExtValue() & 0x00000000FFFFFFFFULL;
220   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
221 }]>;
222
223 // Truncate an immediate to a 8-bit signed quantity.
224 def SIMM8 : SDNodeXForm<imm, [{
225   return CurDAG->getTargetConstant(int8_t(N->getZExtValue()), SDLoc(N),
226                                    MVT::i64);
227 }]>;
228
229 // Truncate an immediate to a 8-bit unsigned quantity.
230 def UIMM8 : SDNodeXForm<imm, [{
231   return CurDAG->getTargetConstant(uint8_t(N->getZExtValue()), SDLoc(N),
232                                    MVT::i64);
233 }]>;
234
235 // Truncate an immediate to a 8-bit unsigned quantity and mask off low bit.
236 def UIMM8EVEN : SDNodeXForm<imm, [{
237   return CurDAG->getTargetConstant(N->getZExtValue() & 0xfe, SDLoc(N),
238                                    MVT::i64);
239 }]>;
240
241 // Truncate an immediate to a 12-bit unsigned quantity.
242 def UIMM12 : SDNodeXForm<imm, [{
243   return CurDAG->getTargetConstant(N->getZExtValue() & 0xfff, SDLoc(N),
244                                    MVT::i64);
245 }]>;
246
247 // Truncate an immediate to a 16-bit signed quantity.
248 def SIMM16 : SDNodeXForm<imm, [{
249   return CurDAG->getTargetConstant(int16_t(N->getZExtValue()), SDLoc(N),
250                                    MVT::i64);
251 }]>;
252
253 // Negate and then truncate an immediate to a 16-bit signed quantity.
254 def NEGSIMM16 : SDNodeXForm<imm, [{
255   return CurDAG->getTargetConstant(int16_t(-N->getZExtValue()), SDLoc(N),
256                                    MVT::i64);
257 }]>;
258
259 // Truncate an immediate to a 16-bit unsigned quantity.
260 def UIMM16 : SDNodeXForm<imm, [{
261   return CurDAG->getTargetConstant(uint16_t(N->getZExtValue()), SDLoc(N),
262                                    MVT::i64);
263 }]>;
264
265 // Truncate an immediate to a 32-bit signed quantity.
266 def SIMM32 : SDNodeXForm<imm, [{
267   return CurDAG->getTargetConstant(int32_t(N->getZExtValue()), SDLoc(N),
268                                    MVT::i64);
269 }]>;
270
271 // Negate and then truncate an immediate to a 32-bit unsigned quantity.
272 def NEGSIMM32 : SDNodeXForm<imm, [{
273   return CurDAG->getTargetConstant(int32_t(-N->getZExtValue()), SDLoc(N),
274                                    MVT::i64);
275 }]>;
276
277 // Truncate an immediate to a 32-bit unsigned quantity.
278 def UIMM32 : SDNodeXForm<imm, [{
279   return CurDAG->getTargetConstant(uint32_t(N->getZExtValue()), SDLoc(N),
280                                    MVT::i64);
281 }]>;
282
283 // Negate and then truncate an immediate to a 32-bit unsigned quantity.
284 def NEGUIMM32 : SDNodeXForm<imm, [{
285   return CurDAG->getTargetConstant(uint32_t(-N->getZExtValue()), SDLoc(N),
286                                    MVT::i64);
287 }]>;
288
289 // Truncate an immediate to a 48-bit unsigned quantity.
290 def UIMM48 : SDNodeXForm<imm, [{
291   return CurDAG->getTargetConstant(uint64_t(N->getZExtValue()) & 0xffffffffffff,
292                                    SDLoc(N), MVT::i64);
293 }]>;
294
295 //===----------------------------------------------------------------------===//
296 // Immediate asm operands.
297 //===----------------------------------------------------------------------===//
298
299 def U1Imm  : ImmediateAsmOperand<"U1Imm">;
300 def U2Imm  : ImmediateAsmOperand<"U2Imm">;
301 def U3Imm  : ImmediateAsmOperand<"U3Imm">;
302 def U4Imm  : ImmediateAsmOperand<"U4Imm">;
303 def U6Imm  : ImmediateAsmOperand<"U6Imm">;
304 def S8Imm  : ImmediateAsmOperand<"S8Imm">;
305 def U8Imm  : ImmediateAsmOperand<"U8Imm">;
306 def U12Imm : ImmediateAsmOperand<"U12Imm">;
307 def S16Imm : ImmediateAsmOperand<"S16Imm">;
308 def U16Imm : ImmediateAsmOperand<"U16Imm">;
309 def S32Imm : ImmediateAsmOperand<"S32Imm">;
310 def U32Imm : ImmediateAsmOperand<"U32Imm">;
311 def U48Imm : ImmediateAsmOperand<"U48Imm">;
312
313 //===----------------------------------------------------------------------===//
314 // i32 immediates
315 //===----------------------------------------------------------------------===//
316
317 // Immediates for the lower and upper 16 bits of an i32, with the other
318 // bits of the i32 being zero.
319 defm imm32ll16 : Immediate<i32, [{
320   return SystemZ::isImmLL(N->getZExtValue());
321 }], LL16, "U16Imm">;
322
323 defm imm32lh16 : Immediate<i32, [{
324   return SystemZ::isImmLH(N->getZExtValue());
325 }], LH16, "U16Imm">;
326
327 // Immediates for the lower and upper 16 bits of an i32, with the other
328 // bits of the i32 being one.
329 defm imm32ll16c : Immediate<i32, [{
330   return SystemZ::isImmLL(uint32_t(~N->getZExtValue()));
331 }], LL16, "U16Imm">;
332
333 defm imm32lh16c : Immediate<i32, [{
334   return SystemZ::isImmLH(uint32_t(~N->getZExtValue()));
335 }], LH16, "U16Imm">;
336
337 // Short immediates
338 defm imm32zx1 : Immediate<i32, [{
339   return isUInt<1>(N->getZExtValue());
340 }], NOOP_SDNodeXForm, "U1Imm">;
341
342 defm imm32zx2 : Immediate<i32, [{
343   return isUInt<2>(N->getZExtValue());
344 }], NOOP_SDNodeXForm, "U2Imm">;
345
346 defm imm32zx3 : Immediate<i32, [{
347   return isUInt<3>(N->getZExtValue());
348 }], NOOP_SDNodeXForm, "U3Imm">;
349
350 defm imm32zx4 : Immediate<i32, [{
351   return isUInt<4>(N->getZExtValue());
352 }], NOOP_SDNodeXForm, "U4Imm">;
353
354 // Note: this enforces an even value during code generation only.
355 // When used from the assembler, any 4-bit value is allowed.
356 defm imm32zx4even : Immediate<i32, [{
357   return isUInt<4>(N->getZExtValue());
358 }], UIMM8EVEN, "U4Imm">;
359
360 defm imm32zx6 : Immediate<i32, [{
361   return isUInt<6>(N->getZExtValue());
362 }], NOOP_SDNodeXForm, "U6Imm">;
363
364 defm imm32sx8 : Immediate<i32, [{
365   return isInt<8>(N->getSExtValue());
366 }], SIMM8, "S8Imm">;
367
368 defm imm32zx8 : Immediate<i32, [{
369   return isUInt<8>(N->getZExtValue());
370 }], UIMM8, "U8Imm">;
371
372 defm imm32zx8trunc : Immediate<i32, [{}], UIMM8, "U8Imm">;
373
374 defm imm32zx12 : Immediate<i32, [{
375   return isUInt<12>(N->getZExtValue());
376 }], UIMM12, "U12Imm">;
377
378 defm imm32sx16 : Immediate<i32, [{
379   return isInt<16>(N->getSExtValue());
380 }], SIMM16, "S16Imm">;
381
382 defm imm32sx16n : Immediate<i32, [{
383   return isInt<16>(-N->getSExtValue());
384 }], NEGSIMM16, "S16Imm">;
385
386 defm imm32zx16 : Immediate<i32, [{
387   return isUInt<16>(N->getZExtValue());
388 }], UIMM16, "U16Imm">;
389
390 defm imm32sx16trunc : Immediate<i32, [{}], SIMM16, "S16Imm">;
391 defm imm32zx16trunc : Immediate<i32, [{}], UIMM16, "U16Imm">;
392
393 // Full 32-bit immediates.  we need both signed and unsigned versions
394 // because the assembler is picky.  E.g. AFI requires signed operands
395 // while NILF requires unsigned ones.
396 defm simm32 : Immediate<i32, [{}], SIMM32, "S32Imm">;
397 defm uimm32 : Immediate<i32, [{}], UIMM32, "U32Imm">;
398
399 defm simm32n : Immediate<i32, [{
400   return isInt<32>(-N->getSExtValue());
401 }], NEGSIMM32, "S32Imm">;
402
403 def imm32 : ImmLeaf<i32, [{}]>;
404
405 //===----------------------------------------------------------------------===//
406 // 64-bit immediates
407 //===----------------------------------------------------------------------===//
408
409 // Immediates for 16-bit chunks of an i64, with the other bits of the
410 // i32 being zero.
411 defm imm64ll16 : Immediate<i64, [{
412   return SystemZ::isImmLL(N->getZExtValue());
413 }], LL16, "U16Imm">;
414
415 defm imm64lh16 : Immediate<i64, [{
416   return SystemZ::isImmLH(N->getZExtValue());
417 }], LH16, "U16Imm">;
418
419 defm imm64hl16 : Immediate<i64, [{
420   return SystemZ::isImmHL(N->getZExtValue());
421 }], HL16, "U16Imm">;
422
423 defm imm64hh16 : Immediate<i64, [{
424   return SystemZ::isImmHH(N->getZExtValue());
425 }], HH16, "U16Imm">;
426
427 // Immediates for 16-bit chunks of an i64, with the other bits of the
428 // i32 being one.
429 defm imm64ll16c : Immediate<i64, [{
430   return SystemZ::isImmLL(uint64_t(~N->getZExtValue()));
431 }], LL16, "U16Imm">;
432
433 defm imm64lh16c : Immediate<i64, [{
434   return SystemZ::isImmLH(uint64_t(~N->getZExtValue()));
435 }], LH16, "U16Imm">;
436
437 defm imm64hl16c : Immediate<i64, [{
438   return SystemZ::isImmHL(uint64_t(~N->getZExtValue()));
439 }], HL16, "U16Imm">;
440
441 defm imm64hh16c : Immediate<i64, [{
442   return SystemZ::isImmHH(uint64_t(~N->getZExtValue()));
443 }], HH16, "U16Imm">;
444
445 // Immediates for the lower and upper 32 bits of an i64, with the other
446 // bits of the i32 being zero.
447 defm imm64lf32 : Immediate<i64, [{
448   return SystemZ::isImmLF(N->getZExtValue());
449 }], LF32, "U32Imm">;
450
451 defm imm64hf32 : Immediate<i64, [{
452   return SystemZ::isImmHF(N->getZExtValue());
453 }], HF32, "U32Imm">;
454
455 // Immediates for the lower and upper 32 bits of an i64, with the other
456 // bits of the i32 being one.
457 defm imm64lf32c : Immediate<i64, [{
458   return SystemZ::isImmLF(uint64_t(~N->getZExtValue()));
459 }], LF32, "U32Imm">;
460
461 defm imm64hf32c : Immediate<i64, [{
462   return SystemZ::isImmHF(uint64_t(~N->getZExtValue()));
463 }], HF32, "U32Imm">;
464
465 // Negated immediates that fit LF32 or LH16.
466 defm imm64lh16n : Immediate<i64, [{
467   return SystemZ::isImmLH(uint64_t(-N->getZExtValue()));
468 }], NEGLH16, "U16Imm">;
469
470 defm imm64lf32n : Immediate<i64, [{
471   return SystemZ::isImmLF(uint64_t(-N->getZExtValue()));
472 }], NEGLF32, "U32Imm">;
473
474 // Short immediates.
475 defm imm64sx8 : Immediate<i64, [{
476   return isInt<8>(N->getSExtValue());
477 }], SIMM8, "S8Imm">;
478
479 defm imm64zx8 : Immediate<i64, [{
480   return isUInt<8>(N->getSExtValue());
481 }], UIMM8, "U8Imm">;
482
483 defm imm64sx16 : Immediate<i64, [{
484   return isInt<16>(N->getSExtValue());
485 }], SIMM16, "S16Imm">;
486
487 defm imm64sx16n : Immediate<i64, [{
488   return isInt<16>(-N->getSExtValue());
489 }], NEGSIMM16, "S16Imm">;
490
491 defm imm64zx16 : Immediate<i64, [{
492   return isUInt<16>(N->getZExtValue());
493 }], UIMM16, "U16Imm">;
494
495 defm imm64sx32 : Immediate<i64, [{
496   return isInt<32>(N->getSExtValue());
497 }], SIMM32, "S32Imm">;
498
499 defm imm64sx32n : Immediate<i64, [{
500   return isInt<32>(-N->getSExtValue());
501 }], NEGSIMM32, "S32Imm">;
502
503 defm imm64zx32 : Immediate<i64, [{
504   return isUInt<32>(N->getZExtValue());
505 }], UIMM32, "U32Imm">;
506
507 defm imm64zx32n : Immediate<i64, [{
508   return isUInt<32>(-N->getSExtValue());
509 }], NEGUIMM32, "U32Imm">;
510
511 defm imm64zx48 : Immediate<i64, [{
512   return isUInt<64>(N->getZExtValue());
513 }], UIMM48, "U48Imm">;
514
515 let OperandType = "OPERAND_IMMEDIATE" in
516   def imm64 : ImmLeaf<i64, [{}]>, Operand<i64>;
517
518 //===----------------------------------------------------------------------===//
519 // Floating-point immediates
520 //===----------------------------------------------------------------------===//
521
522 // Floating-point zero.
523 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
524
525 // Floating point negative zero.
526 def fpimmneg0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(-0.0); }]>;
527
528 //===----------------------------------------------------------------------===//
529 // Symbolic address operands
530 //===----------------------------------------------------------------------===//
531
532 // PC-relative asm operands.
533 def PCRel12 : PCRelAsmOperand<"12">;
534 def PCRel16 : PCRelAsmOperand<"16">;
535 def PCRel24 : PCRelAsmOperand<"24">;
536 def PCRel32 : PCRelAsmOperand<"32">;
537 def PCRelTLS16 : PCRelTLSAsmOperand<"16">;
538 def PCRelTLS32 : PCRelTLSAsmOperand<"32">;
539
540 // PC-relative offsets of a basic block.  The offset is sign-extended
541 // and multiplied by 2.
542 def brtarget16 : PCRelOperand<OtherVT, PCRel16> {
543   let EncoderMethod = "getPC16DBLEncoding";
544   let DecoderMethod = "decodePC16DBLBranchOperand";
545 }
546 def brtarget32 : PCRelOperand<OtherVT, PCRel32> {
547   let EncoderMethod = "getPC32DBLEncoding";
548   let DecoderMethod = "decodePC32DBLBranchOperand";
549 }
550
551 // Variants of brtarget for use with branch prediction preload.
552 def brtarget12bpp : PCRelOperand<OtherVT, PCRel12> {
553   let EncoderMethod = "getPC12DBLBPPEncoding";
554   let DecoderMethod = "decodePC12DBLBranchOperand";
555 }
556 def brtarget16bpp : PCRelOperand<OtherVT, PCRel16> {
557   let EncoderMethod = "getPC16DBLBPPEncoding";
558   let DecoderMethod = "decodePC16DBLBranchOperand";
559 }
560 def brtarget24bpp : PCRelOperand<OtherVT, PCRel24> {
561   let EncoderMethod = "getPC24DBLBPPEncoding";
562   let DecoderMethod = "decodePC24DBLBranchOperand";
563 }
564
565 // Variants of brtarget16/32 with an optional additional TLS symbol.
566 // These are used to annotate calls to __tls_get_offset.
567 def tlssym : Operand<i64> { }
568 def brtarget16tls : PCRelTLSOperand<OtherVT, PCRelTLS16> {
569   let MIOperandInfo = (ops brtarget16:$func, tlssym:$sym);
570   let EncoderMethod = "getPC16DBLTLSEncoding";
571   let DecoderMethod = "decodePC16DBLBranchOperand";
572 }
573 def brtarget32tls : PCRelTLSOperand<OtherVT, PCRelTLS32> {
574   let MIOperandInfo = (ops brtarget32:$func, tlssym:$sym);
575   let EncoderMethod = "getPC32DBLTLSEncoding";
576   let DecoderMethod = "decodePC32DBLBranchOperand";
577 }
578
579 // A PC-relative offset of a global value.  The offset is sign-extended
580 // and multiplied by 2.
581 def pcrel32 : PCRelAddress<i64, "pcrel32", PCRel32> {
582   let EncoderMethod = "getPC32DBLEncoding";
583   let DecoderMethod = "decodePC32DBLOperand";
584 }
585
586 //===----------------------------------------------------------------------===//
587 // Addressing modes
588 //===----------------------------------------------------------------------===//
589
590 // 12-bit displacement operands.
591 def disp12imm32 : Operand<i32>;
592 def disp12imm64 : Operand<i64>;
593
594 // 20-bit displacement operands.
595 def disp20imm32 : Operand<i32>;
596 def disp20imm64 : Operand<i64>;
597
598 def BDAddr32Disp12      : AddressAsmOperand<"BDAddr",   "32", "12">;
599 def BDAddr32Disp20      : AddressAsmOperand<"BDAddr",   "32", "20">;
600 def BDAddr64Disp12      : AddressAsmOperand<"BDAddr",   "64", "12">;
601 def BDAddr64Disp20      : AddressAsmOperand<"BDAddr",   "64", "20">;
602 def BDXAddr64Disp12     : AddressAsmOperand<"BDXAddr",  "64", "12">;
603 def BDXAddr64Disp20     : AddressAsmOperand<"BDXAddr",  "64", "20">;
604 def BDLAddr64Disp12Len4 : AddressAsmOperand<"BDLAddr",  "64", "12", "Len4">;
605 def BDLAddr64Disp12Len8 : AddressAsmOperand<"BDLAddr",  "64", "12", "Len8">;
606 def BDRAddr64Disp12     : AddressAsmOperand<"BDRAddr",  "64", "12">;
607 def BDVAddr64Disp12     : AddressAsmOperand<"BDVAddr",  "64", "12">;
608
609 // DAG patterns and operands for addressing modes.  Each mode has
610 // the form <type><range><group>[<len>] where:
611 //
612 // <type> is one of:
613 //   shift    : base + displacement (32-bit)
614 //   bdaddr   : base + displacement
615 //   mviaddr  : like bdaddr, but reject cases with a natural index
616 //   bdxaddr  : base + displacement + index
617 //   laaddr   : like bdxaddr, but used for Load Address operations
618 //   dynalloc : base + displacement + index + ADJDYNALLOC
619 //   bdladdr  : base + displacement with a length field
620 //   bdvaddr  : base + displacement with a vector index
621 //
622 // <range> is one of:
623 //   12       : the displacement is an unsigned 12-bit value
624 //   20       : the displacement is a signed 20-bit value
625 //
626 // <group> is one of:
627 //   pair     : used when there is an equivalent instruction with the opposite
628 //              range value (12 or 20)
629 //   only     : used when there is no equivalent instruction with the opposite
630 //              range value
631 //
632 // <len> is one of:
633 //
634 //   <empty>  : there is no length field
635 //   len8     : the length field is 8 bits, with a range of [1, 0x100].
636 def shift12only       : BDMode <"BDAddr",   "32", "12", "Only">;
637 def shift20only       : BDMode <"BDAddr",   "32", "20", "Only">;
638 def bdaddr12only      : BDMode <"BDAddr",   "64", "12", "Only">;
639 def bdaddr12pair      : BDMode <"BDAddr",   "64", "12", "Pair">;
640 def bdaddr20only      : BDMode <"BDAddr",   "64", "20", "Only">;
641 def bdaddr20pair      : BDMode <"BDAddr",   "64", "20", "Pair">;
642 def mviaddr12pair     : BDMode <"MVIAddr",  "64", "12", "Pair">;
643 def mviaddr20pair     : BDMode <"MVIAddr",  "64", "20", "Pair">;
644 def bdxaddr12only     : BDXMode<"BDXAddr",  "64", "12", "Only">;
645 def bdxaddr12pair     : BDXMode<"BDXAddr",  "64", "12", "Pair">;
646 def bdxaddr20only     : BDXMode<"BDXAddr",  "64", "20", "Only">;
647 def bdxaddr20only128  : BDXMode<"BDXAddr",  "64", "20", "Only128">;
648 def bdxaddr20pair     : BDXMode<"BDXAddr",  "64", "20", "Pair">;
649 def dynalloc12only    : BDXMode<"DynAlloc", "64", "12", "Only">;
650 def laaddr12pair      : BDXMode<"LAAddr",   "64", "12", "Pair">;
651 def laaddr20pair      : BDXMode<"LAAddr",   "64", "20", "Pair">;
652 def bdladdr12onlylen4 : BDLMode<"BDLAddr",  "64", "12", "Only", "4">;
653 def bdladdr12onlylen8 : BDLMode<"BDLAddr",  "64", "12", "Only", "8">;
654 def bdraddr12only     : BDRMode<"BDRAddr",  "64", "12", "Only">;
655 def bdvaddr12only     : BDVMode<            "64", "12">;
656
657 //===----------------------------------------------------------------------===//
658 // Miscellaneous
659 //===----------------------------------------------------------------------===//
660
661 // A 4-bit condition-code mask.
662 def cond4 : PatLeaf<(i32 timm), [{ return (N->getZExtValue() < 16); }]>,
663             Operand<i32> {
664   let PrintMethod = "printCond4Operand";
665   let OperandType = "OPERAND_IMMEDIATE";
666 }