1//== M68kInstrInfo.td - Main M68k Instruction Definition -*- tablegen -*-=// 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/// \file 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. 13/// 14//===----------------------------------------------------------------------===// 15 16include "M68kInstrFormats.td" 17 18//===----------------------------------------------------------------------===// 19// Profiles 20//===----------------------------------------------------------------------===// 21 22def MxSDT_CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>; 23def MxSDT_CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>; 24 25def MxSDT_Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>; 26 27def MxSDT_Ret : SDTypeProfile<0, -1, [ 28 /* ADJ */ SDTCisVT<0, i32> 29]>; 30 31def MxSDT_TCRet : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>; 32 33def MxSDT_Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>; 34 35def MxSDT_UnArithCCROut : SDTypeProfile<2, 1, [ 36 /* RES */ SDTCisInt<0>, 37 /* CCR */ SDTCisVT<1, i8>, 38 /* OPD */ SDTCisSameAs<0, 2> 39]>; 40 41// RES, CCR <- op LHS, RHS 42def MxSDT_BiArithCCROut : SDTypeProfile<2, 2, [ 43 /* RES */ SDTCisInt<0>, 44 /* CCR */ SDTCisVT<1, i8>, 45 /* LHS */ SDTCisSameAs<0, 2>, 46 /* RHS */ SDTCisSameAs<0, 3> 47]>; 48 49// RES, CCR <- op LHS, RHS, CCR 50def 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> 56]>; 57 58// RES1, RES2, CCR <- op LHS, RHS 59def 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> 65]>; 66 67def MxSDT_CmpTest : SDTypeProfile<1, 2, [ 68 /* CCR */ SDTCisVT<0, i8>, 69 /* Ops */ SDTCisSameAs<1, 2> 70]>; 71 72def 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> 77]>; 78 79def MxSDT_BrCond : SDTypeProfile<0, 3, [ 80 /* Dest */ SDTCisVT<0, OtherVT>, 81 /* Cond */ SDTCisVT<1, i8>, 82 /* CCR */ SDTCisVT<2, i8> 83]>; 84 85def MxSDT_SetCC : SDTypeProfile<1, 2, [ 86 /* BOOL */ SDTCisVT<0, i8>, 87 /* Cond */ SDTCisVT<1, i8>, 88 /* CCR */ SDTCisVT<2, i8> 89]>; 90 91def MxSDT_SetCC_C : SDTypeProfile<1, 2, [ 92 /* BOOL */ SDTCisInt<0>, 93 /* Cond */ SDTCisVT<1, i8>, 94 /* CCR */ SDTCisVT<2, i8> 95]>; 96 97 98def MxSDT_SEG_ALLOCA : SDTypeProfile<1, 1,[ 99 /* MEM */ SDTCisVT<0, iPTR>, 100 /* SIZE */ SDTCisVT<1, iPTR> 101]>; 102 103 104//===----------------------------------------------------------------------===// 105// Nodes 106//===----------------------------------------------------------------------===// 107 108def MxCallSeqStart : SDNode<"ISD::CALLSEQ_START", MxSDT_CallSeqStart, 109 [SDNPHasChain, SDNPOutGlue]>; 110 111def MxCallSeqEnd : SDNode<"ISD::CALLSEQ_END", MxSDT_CallSeqEnd, 112 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 113 114def MxCall : SDNode<"M68kISD::CALL", MxSDT_Call, 115 [SDNPHasChain, SDNPOutGlue, 116 SDNPOptInGlue, SDNPVariadic]>; 117 118def MxRet : SDNode<"M68kISD::RET", MxSDT_Ret, 119 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 120 121def MxTCRet : SDNode<"M68kISD::TC_RETURN", MxSDT_TCRet, 122 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 123 124def MxWrapper : SDNode<"M68kISD::Wrapper", MxSDT_Wrapper>; 125def MxWrapperPC : SDNode<"M68kISD::WrapperPC", MxSDT_Wrapper>; 126 127def MxAdd : SDNode<"M68kISD::ADD", MxSDT_BiArithCCROut, [SDNPCommutative]>; 128def MxSub : SDNode<"M68kISD::SUB", MxSDT_BiArithCCROut>; 129def MxOr : SDNode<"M68kISD::OR", MxSDT_BiArithCCROut, [SDNPCommutative]>; 130def MxXor : SDNode<"M68kISD::XOR", MxSDT_BiArithCCROut, [SDNPCommutative]>; 131def MxAnd : SDNode<"M68kISD::AND", MxSDT_BiArithCCROut, [SDNPCommutative]>; 132 133def MxAddX : SDNode<"M68kISD::ADDX", MxSDT_BiArithCCRInOut>; 134def MxSubX : SDNode<"M68kISD::SUBX", MxSDT_BiArithCCRInOut>; 135 136def MxSMul : SDNode<"M68kISD::SMUL", MxSDT_BiArithCCROut, [SDNPCommutative]>; 137def MxUMul : SDNode<"M68kISD::UMUL", MxSDT_2BiArithCCROut, [SDNPCommutative]>; 138 139def MxCmp : SDNode<"M68kISD::CMP", MxSDT_CmpTest>; 140def MxBt : SDNode<"M68kISD::BT", MxSDT_CmpTest>; 141 142def MxCmov : SDNode<"M68kISD::CMOV", MxSDT_Cmov>; 143def MxBrCond : SDNode<"M68kISD::BRCOND", MxSDT_BrCond, [SDNPHasChain]>; 144def MxSetCC : SDNode<"M68kISD::SETCC", MxSDT_SetCC>; 145def MxSetCC_C : SDNode<"M68kISD::SETCC_CARRY", MxSDT_SetCC_C>; 146 147 148def MxSegAlloca : SDNode<"M68kISD::SEG_ALLOCA", MxSDT_SEG_ALLOCA, 149 [SDNPHasChain]>; 150 151 152//===----------------------------------------------------------------------===// 153// Operands 154//===----------------------------------------------------------------------===// 155 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. 158class MxSize<int num, string id, string full> { 159 int Num = num; 160 string Id = id; 161 string Full = full; 162} 163 164def MxSize8 : MxSize<8, "b", "byte">; 165def MxSize16 : MxSize<16, "w", "word">; 166def MxSize32 : MxSize<32, "l", "long">; 167 168class MxOpClass<string name> : AsmOperandClass { 169 let Name = name; 170 let ParserMethod = "parseMemOp"; 171} 172 173def MxRegClass : MxOpClass<"Reg">; 174 175class MxOperand<ValueType vt, MxSize size, string letter, RegisterClass rc, dag pat = (null_frag)> { 176 ValueType VT = vt; 177 string Letter = letter; 178 MxSize Size = size; 179 RegisterClass RC = rc; 180 dag Pat = pat; 181} 182 183class MxRegOp<ValueType vt, 184 RegisterClass rc, 185 MxSize size, 186 string letter, 187 string pm = "printOperand"> 188 : RegisterOperand<rc, pm>, 189 MxOperand<vt, size, letter, rc> { 190 let ParserMatchClass = MxRegClass; 191} 192 193// REGISTER DIRECT. The operand is in the data register specified by 194// the effective address register field. 195def MxXRD16 : MxRegOp<i16, XR16, MxSize16, "r">; 196def MxXRD32 : MxRegOp<i32, XR32, MxSize32, "r">; 197 198def MxXRD16_TC : MxRegOp<i16, XR16_TC, MxSize16, "r">; 199def MxXRD32_TC : MxRegOp<i32, XR32_TC, MxSize32, "r">; 200 201// DATA REGISTER DIRECT. The operand is in the data register specified by 202// the effective address register field. 203def MxDRD8 : MxRegOp<i8, DR8, MxSize8, "d">; 204def MxDRD16 : MxRegOp<i16, DR16, MxSize16, "d">; 205def MxDRD32 : MxRegOp<i32, DR32, MxSize32, "d">; 206 207def MxDRD16_TC : MxRegOp<i16, DR16_TC, MxSize16, "d">; 208def MxDRD32_TC : MxRegOp<i32, DR32_TC, MxSize32, "d">; 209 210// ADDRESS REGISTER DIRECT. The operand is in the address register specified by 211// the effective address register field. 212def MxARD16 : MxRegOp<i16, AR16, MxSize16, "a">; 213def MxARD32 : MxRegOp<i32, AR32, MxSize32, "a">; 214 215def MxARD16_TC : MxRegOp<i16, AR16_TC, MxSize16, "a">; 216def MxARD32_TC : MxRegOp<i32, AR32_TC, MxSize32, "a">; 217 218class MxMemOp<dag ops, MxSize size, string letter, 219 string printMethod = "printOperand", 220 AsmOperandClass parserMatchClass = ImmAsmOperand> 221 : Operand<iPTR>, MxOperand<iPTR, size, letter, ?> { 222 let PrintMethod = printMethod; 223 let MIOperandInfo = ops; 224 let ParserMatchClass = parserMatchClass; 225 let OperandType = "OPERAND_MEMORY"; 226} 227 228// ADDRESS REGISTER INDIRECT. The address of the operand is in the address 229// register specified by the register field. The reference is classified as 230// a data reference with the exception of the jump and jump-to-subroutine 231// instructions. 232def MxARI : MxOpClass<"ARI">; 233def MxARI8 : MxMemOp<(ops AR32), MxSize8, "j", "printARI8Mem", MxARI>; 234def MxARI16 : MxMemOp<(ops AR32), MxSize16, "j", "printARI16Mem", MxARI>; 235def MxARI32 : MxMemOp<(ops AR32), MxSize32, "j", "printARI32Mem", MxARI>; 236 237def MxARI8_TC : MxMemOp<(ops AR32_TC), MxSize8, "j", "printARI8Mem", MxARI>; 238def MxARI16_TC : MxMemOp<(ops AR32_TC), MxSize16, "j", "printARI16Mem", MxARI>; 239def MxARI32_TC : MxMemOp<(ops AR32_TC), MxSize32, "j", "printARI32Mem", MxARI>; 240 241// ADDRESS REGISTER INDIRECT WITH POSTINCREMENT. The address of the operand is 242// in the address register specified by the register field. After the operand 243// address is used, it is incremented by one, two, or four depending upon whether 244// the size of the operand is byte, word, or long word. If the address register 245// is the stack pointer and the operand size is byte, the address is incremented 246// by two rather than one to keep the stack pointer on a word boundary. 247// The reference is classified as a data reference. 248def MxARIPI : MxOpClass<"ARIPI">; 249def MxARIPI8 : MxMemOp<(ops AR32), MxSize8, "o", "printARIPI8Mem", MxARIPI>; 250def MxARIPI16 : MxMemOp<(ops AR32), MxSize16, "o", "printARIPI16Mem", MxARIPI>; 251def MxARIPI32 : MxMemOp<(ops AR32), MxSize32, "o", "printARIPI32Mem", MxARIPI>; 252 253def MxARIPI8_TC : MxMemOp<(ops AR32_TC), MxSize8, "o", "printARIPI8Mem", MxARIPI>; 254def MxARIPI16_TC : MxMemOp<(ops AR32_TC), MxSize16, "o", "printARIPI16Mem", MxARIPI>; 255def MxARIPI32_TC : MxMemOp<(ops AR32_TC), MxSize32, "o", "printARIPI32Mem", MxARIPI>; 256 257// ADDRESS REGISTER INDIRECT WITH PREDECREMENT. The address of the operand is in 258// the address register specified by the register field. Before the operand 259// address is used, it is decremented by one, two, or four depending upon whether 260// the operand size is byte, word, or long word. If the address register is 261// the stack pointer and the operand size is byte, the address is decremented by 262// two rather than one to keep the stack pointer on a word boundary. 263// The reference is classified as a data reference. 264def MxARIPD : MxOpClass<"ARIPD">; 265def MxARIPD8 : MxMemOp<(ops AR32), MxSize8, "e", "printARIPD8Mem", MxARIPD>; 266def MxARIPD16 : MxMemOp<(ops AR32), MxSize16, "e", "printARIPD16Mem", MxARIPD>; 267def MxARIPD32 : MxMemOp<(ops AR32), MxSize32, "e", "printARIPD32Mem", MxARIPD>; 268 269def MxARIPD8_TC : MxMemOp<(ops AR32_TC), MxSize8, "e", "printARIPD8Mem", MxARIPD>; 270def MxARIPD16_TC : MxMemOp<(ops AR32_TC), MxSize16, "e", "printARIPD16Mem", MxARIPD>; 271def MxARIPD32_TC : MxMemOp<(ops AR32_TC), MxSize32, "e", "printARIPD32Mem", MxARIPD>; 272 273// ADDRESS REGISTER INDIRECT WITH DISPLACEMENT. This addressing mode requires one 274// word of extension. The address of the operand is the sum of the address in 275// the address register and the sign-extended 16-bit displacement integer in the 276// extension word. The reference is classified as a data reference with the 277// exception of the jump and jump-to-subroutine instructions. 278def MxARID : MxOpClass<"ARID">; 279def MxARID8 : MxMemOp<(ops i16imm, AR32), MxSize8, "p", "printARID8Mem", MxARID>; 280def MxARID16 : MxMemOp<(ops i16imm, AR32), MxSize16, "p", "printARID16Mem", MxARID>; 281def MxARID32 : MxMemOp<(ops i16imm, AR32), MxSize32, "p", "printARID32Mem", MxARID>; 282 283def MxARID8_TC : MxMemOp<(ops i16imm, AR32_TC), MxSize8, "p", "printARID8Mem", MxARID>; 284def MxARID16_TC : MxMemOp<(ops i16imm, AR32_TC), MxSize16, "p", "printARID16Mem", MxARID>; 285def MxARID32_TC : MxMemOp<(ops i16imm, AR32_TC), MxSize32, "p", "printARID32Mem", MxARID>; 286 287// ADDRESS REGISTER INDIRECT WITH INDEX. This addressing mode requires one word 288// of extension. The address of the operand is the sum of the address in the 289// address register, the signextended displacement integer in the low order eight 290// bits of the extension word, and the contents of the index register. 291// The reference is classified as a data reference with the exception of the 292// jump and jump-to-subroutine instructions 293def MxARII : MxOpClass<"ARII">; 294def MxARII8 : MxMemOp<(ops i8imm, AR32, XR32), MxSize8, "f", "printARII8Mem", MxARII>; 295def MxARII16 : MxMemOp<(ops i8imm, AR32, XR32), MxSize16, "f", "printARII16Mem", MxARII>; 296def MxARII32 : MxMemOp<(ops i8imm, AR32, XR32), MxSize32, "f", "printARII32Mem", MxARII>; 297 298def MxARII8_TC : MxMemOp<(ops i8imm, AR32_TC, XR32_TC), MxSize8, "f", "printARII8Mem", MxARII>; 299def MxARII16_TC : MxMemOp<(ops i8imm, AR32_TC, XR32_TC), MxSize16, "f", "printARII16Mem", MxARII>; 300def MxARII32_TC : MxMemOp<(ops i8imm, AR32_TC, XR32_TC), MxSize32, "f", "printARII32Mem", MxARII>; 301 302// ABSOLUTE SHORT ADDRESS. This addressing mode requires one word of extension. 303// The address of the operand is the extension word. The 16-bit address is sign 304// extended before it is used. The reference is classified as a data reference 305// with the exception of the jump and jump-tosubroutine instructions. 306def MxAddr : MxOpClass<"Addr">; 307def MxAS8 : MxMemOp<(ops OtherVT), MxSize8, "B", "printAS8Mem", MxAddr>; 308def MxAS16 : MxMemOp<(ops OtherVT), MxSize16, "B", "printAS16Mem", MxAddr>; 309def MxAS32 : MxMemOp<(ops OtherVT), MxSize32, "B", "printAS32Mem", MxAddr>; 310 311// ABSOLUTE LONG ADDRESS. This addressing mode requires two words of extension. 312// The address of the operand is developed by the concatenation of the extension 313// words. The high order part of the address is the first extension word; the low 314// order part of the address is the second extension word. The reference is 315// classified as a data reference with the exception of the jump and jump 316// to-subroutine instructions. 317def MxAL8 : MxMemOp<(ops OtherVT), MxSize8, "b", "printAL8Mem", MxAddr>; 318def MxAL16 : MxMemOp<(ops OtherVT), MxSize16, "b", "printAL16Mem", MxAddr>; 319def MxAL32 : MxMemOp<(ops OtherVT), MxSize32, "b", "printAL32Mem", MxAddr>; 320 321def MxPCD : MxOpClass<"PCD">; 322def MxPCI : MxOpClass<"PCI">; 323 324let OperandType = "OPERAND_PCREL" in { 325// PROGRAM COUNTER WITH DISPLACEMENT. This addressing mode requires one word of 326// extension. The address of the operand is the sum of the address in the program 327// counter and the Sign-extended 16-bit displacement integer in the extension 328// word. The value in the program counter is the address of the extension word. 329// The reference is classified as a program reference. 330def MxPCD8 : MxMemOp<(ops i16imm), MxSize8, "q", "printPCD8Mem", MxPCD>; 331def MxPCD16 : MxMemOp<(ops i16imm), MxSize16, "q", "printPCD16Mem", MxPCD>; 332def MxPCD32 : MxMemOp<(ops i16imm), MxSize32, "q", "printPCD32Mem", MxPCD>; 333 334// PROGRAM COUNTER WITH INDEX. This addressing mode requires one word of 335// extension. The address is the sum of the address in the program counter, the 336// sign-extended displacement integer in the lower eight bits of the extension 337// word, and the contents of the index register. The value in the program 338// counter is the address of the extension word. This reference is classified as 339// a program reference. 340def MxPCI8 : MxMemOp<(ops i8imm, XR32), MxSize8, "k", "printPCI8Mem", MxPCI>; 341def MxPCI16 : MxMemOp<(ops i8imm, XR32), MxSize16, "k", "printPCI16Mem", MxPCI>; 342def MxPCI32 : MxMemOp<(ops i8imm, XR32), MxSize32, "k", "printPCI32Mem", MxPCI>; 343} // OPERAND_PCREL 344 345def MxImm : AsmOperandClass { 346 let Name = "MxImm"; 347 let PredicateMethod = "isImm"; 348 let RenderMethod = "addImmOperands"; 349 let ParserMethod = "parseImm"; 350} 351 352class MxOp<ValueType vt, MxSize size, string letter> 353 : Operand<vt>, 354 MxOperand<vt, size, letter, ?> { 355 let ParserMatchClass = MxImm; 356} 357 358let OperandType = "OPERAND_IMMEDIATE", 359 PrintMethod = "printImmediate" in { 360// IMMEDIATE DATA. This addressing mode requires either one or two words of 361// extension depending on the size of the operation. 362// Byte Operation - operand is low order byte of extension word 363// Word Operation - operand is extension word 364// Long Word Operation - operand is in the two extension words, 365// high order 16 bits are in the first 366// extension word, low order 16 bits are 367// in the second extension word. 368def Mxi8imm : MxOp<i8, MxSize8, "i">; 369def Mxi16imm : MxOp<i16, MxSize16, "i">; 370def Mxi32imm : MxOp<i32, MxSize32, "i">; 371} // OPERAND_IMMEDIATE 372 373let OperandType = "OPERAND_PCREL", 374 ParserMatchClass = MxAddr, 375 PrintMethod = "printPCRelImm" in { 376 377// Branch targets have OtherVT type and print as pc-relative values. 378def MxBrTarget8 : Operand<OtherVT>; 379def MxBrTarget16 : Operand<OtherVT>; 380def MxBrTarget32 : Operand<OtherVT>; 381 382} // OPERAND_PCREL 383 384// Used with MOVEM 385def MxMoveMask : MxOp<i16, MxSize16, "m"> { 386 let OperandType = "OPERAND_IMMEDIATE"; 387 let PrintMethod = "printMoveMask"; 388} 389 390//===----------------------------------------------------------------------===// 391// Predicates 392//===----------------------------------------------------------------------===// 393 394def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">; 395def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">; 396def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&" 397 "TM.getCodeModel() != CodeModel::Kernel">; 398def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||" 399 "TM.getCodeModel() == CodeModel::Kernel">; 400def IsPIC : Predicate<"TM.isPositionIndependent()">; 401def IsNotPIC : Predicate<"!TM.isPositionIndependent()">; 402def IsM68000 : Predicate<"Subtarget.IsM68000()">; 403def IsM68010 : Predicate<"Subtarget.IsM68010()">; 404def IsM68020 : Predicate<"Subtarget.IsM68020()">; 405def IsM68030 : Predicate<"Subtarget.IsM68030()">; 406def IsM68040 : Predicate<"Subtarget.IsM68040()">; 407 408 409//===----------------------------------------------------------------------===// 410// Condition Codes 411// 412// These MUST be kept in sync with codes enum in M68kInstrInfo.h 413//===----------------------------------------------------------------------===// 414 415def MxCONDt : PatLeaf<(i8 0)>; // True 416def MxCONDf : PatLeaf<(i8 1)>; // False 417def MxCONDhi : PatLeaf<(i8 2)>; // High 418def MxCONDls : PatLeaf<(i8 3)>; // Less or Same 419def MxCONDcc : PatLeaf<(i8 4)>; // Carry Clear 420def MxCONDcs : PatLeaf<(i8 5)>; // Carry Set 421def MxCONDne : PatLeaf<(i8 6)>; // Not Equal 422def MxCONDeq : PatLeaf<(i8 7)>; // Equal 423def MxCONDvc : PatLeaf<(i8 8)>; // Overflow Clear 424def MxCONDvs : PatLeaf<(i8 9)>; // Overflow Set 425def MxCONDpl : PatLeaf<(i8 10)>; // Plus 426def MxCONDmi : PatLeaf<(i8 11)>; // Minus 427def MxCONDge : PatLeaf<(i8 12)>; // Greater or Equal 428def MxCONDlt : PatLeaf<(i8 13)>; // Less Than 429def MxCONDgt : PatLeaf<(i8 14)>; // Greater Than 430def MxCONDle : PatLeaf<(i8 15)>; // Less or Equal 431 432 433//===----------------------------------------------------------------------===// 434// Complex Patterns 435//===----------------------------------------------------------------------===// 436 437// NOTE Though this CP is not strictly necessarily it will simplify instruciton 438// definitions 439def MxCP_ARI : ComplexPattern<iPTR, 1, "SelectARI", 440 [], [SDNPWantParent]>; 441 442def MxCP_ARIPI : ComplexPattern<iPTR, 1, "SelectARIPI", 443 [], [SDNPWantParent]>; 444 445def MxCP_ARIPD : ComplexPattern<iPTR, 1, "SelectARIPD", 446 [], [SDNPWantParent]>; 447 448def MxCP_ARID : ComplexPattern<iPTR, 2, "SelectARID", 449 [add, sub, mul, or, shl, frameindex], 450 [SDNPWantParent]>; 451 452def MxCP_ARII : ComplexPattern<iPTR, 3, "SelectARII", 453 [add, sub, mul, or, shl, frameindex], 454 [SDNPWantParent]>; 455 456def MxCP_AL : ComplexPattern<iPTR, 1, "SelectAL", 457 [add, sub, mul, or, shl], 458 [SDNPWantParent]>; 459 460def MxCP_PCD : ComplexPattern<iPTR, 1, "SelectPCD", 461 [add, sub, mul, or, shl], 462 [SDNPWantParent]>; 463 464def MxCP_PCI : ComplexPattern<iPTR, 2, "SelectPCI", 465 [add, sub, mul, or, shl], [SDNPWantParent]>; 466 467 468//===----------------------------------------------------------------------===// 469// Pattern Fragments 470//===----------------------------------------------------------------------===// 471 472def MximmSExt8 : PatLeaf<(i8 imm)>; 473def MximmSExt16 : PatLeaf<(i16 imm)>; 474def MximmSExt32 : PatLeaf<(i32 imm)>; 475 476// Used for Shifts and Rotations, since M68k immediates in these instructions 477// are 1 <= i <= 8. Generally, if immediate is bigger than 8 it will be moved 478// to a register and then an operation is performed. 479// 480// TODO Need to evaluate whether splitting one big shift(or rotate) 481// into a few smaller is faster than doing a move, if so do custom lowering 482def Mximm8_1to8 : ImmLeaf<i8, [{ return Imm >= 1 && Imm <= 8; }]>; 483def Mximm16_1to8 : ImmLeaf<i16, [{ return Imm >= 1 && Imm <= 8; }]>; 484def Mximm32_1to8 : ImmLeaf<i32, [{ return Imm >= 1 && Imm <= 8; }]>; 485 486// Helper fragments for loads. 487// It's always safe to treat a anyext i16 load as a i32 load if the i16 is 488// known to be 32-bit aligned or better. Ditto for i8 to i16. 489def Mxloadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{ 490 LoadSDNode *LD = cast<LoadSDNode>(N); 491 ISD::LoadExtType ExtType = LD->getExtensionType(); 492 if (ExtType == ISD::NON_EXTLOAD) 493 return true; 494 if (ExtType == ISD::EXTLOAD) 495 return LD->getAlignment() >= 2 && !LD->isSimple(); 496 return false; 497}]>; 498 499def Mxloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{ 500 LoadSDNode *LD = cast<LoadSDNode>(N); 501 ISD::LoadExtType ExtType = LD->getExtensionType(); 502 if (ExtType == ISD::NON_EXTLOAD) 503 return true; 504 if (ExtType == ISD::EXTLOAD) 505 return LD->getAlignment() >= 4 && !LD->isSimple(); 506 return false; 507}]>; 508 509def Mxloadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>; 510 511def MxSExtLoadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>; 512def MxSExtLoadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>; 513def MxSExtLoadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>; 514 515def MxZExtLoadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>; 516def MxZExtLoadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>; 517def MxZExtLoadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>; 518def MxZExtLoadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>; 519def MxZExtLoadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>; 520def MxZExtLoadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>; 521 522def MxExtLoadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>; 523def MxExtLoadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>; 524def MxExtLoadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>; 525def MxExtLoadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>; 526def MxExtLoadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>; 527def MxExtLoadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>; 528 529 530//===----------------------------------------------------------------------===// 531// Type Fixtures 532// 533// Type Fixtures are ValueType related information sets that usually go together 534//===----------------------------------------------------------------------===// 535 536// TODO make it folded like MxType8.F.Op nad MxType8.F.Pat 537// TODO move strings into META subclass 538// vt: Type of data this fixture refers to 539// prefix: Prefix used to identify type 540// postfix: Prefix used to qualify type 541class MxType<ValueType vt, string prefix, string postfix, 542 // rLet: Register letter 543 // rOp: Supported any register operand 544 string rLet, MxOperand rOp, 545 // jOp: Supported ARI operand 546 // jPat: What ARI pattern to use 547 MxOperand jOp, ComplexPattern jPat, 548 // oOp: Supported ARIPI operand 549 // oPat: What ARIPI pattern is used 550 MxOperand oOp, ComplexPattern oPat, 551 // eOp: Supported ARIPD operand 552 // ePat: What ARIPD pattern is used 553 MxOperand eOp, ComplexPattern ePat, 554 // pOp: Supported ARID operand 555 // pPat: What ARID pattern is used 556 MxOperand pOp, ComplexPattern pPat, 557 // fOp: Supported ARII operand 558 // fPat: What ARII pattern is used 559 MxOperand fOp, ComplexPattern fPat, 560 // bOp: Supported absolute operand 561 // bPat: What absolute pattern is used 562 MxOperand bOp, ComplexPattern bPat, 563 // qOp: Supported PCD operand 564 // qPat: What PCD pattern is used 565 MxOperand qOp, ComplexPattern qPat, 566 // kOp: Supported PCD operand 567 // kPat: What PCD pattern is used 568 MxOperand kOp, ComplexPattern kPat, 569 // iOp: Supported immediate operand 570 // iPat: What immediate pattern is used 571 MxOperand iOp, PatFrag iPat, 572 // load: What load operation is used with MEM 573 PatFrag load> { 574 int Size = vt.Size; 575 ValueType VT = vt; 576 string Prefix = prefix; 577 string Postfix = postfix; 578 579 string RLet = rLet; 580 MxOperand ROp = rOp; 581 582 MxOperand JOp = jOp; 583 ComplexPattern JPat = jPat; 584 585 MxOperand OOp = oOp; 586 ComplexPattern OPat = oPat; 587 588 MxOperand EOp = eOp; 589 ComplexPattern EPat = ePat; 590 591 MxOperand POp = pOp; 592 ComplexPattern PPat = pPat; 593 594 MxOperand FOp = fOp; 595 ComplexPattern FPat = fPat; 596 597 MxOperand BOp = bOp; 598 ComplexPattern BPat = bPat; 599 600 MxOperand QOp = qOp; 601 ComplexPattern QPat = qPat; 602 603 MxOperand KOp = kOp; 604 ComplexPattern KPat = kPat; 605 606 MxOperand IOp = iOp; 607 PatFrag IPat = iPat; 608 609 PatFrag Load = load; 610} 611 612class MxType8Class<string rLet, MxOperand reg> 613 : MxType<i8, "b", "", rLet, reg, 614 MxARI8, MxCP_ARI, 615 MxARIPI8, MxCP_ARIPI, 616 MxARIPD8, MxCP_ARIPD, 617 MxARID8, MxCP_ARID, 618 MxARII8, MxCP_ARII, 619 MxAL8, MxCP_AL, 620 MxPCD8, MxCP_PCD, 621 MxPCI8, MxCP_PCI, 622 Mxi8imm, MximmSExt8, 623 Mxloadi8>; 624 625def MxType8 : MxType8Class<?,?>; 626 627class MxType16Class<string rLet, MxOperand reg> 628 : MxType<i16, "w", "", rLet, reg, 629 MxARI16, MxCP_ARI, 630 MxARIPI16, MxCP_ARIPI, 631 MxARIPD16, MxCP_ARIPD, 632 MxARID16, MxCP_ARID, 633 MxARII16, MxCP_ARII, 634 MxAL16, MxCP_AL, 635 MxPCD16, MxCP_PCD, 636 MxPCI16, MxCP_PCI, 637 Mxi16imm, MximmSExt16, 638 Mxloadi16>; 639 640def MxType16 : MxType16Class<?,?>; 641 642class MxType32Class<string rLet, MxOperand reg> 643 : MxType<i32, "l", "", rLet, reg, 644 MxARI32, MxCP_ARI, 645 MxARIPI32, MxCP_ARIPI, 646 MxARIPD32, MxCP_ARIPD, 647 MxARID32, MxCP_ARID, 648 MxARII32, MxCP_ARII, 649 MxAL32, MxCP_AL, 650 MxPCD32, MxCP_PCD, 651 MxPCI32, MxCP_PCI, 652 Mxi32imm, MximmSExt32, 653 Mxloadi32>; 654 655def MxType32 : MxType32Class<?,?>; 656 657 658def MxType8d : MxType8Class<"d", MxDRD8>; 659 660def MxType16d : MxType16Class<"d", MxDRD16>; 661def MxType16a : MxType16Class<"a", MxARD16>; 662def MxType16r : MxType16Class<"r", MxXRD16>; 663def MxType32d : MxType32Class<"d", MxDRD32>; 664def MxType32a : MxType32Class<"a", MxARD32>; 665def MxType32r : MxType32Class<"r", MxXRD32>; 666 667let Postfix = "_TC" in { 668def MxType16d_TC : MxType16Class<"d", MxDRD16_TC>; 669def MxType16a_TC : MxType16Class<"a", MxARD16_TC>; 670def MxType16r_TC : MxType16Class<"r", MxXRD16_TC>; 671def MxType32d_TC : MxType32Class<"d", MxDRD32_TC>; 672def MxType32a_TC : MxType32Class<"a", MxARD32_TC>; 673def MxType32r_TC : MxType32Class<"r", MxXRD32_TC>; 674} 675 676 677//===----------------------------------------------------------------------===// 678// Subsystems 679//===----------------------------------------------------------------------===// 680 681include "M68kInstrData.td" 682include "M68kInstrShiftRotate.td" 683include "M68kInstrBits.td" 684include "M68kInstrArithmetic.td" 685include "M68kInstrControl.td" 686 687include "M68kInstrCompiler.td" 688