1 //== M68kInstrInfo.td - Main M68k Instruction Definition -*- tablegen -*-=//
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
7 //===----------------------------------------------------------------------===//
10 /// This file describes the M68k instruction set, defining the instructions
11 /// and properties of the instructions which are needed for code generation,
12 /// machine code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 include "M68kInstrFormats.td"
18 //===----------------------------------------------------------------------===//
20 //===----------------------------------------------------------------------===//
22 def MxSDT_CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
23 def MxSDT_CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
25 def MxSDT_Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
27 def MxSDT_Ret : SDTypeProfile<0, -1, [
28 /* ADJ */ SDTCisVT<0, i32>
31 def MxSDT_TCRet : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
33 def MxSDT_Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
35 def MxSDT_UnArithCCROut : SDTypeProfile<2, 1, [
36 /* RES */ SDTCisInt<0>,
37 /* CCR */ SDTCisVT<1, i8>,
38 /* OPD */ SDTCisSameAs<0, 2>
41 // RES, CCR <- op LHS, RHS
42 def MxSDT_BiArithCCROut : SDTypeProfile<2, 2, [
43 /* RES */ SDTCisInt<0>,
44 /* CCR */ SDTCisVT<1, i8>,
45 /* LHS */ SDTCisSameAs<0, 2>,
46 /* RHS */ SDTCisSameAs<0, 3>
49 // RES, CCR <- op LHS, RHS, CCR
50 def MxSDT_BiArithCCRInOut : SDTypeProfile<2, 3, [
51 /* RES 1 */ SDTCisInt<0>,
52 /* CCR */ SDTCisVT<1, i8>,
53 /* LHS */ SDTCisSameAs<0, 2>,
54 /* RHS */ SDTCisSameAs<0, 3>,
55 /* CCR */ SDTCisSameAs<1, 4>
58 // RES1, RES2, CCR <- op LHS, RHS
59 def MxSDT_2BiArithCCROut : SDTypeProfile<3, 2, [
60 /* RES 1 */ SDTCisInt<0>,
61 /* RES 2 */ SDTCisSameAs<0, 1>,
62 /* CCR */ SDTCisVT<1, i8>,
63 /* LHS */ SDTCisSameAs<0, 2>,
64 /* RHS */ SDTCisSameAs<0, 3>
67 def MxSDT_CmpTest : SDTypeProfile<1, 2, [
68 /* CCR */ SDTCisVT<0, i8>,
69 /* Ops */ SDTCisSameAs<1, 2>
72 def MxSDT_Cmov : SDTypeProfile<1, 4, [
73 /* ARG */ SDTCisSameAs<0, 1>,
74 /* ARG */ SDTCisSameAs<1, 2>,
75 /* Cond */ SDTCisVT<3, i8>,
76 /* CCR */ SDTCisVT<4, i8>
79 def MxSDT_BrCond : SDTypeProfile<0, 3, [
80 /* Dest */ SDTCisVT<0, OtherVT>,
81 /* Cond */ SDTCisVT<1, i8>,
82 /* CCR */ SDTCisVT<2, i8>
85 def MxSDT_SetCC : SDTypeProfile<1, 2, [
86 /* BOOL */ SDTCisVT<0, i8>,
87 /* Cond */ SDTCisVT<1, i8>,
88 /* CCR */ SDTCisVT<2, i8>
91 def MxSDT_SetCC_C : SDTypeProfile<1, 2, [
92 /* BOOL */ SDTCisInt<0>,
93 /* Cond */ SDTCisVT<1, i8>,
94 /* CCR */ SDTCisVT<2, i8>
98 def MxSDT_SEG_ALLOCA : SDTypeProfile<1, 1,[
99 /* MEM */ SDTCisVT<0, iPTR>,
100 /* SIZE */ SDTCisVT<1, iPTR>
104 //===----------------------------------------------------------------------===//
106 //===----------------------------------------------------------------------===//
108 def MxCallSeqStart : SDNode<"ISD::CALLSEQ_START", MxSDT_CallSeqStart,
109 [SDNPHasChain, SDNPOutGlue]>;
111 def MxCallSeqEnd : SDNode<"ISD::CALLSEQ_END", MxSDT_CallSeqEnd,
112 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
114 def MxCall : SDNode<"M68kISD::CALL", MxSDT_Call,
115 [SDNPHasChain, SDNPOutGlue,
116 SDNPOptInGlue, SDNPVariadic]>;
118 def MxRet : SDNode<"M68kISD::RET", MxSDT_Ret,
119 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
121 def MxTCRet : SDNode<"M68kISD::TC_RETURN", MxSDT_TCRet,
122 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
124 def MxWrapper : SDNode<"M68kISD::Wrapper", MxSDT_Wrapper>;
125 def MxWrapperPC : SDNode<"M68kISD::WrapperPC", MxSDT_Wrapper>;
127 def MxAdd : SDNode<"M68kISD::ADD", MxSDT_BiArithCCROut, [SDNPCommutative]>;
128 def MxSub : SDNode<"M68kISD::SUB", MxSDT_BiArithCCROut>;
129 def MxOr : SDNode<"M68kISD::OR", MxSDT_BiArithCCROut, [SDNPCommutative]>;
130 def MxXor : SDNode<"M68kISD::XOR", MxSDT_BiArithCCROut, [SDNPCommutative]>;
131 def MxAnd : SDNode<"M68kISD::AND", MxSDT_BiArithCCROut, [SDNPCommutative]>;
133 def MxAddX : SDNode<"M68kISD::ADDX", MxSDT_BiArithCCRInOut>;
134 def MxSubX : SDNode<"M68kISD::SUBX", MxSDT_BiArithCCRInOut>;
136 def MxSMul : SDNode<"M68kISD::SMUL", MxSDT_BiArithCCROut, [SDNPCommutative]>;
137 def MxUMul : SDNode<"M68kISD::UMUL", MxSDT_2BiArithCCROut, [SDNPCommutative]>;
139 def MxCmp : SDNode<"M68kISD::CMP", MxSDT_CmpTest>;
140 def MxBt : SDNode<"M68kISD::BT", MxSDT_CmpTest>;
142 def MxCmov : SDNode<"M68kISD::CMOV", MxSDT_Cmov>;
143 def MxBrCond : SDNode<"M68kISD::BRCOND", MxSDT_BrCond, [SDNPHasChain]>;
144 def MxSetCC : SDNode<"M68kISD::SETCC", MxSDT_SetCC>;
145 def MxSetCC_C : SDNode<"M68kISD::SETCC_CARRY", MxSDT_SetCC_C>;
148 def MxSegAlloca : SDNode<"M68kISD::SEG_ALLOCA", MxSDT_SEG_ALLOCA,
152 //===----------------------------------------------------------------------===//
154 //===----------------------------------------------------------------------===//
156 /// Size is the size of the data, either bits of a register or number of bits
157 /// addressed in memory. Size id is a letter that identifies size.
158 class MxSize<int num, string id, string full> {
164 def MxSize8 : MxSize<8, "b", "byte">;
165 def MxSize16 : MxSize<16, "w", "word">;
166 def MxSize32 : MxSize<32, "l", "long">;
168 class MxOpClass<string name,
169 list<AsmOperandClass> superClasses = []> : AsmOperandClass {
171 let ParserMethod = "parseMemOp";
172 let SuperClasses = superClasses;
175 def MxRegClass : MxOpClass<"Reg">;
176 // Splitting asm register class to avoid ambiguous on operands'
177 // MatchClassKind. For instance, without this separation,
178 // both ADD32dd and ADD32dr has {MCK_RegClass, MCK_RegClass} for
179 // their operands, which makes AsmParser unable to pick the correct
180 // one in a deterministic way.
181 let RenderMethod = "addRegOperands", SuperClasses = [MxRegClass]in {
182 def MxARegClass : MxOpClass<"AReg">;
183 def MxDRegClass : MxOpClass<"DReg">;
186 class MxOperand<ValueType vt, MxSize size, string letter, RegisterClass rc, dag pat = (null_frag)> {
188 string Letter = letter;
190 RegisterClass RC = rc;
194 class MxRegOp<ValueType vt,
198 string pm = "printOperand">
199 : RegisterOperand<rc, pm>,
200 MxOperand<vt, size, letter, rc> {
201 let ParserMatchClass = MxRegClass;
204 // REGISTER DIRECT. The operand is in the data register specified by
205 // the effective address register field.
206 def MxXRD16 : MxRegOp<i16, XR16, MxSize16, "r">;
207 def MxXRD32 : MxRegOp<i32, XR32, MxSize32, "r">;
209 def MxXRD16_TC : MxRegOp<i16, XR16_TC, MxSize16, "r">;
210 def MxXRD32_TC : MxRegOp<i32, XR32_TC, MxSize32, "r">;
212 // DATA REGISTER DIRECT. The operand is in the data register specified by
213 // the effective address register field.
214 let ParserMatchClass = MxDRegClass in {
215 def MxDRD8 : MxRegOp<i8, DR8, MxSize8, "d">;
216 def MxDRD16 : MxRegOp<i16, DR16, MxSize16, "d">;
217 def MxDRD32 : MxRegOp<i32, DR32, MxSize32, "d">;
219 def MxDRD16_TC : MxRegOp<i16, DR16_TC, MxSize16, "d">;
220 def MxDRD32_TC : MxRegOp<i32, DR32_TC, MxSize32, "d">;
223 // ADDRESS REGISTER DIRECT. The operand is in the address register specified by
224 // the effective address register field.
225 let ParserMatchClass = MxARegClass in {
226 def MxARD16 : MxRegOp<i16, AR16, MxSize16, "a">;
227 def MxARD32 : MxRegOp<i32, AR32, MxSize32, "a">;
229 def MxARD16_TC : MxRegOp<i16, AR16_TC, MxSize16, "a">;
230 def MxARD32_TC : MxRegOp<i32, AR32_TC, MxSize32, "a">;
233 class MxMemOp<dag ops, MxSize size, string letter,
234 string printMethod = "printOperand",
235 AsmOperandClass parserMatchClass = ImmAsmOperand>
236 : Operand<iPTR>, MxOperand<iPTR, size, letter, ?> {
237 let PrintMethod = printMethod;
238 let MIOperandInfo = ops;
239 let ParserMatchClass = parserMatchClass;
240 let OperandType = "OPERAND_MEMORY";
243 // ADDRESS REGISTER INDIRECT. The address of the operand is in the address
244 // register specified by the register field. The reference is classified as
245 // a data reference with the exception of the jump and jump-to-subroutine
247 def MxARI : MxOpClass<"ARI">;
248 def MxARI8 : MxMemOp<(ops AR32), MxSize8, "j", "printARI8Mem", MxARI>;
249 def MxARI16 : MxMemOp<(ops AR32), MxSize16, "j", "printARI16Mem", MxARI>;
250 def MxARI32 : MxMemOp<(ops AR32), MxSize32, "j", "printARI32Mem", MxARI>;
252 def MxARI8_TC : MxMemOp<(ops AR32_TC), MxSize8, "j", "printARI8Mem", MxARI>;
253 def MxARI16_TC : MxMemOp<(ops AR32_TC), MxSize16, "j", "printARI16Mem", MxARI>;
254 def MxARI32_TC : MxMemOp<(ops AR32_TC), MxSize32, "j", "printARI32Mem", MxARI>;
256 // ADDRESS REGISTER INDIRECT WITH POSTINCREMENT. The address of the operand is
257 // in the address register specified by the register field. After the operand
258 // address is used, it is incremented by one, two, or four depending upon whether
259 // the size of the operand is byte, word, or long word. If the address register
260 // is the stack pointer and the operand size is byte, the address is incremented
261 // by two rather than one to keep the stack pointer on a word boundary.
262 // The reference is classified as a data reference.
263 def MxARIPI : MxOpClass<"ARIPI">;
264 def MxARIPI8 : MxMemOp<(ops AR32), MxSize8, "o", "printARIPI8Mem", MxARIPI>;
265 def MxARIPI16 : MxMemOp<(ops AR32), MxSize16, "o", "printARIPI16Mem", MxARIPI>;
266 def MxARIPI32 : MxMemOp<(ops AR32), MxSize32, "o", "printARIPI32Mem", MxARIPI>;
268 def MxARIPI8_TC : MxMemOp<(ops AR32_TC), MxSize8, "o", "printARIPI8Mem", MxARIPI>;
269 def MxARIPI16_TC : MxMemOp<(ops AR32_TC), MxSize16, "o", "printARIPI16Mem", MxARIPI>;
270 def MxARIPI32_TC : MxMemOp<(ops AR32_TC), MxSize32, "o", "printARIPI32Mem", MxARIPI>;
272 // ADDRESS REGISTER INDIRECT WITH PREDECREMENT. The address of the operand is in
273 // the address register specified by the register field. Before the operand
274 // address is used, it is decremented by one, two, or four depending upon whether
275 // the operand size is byte, word, or long word. If the address register is
276 // the stack pointer and the operand size is byte, the address is decremented by
277 // two rather than one to keep the stack pointer on a word boundary.
278 // The reference is classified as a data reference.
279 def MxARIPD : MxOpClass<"ARIPD">;
280 def MxARIPD8 : MxMemOp<(ops AR32), MxSize8, "e", "printARIPD8Mem", MxARIPD>;
281 def MxARIPD16 : MxMemOp<(ops AR32), MxSize16, "e", "printARIPD16Mem", MxARIPD>;
282 def MxARIPD32 : MxMemOp<(ops AR32), MxSize32, "e", "printARIPD32Mem", MxARIPD>;
284 def MxARIPD8_TC : MxMemOp<(ops AR32_TC), MxSize8, "e", "printARIPD8Mem", MxARIPD>;
285 def MxARIPD16_TC : MxMemOp<(ops AR32_TC), MxSize16, "e", "printARIPD16Mem", MxARIPD>;
286 def MxARIPD32_TC : MxMemOp<(ops AR32_TC), MxSize32, "e", "printARIPD32Mem", MxARIPD>;
288 // ADDRESS REGISTER INDIRECT WITH DISPLACEMENT. This addressing mode requires one
289 // word of extension. The address of the operand is the sum of the address in
290 // the address register and the sign-extended 16-bit displacement integer in the
291 // extension word. The reference is classified as a data reference with the
292 // exception of the jump and jump-to-subroutine instructions.
293 def MxARID : MxOpClass<"ARID">;
294 def MxARID8 : MxMemOp<(ops i16imm, AR32), MxSize8, "p", "printARID8Mem", MxARID>;
295 def MxARID16 : MxMemOp<(ops i16imm, AR32), MxSize16, "p", "printARID16Mem", MxARID>;
296 def MxARID32 : MxMemOp<(ops i16imm, AR32), MxSize32, "p", "printARID32Mem", MxARID>;
298 def MxARID8_TC : MxMemOp<(ops i16imm, AR32_TC), MxSize8, "p", "printARID8Mem", MxARID>;
299 def MxARID16_TC : MxMemOp<(ops i16imm, AR32_TC), MxSize16, "p", "printARID16Mem", MxARID>;
300 def MxARID32_TC : MxMemOp<(ops i16imm, AR32_TC), MxSize32, "p", "printARID32Mem", MxARID>;
302 // ADDRESS REGISTER INDIRECT WITH INDEX. This addressing mode requires one word
303 // of extension. The address of the operand is the sum of the address in the
304 // address register, the signextended displacement integer in the low order eight
305 // bits of the extension word, and the contents of the index register.
306 // The reference is classified as a data reference with the exception of the
307 // jump and jump-to-subroutine instructions
308 def MxARII : MxOpClass<"ARII">;
309 def MxARII8 : MxMemOp<(ops i8imm, AR32, XR32), MxSize8, "f", "printARII8Mem", MxARII>;
310 def MxARII16 : MxMemOp<(ops i8imm, AR32, XR32), MxSize16, "f", "printARII16Mem", MxARII>;
311 def MxARII32 : MxMemOp<(ops i8imm, AR32, XR32), MxSize32, "f", "printARII32Mem", MxARII>;
313 def MxARII8_TC : MxMemOp<(ops i8imm, AR32_TC, XR32_TC), MxSize8, "f", "printARII8Mem", MxARII>;
314 def MxARII16_TC : MxMemOp<(ops i8imm, AR32_TC, XR32_TC), MxSize16, "f", "printARII16Mem", MxARII>;
315 def MxARII32_TC : MxMemOp<(ops i8imm, AR32_TC, XR32_TC), MxSize32, "f", "printARII32Mem", MxARII>;
317 // ABSOLUTE SHORT ADDRESS. This addressing mode requires one word of extension.
318 // The address of the operand is the extension word. The 16-bit address is sign
319 // extended before it is used. The reference is classified as a data reference
320 // with the exception of the jump and jump-tosubroutine instructions.
321 def MxAddr : MxOpClass<"Addr">;
322 let RenderMethod = "addAddrOperands" in {
323 // This hierarchy ensures Addr8 will always be parsed
324 // before other larger-width variants.
325 def MxAddr32 : MxOpClass<"Addr32", [MxAddr]>;
326 def MxAddr16 : MxOpClass<"Addr16", [MxAddr32]>;
327 def MxAddr8 : MxOpClass<"Addr8", [MxAddr16]>;
330 def MxAS8 : MxMemOp<(ops OtherVT), MxSize8, "B", "printAS8Mem", MxAddr8>;
331 def MxAS16 : MxMemOp<(ops OtherVT), MxSize16, "B", "printAS16Mem", MxAddr16>;
332 def MxAS32 : MxMemOp<(ops OtherVT), MxSize32, "B", "printAS32Mem", MxAddr32>;
334 // ABSOLUTE LONG ADDRESS. This addressing mode requires two words of extension.
335 // The address of the operand is developed by the concatenation of the extension
336 // words. The high order part of the address is the first extension word; the low
337 // order part of the address is the second extension word. The reference is
338 // classified as a data reference with the exception of the jump and jump
339 // to-subroutine instructions.
340 def MxAL8 : MxMemOp<(ops OtherVT), MxSize8, "b", "printAL8Mem", MxAddr8>;
341 def MxAL16 : MxMemOp<(ops OtherVT), MxSize16, "b", "printAL16Mem", MxAddr16>;
342 def MxAL32 : MxMemOp<(ops OtherVT), MxSize32, "b", "printAL32Mem", MxAddr32>;
344 def MxPCD : MxOpClass<"PCD">;
345 def MxPCI : MxOpClass<"PCI">;
347 let OperandType = "OPERAND_PCREL" in {
348 // PROGRAM COUNTER WITH DISPLACEMENT. This addressing mode requires one word of
349 // extension. The address of the operand is the sum of the address in the program
350 // counter and the Sign-extended 16-bit displacement integer in the extension
351 // word. The value in the program counter is the address of the extension word.
352 // The reference is classified as a program reference.
353 def MxPCD8 : MxMemOp<(ops i16imm), MxSize8, "q", "printPCD8Mem", MxPCD>;
354 def MxPCD16 : MxMemOp<(ops i16imm), MxSize16, "q", "printPCD16Mem", MxPCD>;
355 def MxPCD32 : MxMemOp<(ops i16imm), MxSize32, "q", "printPCD32Mem", MxPCD>;
357 // PROGRAM COUNTER WITH INDEX. This addressing mode requires one word of
358 // extension. The address is the sum of the address in the program counter, the
359 // sign-extended displacement integer in the lower eight bits of the extension
360 // word, and the contents of the index register. The value in the program
361 // counter is the address of the extension word. This reference is classified as
362 // a program reference.
363 def MxPCI8 : MxMemOp<(ops i8imm, XR32), MxSize8, "k", "printPCI8Mem", MxPCI>;
364 def MxPCI16 : MxMemOp<(ops i8imm, XR32), MxSize16, "k", "printPCI16Mem", MxPCI>;
365 def MxPCI32 : MxMemOp<(ops i8imm, XR32), MxSize32, "k", "printPCI32Mem", MxPCI>;
368 def MxImm : AsmOperandClass {
370 let PredicateMethod = "isImm";
371 let RenderMethod = "addImmOperands";
372 let ParserMethod = "parseImm";
375 class MxOp<ValueType vt, MxSize size, string letter>
377 MxOperand<vt, size, letter, ?> {
378 let ParserMatchClass = MxImm;
381 let OperandType = "OPERAND_IMMEDIATE",
382 PrintMethod = "printImmediate" in {
383 // IMMEDIATE DATA. This addressing mode requires either one or two words of
384 // extension depending on the size of the operation.
385 // Byte Operation - operand is low order byte of extension word
386 // Word Operation - operand is extension word
387 // Long Word Operation - operand is in the two extension words,
388 // high order 16 bits are in the first
389 // extension word, low order 16 bits are
390 // in the second extension word.
391 def Mxi8imm : MxOp<i8, MxSize8, "i">;
392 def Mxi16imm : MxOp<i16, MxSize16, "i">;
393 def Mxi32imm : MxOp<i32, MxSize32, "i">;
394 } // OPERAND_IMMEDIATE
396 class MxBrTargetOperand<int N> : Operand<OtherVT> {
397 let OperandType = "OPERAND_PCREL";
398 let PrintMethod = "printPCRelImm";
399 let ParserMatchClass = !cast<AsmOperandClass>("MxAddr"#N);
401 // Branch targets have OtherVT type and print as pc-relative values.
402 def MxBrTarget8 : MxBrTargetOperand<8>;
403 def MxBrTarget16 : MxBrTargetOperand<16>;
404 def MxBrTarget32 : MxBrTargetOperand<32>;
407 def MxMoveMask : MxOp<i16, MxSize16, "m"> {
408 let OperandType = "OPERAND_IMMEDIATE";
409 let PrintMethod = "printMoveMask";
412 //===----------------------------------------------------------------------===//
414 //===----------------------------------------------------------------------===//
416 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
417 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
418 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
419 "TM.getCodeModel() != CodeModel::Kernel">;
420 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
421 "TM.getCodeModel() == CodeModel::Kernel">;
422 def IsPIC : Predicate<"TM.isPositionIndependent()">;
423 def IsNotPIC : Predicate<"!TM.isPositionIndependent()">;
424 def IsM68000 : Predicate<"Subtarget.IsM68000()">;
425 def IsM68010 : Predicate<"Subtarget.IsM68010()">;
426 def IsM68020 : Predicate<"Subtarget.IsM68020()">;
427 def IsM68030 : Predicate<"Subtarget.IsM68030()">;
428 def IsM68040 : Predicate<"Subtarget.IsM68040()">;
431 //===----------------------------------------------------------------------===//
434 // These MUST be kept in sync with codes enum in M68kInstrInfo.h
435 //===----------------------------------------------------------------------===//
437 def MxCONDt : PatLeaf<(i8 0)>; // True
438 def MxCONDf : PatLeaf<(i8 1)>; // False
439 def MxCONDhi : PatLeaf<(i8 2)>; // High
440 def MxCONDls : PatLeaf<(i8 3)>; // Less or Same
441 def MxCONDcc : PatLeaf<(i8 4)>; // Carry Clear
442 def MxCONDcs : PatLeaf<(i8 5)>; // Carry Set
443 def MxCONDne : PatLeaf<(i8 6)>; // Not Equal
444 def MxCONDeq : PatLeaf<(i8 7)>; // Equal
445 def MxCONDvc : PatLeaf<(i8 8)>; // Overflow Clear
446 def MxCONDvs : PatLeaf<(i8 9)>; // Overflow Set
447 def MxCONDpl : PatLeaf<(i8 10)>; // Plus
448 def MxCONDmi : PatLeaf<(i8 11)>; // Minus
449 def MxCONDge : PatLeaf<(i8 12)>; // Greater or Equal
450 def MxCONDlt : PatLeaf<(i8 13)>; // Less Than
451 def MxCONDgt : PatLeaf<(i8 14)>; // Greater Than
452 def MxCONDle : PatLeaf<(i8 15)>; // Less or Equal
455 //===----------------------------------------------------------------------===//
457 //===----------------------------------------------------------------------===//
459 // NOTE Though this CP is not strictly necessarily it will simplify instruciton
461 def MxCP_ARI : ComplexPattern<iPTR, 1, "SelectARI",
462 [], [SDNPWantParent]>;
464 def MxCP_ARIPI : ComplexPattern<iPTR, 1, "SelectARIPI",
465 [], [SDNPWantParent]>;
467 def MxCP_ARIPD : ComplexPattern<iPTR, 1, "SelectARIPD",
468 [], [SDNPWantParent]>;
470 def MxCP_ARID : ComplexPattern<iPTR, 2, "SelectARID",
471 [add, sub, mul, or, shl, frameindex],
474 def MxCP_ARII : ComplexPattern<iPTR, 3, "SelectARII",
475 [add, sub, mul, or, shl, frameindex],
478 def MxCP_AL : ComplexPattern<iPTR, 1, "SelectAL",
479 [add, sub, mul, or, shl],
482 def MxCP_PCD : ComplexPattern<iPTR, 1, "SelectPCD",
483 [add, sub, mul, or, shl],
486 def MxCP_PCI : ComplexPattern<iPTR, 2, "SelectPCI",
487 [add, sub, mul, or, shl], [SDNPWantParent]>;
490 //===----------------------------------------------------------------------===//
492 //===----------------------------------------------------------------------===//
494 def MximmSExt8 : PatLeaf<(i8 imm)>;
495 def MximmSExt16 : PatLeaf<(i16 imm)>;
496 def MximmSExt32 : PatLeaf<(i32 imm)>;
498 // Used for Shifts and Rotations, since M68k immediates in these instructions
499 // are 1 <= i <= 8. Generally, if immediate is bigger than 8 it will be moved
500 // to a register and then an operation is performed.
502 // TODO Need to evaluate whether splitting one big shift(or rotate)
503 // into a few smaller is faster than doing a move, if so do custom lowering
504 def Mximm8_1to8 : ImmLeaf<i8, [{ return Imm >= 1 && Imm <= 8; }]>;
505 def Mximm16_1to8 : ImmLeaf<i16, [{ return Imm >= 1 && Imm <= 8; }]>;
506 def Mximm32_1to8 : ImmLeaf<i32, [{ return Imm >= 1 && Imm <= 8; }]>;
508 // Helper fragments for loads.
509 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
510 // known to be 32-bit aligned or better. Ditto for i8 to i16.
511 def Mxloadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
512 LoadSDNode *LD = cast<LoadSDNode>(N);
513 ISD::LoadExtType ExtType = LD->getExtensionType();
514 if (ExtType == ISD::NON_EXTLOAD)
516 if (ExtType == ISD::EXTLOAD)
517 return LD->getAlignment() >= 2 && !LD->isSimple();
521 def Mxloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
522 LoadSDNode *LD = cast<LoadSDNode>(N);
523 ISD::LoadExtType ExtType = LD->getExtensionType();
524 if (ExtType == ISD::NON_EXTLOAD)
526 if (ExtType == ISD::EXTLOAD)
527 return LD->getAlignment() >= 4 && !LD->isSimple();
531 def Mxloadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
533 def MxSExtLoadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
534 def MxSExtLoadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
535 def MxSExtLoadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
537 def MxZExtLoadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
538 def MxZExtLoadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
539 def MxZExtLoadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
540 def MxZExtLoadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
541 def MxZExtLoadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
542 def MxZExtLoadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
544 def MxExtLoadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
545 def MxExtLoadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
546 def MxExtLoadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
547 def MxExtLoadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
548 def MxExtLoadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
549 def MxExtLoadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
552 //===----------------------------------------------------------------------===//
555 // Type Fixtures are ValueType related information sets that usually go together
556 //===----------------------------------------------------------------------===//
558 // TODO make it folded like MxType8.F.Op nad MxType8.F.Pat
559 // TODO move strings into META subclass
560 // vt: Type of data this fixture refers to
561 // prefix: Prefix used to identify type
562 // postfix: Prefix used to qualify type
563 class MxType<ValueType vt, string prefix, string postfix,
564 // rLet: Register letter
565 // rOp: Supported any register operand
566 string rLet, MxOperand rOp,
567 // jOp: Supported ARI operand
568 // jPat: What ARI pattern to use
569 MxOperand jOp, ComplexPattern jPat,
570 // oOp: Supported ARIPI operand
571 // oPat: What ARIPI pattern is used
572 MxOperand oOp, ComplexPattern oPat,
573 // eOp: Supported ARIPD operand
574 // ePat: What ARIPD pattern is used
575 MxOperand eOp, ComplexPattern ePat,
576 // pOp: Supported ARID operand
577 // pPat: What ARID pattern is used
578 MxOperand pOp, ComplexPattern pPat,
579 // fOp: Supported ARII operand
580 // fPat: What ARII pattern is used
581 MxOperand fOp, ComplexPattern fPat,
582 // bOp: Supported absolute operand
583 // bPat: What absolute pattern is used
584 MxOperand bOp, ComplexPattern bPat,
585 // qOp: Supported PCD operand
586 // qPat: What PCD pattern is used
587 MxOperand qOp, ComplexPattern qPat,
588 // kOp: Supported PCD operand
589 // kPat: What PCD pattern is used
590 MxOperand kOp, ComplexPattern kPat,
591 // iOp: Supported immediate operand
592 // iPat: What immediate pattern is used
593 MxOperand iOp, PatFrag iPat,
594 // load: What load operation is used with MEM
598 string Prefix = prefix;
599 string Postfix = postfix;
605 ComplexPattern JPat = jPat;
608 ComplexPattern OPat = oPat;
611 ComplexPattern EPat = ePat;
614 ComplexPattern PPat = pPat;
617 ComplexPattern FPat = fPat;
620 ComplexPattern BPat = bPat;
623 ComplexPattern QPat = qPat;
626 ComplexPattern KPat = kPat;
634 class MxType8Class<string rLet, MxOperand reg>
635 : MxType<i8, "b", "", rLet, reg,
637 MxARIPI8, MxCP_ARIPI,
638 MxARIPD8, MxCP_ARIPD,
647 def MxType8 : MxType8Class<?,?>;
649 class MxType16Class<string rLet, MxOperand reg>
650 : MxType<i16, "w", "", rLet, reg,
652 MxARIPI16, MxCP_ARIPI,
653 MxARIPD16, MxCP_ARIPD,
659 Mxi16imm, MximmSExt16,
662 def MxType16 : MxType16Class<?,?>;
664 class MxType32Class<string rLet, MxOperand reg>
665 : MxType<i32, "l", "", rLet, reg,
667 MxARIPI32, MxCP_ARIPI,
668 MxARIPD32, MxCP_ARIPD,
674 Mxi32imm, MximmSExt32,
677 def MxType32 : MxType32Class<?,?>;
680 def MxType8d : MxType8Class<"d", MxDRD8>;
682 def MxType16d : MxType16Class<"d", MxDRD16>;
683 def MxType16a : MxType16Class<"a", MxARD16>;
684 def MxType16r : MxType16Class<"r", MxXRD16>;
685 def MxType32d : MxType32Class<"d", MxDRD32>;
686 def MxType32a : MxType32Class<"a", MxARD32>;
687 def MxType32r : MxType32Class<"r", MxXRD32>;
689 let Postfix = "_TC" in {
690 def MxType16d_TC : MxType16Class<"d", MxDRD16_TC>;
691 def MxType16a_TC : MxType16Class<"a", MxARD16_TC>;
692 def MxType16r_TC : MxType16Class<"r", MxXRD16_TC>;
693 def MxType32d_TC : MxType32Class<"d", MxDRD32_TC>;
694 def MxType32a_TC : MxType32Class<"a", MxARD32_TC>;
695 def MxType32r_TC : MxType32Class<"r", MxXRD32_TC>;
699 //===----------------------------------------------------------------------===//
701 //===----------------------------------------------------------------------===//
703 include "M68kInstrData.td"
704 include "M68kInstrShiftRotate.td"
705 include "M68kInstrBits.td"
706 include "M68kInstrArithmetic.td"
707 include "M68kInstrControl.td"
709 include "M68kInstrCompiler.td"