1//===-- ARMInstrFormats.td - ARM Instruction Formats -------*- tablegen -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 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. 18class Format<bits<6> val> { 19 bits<6> Value = val; 20} 21 22def Pseudo : Format<0>; 23def MulFrm : Format<1>; 24def BrFrm : Format<2>; 25def BrMiscFrm : Format<3>; 26 27def DPFrm : Format<4>; 28def DPSoRegRegFrm : Format<5>; 29 30def LdFrm : Format<6>; 31def StFrm : Format<7>; 32def LdMiscFrm : Format<8>; 33def StMiscFrm : Format<9>; 34def LdStMulFrm : Format<10>; 35 36def LdStExFrm : Format<11>; 37 38def ArithMiscFrm : Format<12>; 39def SatFrm : Format<13>; 40def ExtFrm : Format<14>; 41 42def 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>; 52 53def ThumbFrm : Format<25>; 54def MiscFrm : Format<26>; 55 56def 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>; 71def DPSoRegImmFrm : Format<42>; 72 73// Misc flags. 74 75// The instruction has an Rn register operand. 76// 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; } 83 84//===----------------------------------------------------------------------===// 85// ARM Instruction flags. These need to match ARMBaseInstrInfo.h. 86// 87 88// FIXME: Once the JIT is MC-ized, these can go away. 89// Addressing mode. 90class AddrMode<bits<5> val> { 91 bits<5> Value = val; 92} 93def 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>; 108def AddrModeT2_i8s4 : AddrMode<15>; 109def AddrMode_i12 : AddrMode<16>; 110 111// 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>; 118def IndexModeUpd : IndexMode<3>; 119 120// Instruction execution domain. 121class Domain<bits<3> val> { 122 bits<3> Value = val; 123} 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 128def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8 129 130//===----------------------------------------------------------------------===// 131// ARM special operands. 132// 133 134// ARM imod and iflag operands, used only by the CPS instruction. 135def imod_op : Operand<i32> { 136 let PrintMethod = "printCPSIMod"; 137} 138 139def ProcIFlagsOperand : AsmOperandClass { 140 let Name = "ProcIFlags"; 141 let ParserMethod = "parseProcIFlagsOperand"; 142} 143def iflags_op : Operand<i32> { 144 let PrintMethod = "printCPSIFlag"; 145 let ParserMatchClass = ProcIFlagsOperand; 146} 147 148// ARM Predicate operand. Default to 14 = always (AL). Second part is CC 149// register whose default is 0 (no register). 150def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; } 151def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm), 152 (ops (i32 14), (i32 zero_reg))> { 153 let PrintMethod = "printPredicateOperand"; 154 let ParserMatchClass = CondCodeOperand; 155 let DecoderMethod = "DecodePredicateOperand"; 156} 157 158// 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 168// Conditional code result for instructions whose 's' bit is set, e.g. subs. 169def CCOutOperand : AsmOperandClass { let Name = "CCOut"; } 170def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> { 171 let EncoderMethod = "getCCOutOpValue"; 172 let PrintMethod = "printSBitModifierOperand"; 173 let ParserMatchClass = CCOutOperand; 174 let DecoderMethod = "DecodeCCOutOperand"; 175} 176 177// Same as cc_out except it defaults to setting CPSR. 178def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> { 179 let EncoderMethod = "getCCOutOpValue"; 180 let PrintMethod = "printSBitModifierOperand"; 181 let ParserMatchClass = CCOutOperand; 182 let DecoderMethod = "DecodeCCOutOperand"; 183} 184 185// ARM special operands for disassembly only. 186// 187def SetEndAsmOperand : ImmAsmOperand { 188 let Name = "SetEndImm"; 189 let ParserMethod = "parseSetEndImm"; 190} 191def setend_op : Operand<i32> { 192 let PrintMethod = "printSetendOperand"; 193 let ParserMatchClass = SetEndAsmOperand; 194} 195 196def MSRMaskOperand : AsmOperandClass { 197 let Name = "MSRMask"; 198 let ParserMethod = "parseMSRMaskOperand"; 199} 200def msr_mask : Operand<i32> { 201 let PrintMethod = "printMSRMaskOperand"; 202 let DecoderMethod = "DecodeMSRMask"; 203 let ParserMatchClass = MSRMaskOperand; 204} 205 206def 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 216// Shift Right Immediate - A shift right immediate is encoded differently from 217// other shift immediates. The imm6 field is encoded like so: 218// 219// 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> 224def shr_imm8_asm_operand : ImmAsmOperand { let Name = "ShrImm8"; } 225def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> { 226 let EncoderMethod = "getShiftRight8Imm"; 227 let DecoderMethod = "DecodeShiftRight8Imm"; 228 let ParserMatchClass = shr_imm8_asm_operand; 229} 230def shr_imm16_asm_operand : ImmAsmOperand { let Name = "ShrImm16"; } 231def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> { 232 let EncoderMethod = "getShiftRight16Imm"; 233 let DecoderMethod = "DecodeShiftRight16Imm"; 234 let ParserMatchClass = shr_imm16_asm_operand; 235} 236def shr_imm32_asm_operand : ImmAsmOperand { let Name = "ShrImm32"; } 237def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> { 238 let EncoderMethod = "getShiftRight32Imm"; 239 let DecoderMethod = "DecodeShiftRight32Imm"; 240 let ParserMatchClass = shr_imm32_asm_operand; 241} 242def shr_imm64_asm_operand : ImmAsmOperand { let Name = "ShrImm64"; } 243def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> { 244 let EncoderMethod = "getShiftRight64Imm"; 245 let DecoderMethod = "DecodeShiftRight64Imm"; 246 let ParserMatchClass = shr_imm64_asm_operand; 247} 248 249 250// ARM Assembler operand for ldr Rd, =expression which generates an offset 251// to a constant pool entry or a MOV depending on the value of expression 252def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; } 253def const_pool_asm_imm : Operand<i32> { 254 let ParserMatchClass = const_pool_asm_operand; 255} 256 257 258//===----------------------------------------------------------------------===// 259// ARM Assembler alias templates. 260// 261// Note: When EmitPriority == 1, the alias will be used for printing 262class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0> 263 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>; 264class tInstAlias<string Asm, dag Result, bit EmitPriority = 0> 265 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>; 266class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0> 267 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>; 268class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0> 269 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>; 270class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0> 271 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>; 272class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0> 273 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>; 274class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0> 275 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>; 276 277 278class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>, 279 Requires<[HasVFP2]>; 280class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>, 281 Requires<[HasNEON]>; 282 283//===----------------------------------------------------------------------===// 284// ARM Instruction templates. 285// 286 287 288class InstTemplate<AddrMode am, int sz, IndexMode im, 289 Format f, Domain d, string cstr, InstrItinClass itin> 290 : Instruction { 291 let Namespace = "ARM"; 292 293 AddrMode AM = am; 294 int Size = sz; 295 IndexMode IM = im; 296 bits<2> IndexModeBits = IM.Value; 297 Format F = f; 298 bits<6> Form = F.Value; 299 Domain D = d; 300 bit isUnaryDataProc = 0; 301 bit canXformTo16Bit = 0; 302 // The instruction is a 16-bit flag setting Thumb instruction. Used 303 // by the parser to determine whether to require the 'S' suffix on the 304 // mnemonic (when not in an IT block) or preclude it (when in an IT block). 305 bit thumbArithFlagSetting = 0; 306 307 // If this is a pseudo instruction, mark it isCodeGenOnly. 308 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo"); 309 310 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h. 311 let TSFlags{4-0} = AM.Value; 312 let TSFlags{6-5} = IndexModeBits; 313 let TSFlags{12-7} = Form; 314 let TSFlags{13} = isUnaryDataProc; 315 let TSFlags{14} = canXformTo16Bit; 316 let TSFlags{17-15} = D.Value; 317 let TSFlags{18} = thumbArithFlagSetting; 318 319 let Constraints = cstr; 320 let Itinerary = itin; 321} 322 323class Encoding { 324 field bits<32> Inst; 325 // Mask of bits that cause an encoding to be UNPREDICTABLE. 326 // If a bit is set, then if the corresponding bit in the 327 // target encoding differs from its value in the "Inst" field, 328 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance). 329 field bits<32> Unpredictable = 0; 330 // SoftFail is the generic name for this field, but we alias it so 331 // as to make it more obvious what it means in ARM-land. 332 field bits<32> SoftFail = Unpredictable; 333} 334 335class InstARM<AddrMode am, int sz, IndexMode im, 336 Format f, Domain d, string cstr, InstrItinClass itin> 337 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding { 338 let DecoderNamespace = "ARM"; 339} 340 341// This Encoding-less class is used by Thumb1 to specify the encoding bits later 342// on by adding flavors to specific instructions. 343class InstThumb<AddrMode am, int sz, IndexMode im, 344 Format f, Domain d, string cstr, InstrItinClass itin> 345 : InstTemplate<am, sz, im, f, d, cstr, itin> { 346 let DecoderNamespace = "Thumb"; 347} 348 349// Pseudo-instructions for alternate assembly syntax (never used by codegen). 350// These are aliases that require C++ handling to convert to the target 351// instruction, while InstAliases can be handled directly by tblgen. 352class AsmPseudoInst<string asm, dag iops, dag oops = (outs)> 353 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain, 354 "", NoItinerary> { 355 let OutOperandList = oops; 356 let InOperandList = iops; 357 let Pattern = []; 358 let isCodeGenOnly = 0; // So we get asm matcher for it. 359 let AsmString = asm; 360 let isPseudo = 1; 361} 362 363class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)> 364 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>; 365class tAsmPseudo<string asm, dag iops, dag oops = (outs)> 366 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>; 367class t2AsmPseudo<string asm, dag iops, dag oops = (outs)> 368 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>; 369class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)> 370 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>; 371class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)> 372 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>; 373 374// Pseudo instructions for the code generator. 375class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern> 376 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, 377 GenericDomain, "", itin> { 378 let OutOperandList = oops; 379 let InOperandList = iops; 380 let Pattern = pattern; 381 let isCodeGenOnly = 1; 382 let isPseudo = 1; 383} 384 385// PseudoInst that's ARM-mode only. 386class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin, 387 list<dag> pattern> 388 : PseudoInst<oops, iops, itin, pattern> { 389 let Size = sz; 390 list<Predicate> Predicates = [IsARM]; 391} 392 393// PseudoInst that's Thumb-mode only. 394class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin, 395 list<dag> pattern> 396 : PseudoInst<oops, iops, itin, pattern> { 397 let Size = sz; 398 list<Predicate> Predicates = [IsThumb]; 399} 400 401// PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2) 402class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin, 403 list<dag> pattern> 404 : PseudoInst<oops, iops, itin, pattern> { 405 let Size = sz; 406 list<Predicate> Predicates = [IsThumb,HasV8MBaseline]; 407} 408 409// PseudoInst that's Thumb2-mode only. 410class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin, 411 list<dag> pattern> 412 : PseudoInst<oops, iops, itin, pattern> { 413 let Size = sz; 414 list<Predicate> Predicates = [IsThumb2]; 415} 416 417class ARMPseudoExpand<dag oops, dag iops, int sz, 418 InstrItinClass itin, list<dag> pattern, 419 dag Result> 420 : ARMPseudoInst<oops, iops, sz, itin, pattern>, 421 PseudoInstExpansion<Result>; 422 423class tPseudoExpand<dag oops, dag iops, int sz, 424 InstrItinClass itin, list<dag> pattern, 425 dag Result> 426 : tPseudoInst<oops, iops, sz, itin, pattern>, 427 PseudoInstExpansion<Result>; 428 429class t2PseudoExpand<dag oops, dag iops, int sz, 430 InstrItinClass itin, list<dag> pattern, 431 dag Result> 432 : t2PseudoInst<oops, iops, sz, itin, pattern>, 433 PseudoInstExpansion<Result>; 434 435// Almost all ARM instructions are predicable. 436class I<dag oops, dag iops, AddrMode am, int sz, 437 IndexMode im, Format f, InstrItinClass itin, 438 string opc, string asm, string cstr, 439 list<dag> pattern> 440 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> { 441 bits<4> p; 442 let Inst{31-28} = p; 443 let OutOperandList = oops; 444 let InOperandList = !con(iops, (ins pred:$p)); 445 let AsmString = !strconcat(opc, "${p}", asm); 446 let Pattern = pattern; 447 list<Predicate> Predicates = [IsARM]; 448} 449 450// A few are not predicable 451class InoP<dag oops, dag iops, AddrMode am, int sz, 452 IndexMode im, Format f, InstrItinClass itin, 453 string opc, string asm, string cstr, 454 list<dag> pattern> 455 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> { 456 let OutOperandList = oops; 457 let InOperandList = iops; 458 let AsmString = !strconcat(opc, asm); 459 let Pattern = pattern; 460 let isPredicable = 0; 461 list<Predicate> Predicates = [IsARM]; 462} 463 464// Same as I except it can optionally modify CPSR. Note it's modeled as an input 465// operand since by default it's a zero register. It will become an implicit def 466// once it's "flipped". 467class sI<dag oops, dag iops, AddrMode am, int sz, 468 IndexMode im, Format f, InstrItinClass itin, 469 string opc, string asm, string cstr, 470 list<dag> pattern> 471 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> { 472 bits<4> p; // Predicate operand 473 bits<1> s; // condition-code set flag ('1' if the insn should set the flags) 474 let Inst{31-28} = p; 475 let Inst{20} = s; 476 477 let OutOperandList = oops; 478 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s)); 479 let AsmString = !strconcat(opc, "${s}${p}", asm); 480 let Pattern = pattern; 481 list<Predicate> Predicates = [IsARM]; 482} 483 484// Special cases 485class XI<dag oops, dag iops, AddrMode am, int sz, 486 IndexMode im, Format f, InstrItinClass itin, 487 string asm, string cstr, list<dag> pattern> 488 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> { 489 let OutOperandList = oops; 490 let InOperandList = iops; 491 let AsmString = asm; 492 let Pattern = pattern; 493 list<Predicate> Predicates = [IsARM]; 494} 495 496class AI<dag oops, dag iops, Format f, InstrItinClass itin, 497 string opc, string asm, list<dag> pattern> 498 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin, 499 opc, asm, "", pattern>; 500class AsI<dag oops, dag iops, Format f, InstrItinClass itin, 501 string opc, string asm, list<dag> pattern> 502 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin, 503 opc, asm, "", pattern>; 504class AXI<dag oops, dag iops, Format f, InstrItinClass itin, 505 string asm, list<dag> pattern> 506 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin, 507 asm, "", pattern>; 508class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin, 509 string asm, list<dag> pattern> 510 : XI<oops, iops, am, 4, IndexModeNone, f, itin, 511 asm, "", pattern>; 512class AInoP<dag oops, dag iops, Format f, InstrItinClass itin, 513 string opc, string asm, list<dag> pattern> 514 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin, 515 opc, asm, "", pattern>; 516 517// Ctrl flow instructions 518class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin, 519 string opc, string asm, list<dag> pattern> 520 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin, 521 opc, asm, "", pattern> { 522 let Inst{27-24} = opcod; 523} 524class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin, 525 string asm, list<dag> pattern> 526 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin, 527 asm, "", pattern> { 528 let Inst{27-24} = opcod; 529} 530 531// BR_JT instructions 532class JTI<dag oops, dag iops, InstrItinClass itin, 533 string asm, list<dag> pattern> 534 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin, 535 asm, "", pattern>; 536 537class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin, 538 string opc, string asm, list<dag> pattern> 539 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin, 540 opc, asm, "", pattern> { 541 bits<4> Rt; 542 bits<4> addr; 543 let Inst{27-23} = 0b00011; 544 let Inst{22-21} = opcod; 545 let Inst{20} = 1; 546 let Inst{19-16} = addr; 547 let Inst{15-12} = Rt; 548 let Inst{11-10} = 0b11; 549 let Inst{9-8} = opcod2; 550 let Inst{7-0} = 0b10011111; 551} 552class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin, 553 string opc, string asm, list<dag> pattern> 554 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin, 555 opc, asm, "", pattern> { 556 bits<4> Rt; 557 bits<4> addr; 558 let Inst{27-23} = 0b00011; 559 let Inst{22-21} = opcod; 560 let Inst{20} = 0; 561 let Inst{19-16} = addr; 562 let Inst{11-10} = 0b11; 563 let Inst{9-8} = opcod2; 564 let Inst{7-4} = 0b1001; 565 let Inst{3-0} = Rt; 566} 567// Atomic load/store instructions 568class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin, 569 string opc, string asm, list<dag> pattern> 570 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>; 571 572class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin, 573 string opc, string asm, list<dag> pattern> 574 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> { 575 bits<4> Rd; 576 let Inst{15-12} = Rd; 577} 578 579// Exclusive load/store instructions 580 581class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin, 582 string opc, string asm, list<dag> pattern> 583 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>, 584 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>; 585 586class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin, 587 string opc, string asm, list<dag> pattern> 588 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>, 589 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> { 590 bits<4> Rd; 591 let Inst{15-12} = Rd; 592} 593 594class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern> 595 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> { 596 bits<4> Rt; 597 bits<4> Rt2; 598 bits<4> addr; 599 let Inst{27-23} = 0b00010; 600 let Inst{22} = b; 601 let Inst{21-20} = 0b00; 602 let Inst{19-16} = addr; 603 let Inst{15-12} = Rt; 604 let Inst{11-4} = 0b00001001; 605 let Inst{3-0} = Rt2; 606 607 let Unpredictable{11-8} = 0b1111; 608 let DecoderMethod = "DecodeSwap"; 609} 610// Acquire/Release load/store instructions 611class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin, 612 string opc, string asm, list<dag> pattern> 613 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>, 614 Requires<[IsARM, HasAcquireRelease]>; 615 616class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin, 617 string opc, string asm, list<dag> pattern> 618 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>, 619 Requires<[IsARM, HasAcquireRelease]> { 620 let Inst{15-12} = 0b1111; 621} 622 623// addrmode1 instructions 624class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin, 625 string opc, string asm, list<dag> pattern> 626 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin, 627 opc, asm, "", pattern> { 628 let Inst{24-21} = opcod; 629 let Inst{27-26} = 0b00; 630} 631class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin, 632 string opc, string asm, list<dag> pattern> 633 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin, 634 opc, asm, "", pattern> { 635 let Inst{24-21} = opcod; 636 let Inst{27-26} = 0b00; 637} 638class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin, 639 string asm, list<dag> pattern> 640 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin, 641 asm, "", pattern> { 642 let Inst{24-21} = opcod; 643 let Inst{27-26} = 0b00; 644} 645 646// loads 647 648// LDR/LDRB/STR/STRB/... 649class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am, 650 Format f, InstrItinClass itin, string opc, string asm, 651 list<dag> pattern> 652 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm, 653 "", pattern> { 654 let Inst{27-25} = op; 655 let Inst{24} = 1; // 24 == P 656 // 23 == U 657 let Inst{22} = isByte; 658 let Inst{21} = 0; // 21 == W 659 let Inst{20} = isLd; 660} 661// Indexed load/stores 662class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops, 663 IndexMode im, Format f, InstrItinClass itin, string opc, 664 string asm, string cstr, list<dag> pattern> 665 : I<oops, iops, AddrMode2, 4, im, f, itin, 666 opc, asm, cstr, pattern> { 667 bits<4> Rt; 668 let Inst{27-26} = 0b01; 669 let Inst{24} = isPre; // P bit 670 let Inst{22} = isByte; // B bit 671 let Inst{21} = isPre; // W bit 672 let Inst{20} = isLd; // L bit 673 let Inst{15-12} = Rt; 674} 675class AI2stridx_reg<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} = 1; 686 let Inst{23} = offset{12}; 687 let Inst{19-16} = Rn; 688 let Inst{11-5} = offset{11-5}; 689 let Inst{4} = 0; 690 let Inst{3-0} = offset{3-0}; 691} 692 693class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops, 694 IndexMode im, Format f, InstrItinClass itin, string opc, 695 string asm, string cstr, list<dag> pattern> 696 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr, 697 pattern> { 698 // AM2 store w/ two operands: (GPR, am2offset) 699 // {12} isAdd 700 // {11-0} imm12/Rm 701 bits<14> offset; 702 bits<4> Rn; 703 let Inst{25} = 0; 704 let Inst{23} = offset{12}; 705 let Inst{19-16} = Rn; 706 let Inst{11-0} = offset{11-0}; 707} 708 709 710// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB 711// but for now use this class for STRT and STRBT. 712class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops, 713 IndexMode im, Format f, InstrItinClass itin, string opc, 714 string asm, string cstr, list<dag> pattern> 715 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr, 716 pattern> { 717 // AM2 store w/ two operands: (GPR, am2offset) 718 // {17-14} Rn 719 // {13} 1 == Rm, 0 == imm12 720 // {12} isAdd 721 // {11-0} imm12/Rm 722 bits<18> addr; 723 let Inst{25} = addr{13}; 724 let Inst{23} = addr{12}; 725 let Inst{19-16} = addr{17-14}; 726 let Inst{11-0} = addr{11-0}; 727} 728 729// addrmode3 instructions 730class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f, 731 InstrItinClass itin, string opc, string asm, list<dag> pattern> 732 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin, 733 opc, asm, "", pattern> { 734 bits<14> addr; 735 bits<4> Rt; 736 let Inst{27-25} = 0b000; 737 let Inst{24} = 1; // P bit 738 let Inst{23} = addr{8}; // U bit 739 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm 740 let Inst{21} = 0; // W bit 741 let Inst{20} = op20; // L bit 742 let Inst{19-16} = addr{12-9}; // Rn 743 let Inst{15-12} = Rt; // Rt 744 let Inst{11-8} = addr{7-4}; // imm7_4/zero 745 let Inst{7-4} = op; 746 let Inst{3-0} = addr{3-0}; // imm3_0/Rm 747 748 let DecoderMethod = "DecodeAddrMode3Instruction"; 749} 750 751class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops, 752 IndexMode im, Format f, InstrItinClass itin, string opc, 753 string asm, string cstr, list<dag> pattern> 754 : I<oops, iops, AddrMode3, 4, im, f, itin, 755 opc, asm, cstr, pattern> { 756 bits<4> Rt; 757 let Inst{27-25} = 0b000; 758 let Inst{24} = isPre; // P bit 759 let Inst{21} = isPre; // W bit 760 let Inst{20} = op20; // L bit 761 let Inst{15-12} = Rt; // Rt 762 let Inst{7-4} = op; 763} 764 765// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB 766// but for now use this class for LDRSBT, LDRHT, LDSHT. 767class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops, 768 IndexMode im, Format f, InstrItinClass itin, string opc, 769 string asm, string cstr, list<dag> pattern> 770 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> { 771 // {13} 1 == imm8, 0 == Rm 772 // {12-9} Rn 773 // {8} isAdd 774 // {7-4} imm7_4/zero 775 // {3-0} imm3_0/Rm 776 bits<4> addr; 777 bits<4> Rt; 778 let Inst{27-25} = 0b000; 779 let Inst{24} = 0; // P bit 780 let Inst{21} = 1; 781 let Inst{20} = isLoad; // L bit 782 let Inst{19-16} = addr; // Rn 783 let Inst{15-12} = Rt; // Rt 784 let Inst{7-4} = op; 785} 786 787// stores 788class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin, 789 string opc, string asm, list<dag> pattern> 790 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin, 791 opc, asm, "", pattern> { 792 bits<14> addr; 793 bits<4> Rt; 794 let Inst{27-25} = 0b000; 795 let Inst{24} = 1; // P bit 796 let Inst{23} = addr{8}; // U bit 797 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm 798 let Inst{21} = 0; // W bit 799 let Inst{20} = 0; // L bit 800 let Inst{19-16} = addr{12-9}; // Rn 801 let Inst{15-12} = Rt; // Rt 802 let Inst{11-8} = addr{7-4}; // imm7_4/zero 803 let Inst{7-4} = op; 804 let Inst{3-0} = addr{3-0}; // imm3_0/Rm 805 let DecoderMethod = "DecodeAddrMode3Instruction"; 806} 807 808// addrmode4 instructions 809class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin, 810 string asm, string cstr, list<dag> pattern> 811 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> { 812 bits<4> p; 813 bits<16> regs; 814 bits<4> Rn; 815 let Inst{31-28} = p; 816 let Inst{27-25} = 0b100; 817 let Inst{22} = 0; // S bit 818 let Inst{19-16} = Rn; 819 let Inst{15-0} = regs; 820} 821 822// Unsigned multiply, multiply-accumulate instructions. 823class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin, 824 string opc, string asm, list<dag> pattern> 825 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin, 826 opc, asm, "", pattern> { 827 let Inst{7-4} = 0b1001; 828 let Inst{20} = 0; // S bit 829 let Inst{27-21} = opcod; 830} 831class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin, 832 string opc, string asm, list<dag> pattern> 833 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin, 834 opc, asm, "", pattern> { 835 let Inst{7-4} = 0b1001; 836 let Inst{27-21} = opcod; 837} 838 839// Most significant word multiply 840class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops, 841 InstrItinClass itin, string opc, string asm, list<dag> pattern> 842 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin, 843 opc, asm, "", pattern> { 844 bits<4> Rd; 845 bits<4> Rn; 846 bits<4> Rm; 847 let Inst{7-4} = opc7_4; 848 let Inst{20} = 1; 849 let Inst{27-21} = opcod; 850 let Inst{19-16} = Rd; 851 let Inst{11-8} = Rm; 852 let Inst{3-0} = Rn; 853} 854// MSW multiple w/ Ra operand 855class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops, 856 InstrItinClass itin, string opc, string asm, list<dag> pattern> 857 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> { 858 bits<4> Ra; 859 let Inst{15-12} = Ra; 860} 861 862// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y> 863class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops, 864 InstrItinClass itin, string opc, string asm, list<dag> pattern> 865 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin, 866 opc, asm, "", pattern> { 867 bits<4> Rn; 868 bits<4> Rm; 869 let Inst{4} = 0; 870 let Inst{7} = 1; 871 let Inst{20} = 0; 872 let Inst{27-21} = opcod; 873 let Inst{6-5} = bit6_5; 874 let Inst{11-8} = Rm; 875 let Inst{3-0} = Rn; 876} 877class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops, 878 InstrItinClass itin, string opc, string asm, list<dag> pattern> 879 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> { 880 bits<4> Rd; 881 let Inst{19-16} = Rd; 882} 883 884// AMulxyI with Ra operand 885class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops, 886 InstrItinClass itin, string opc, string asm, list<dag> pattern> 887 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> { 888 bits<4> Ra; 889 let Inst{15-12} = Ra; 890} 891// SMLAL* 892class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops, 893 InstrItinClass itin, string opc, string asm, list<dag> pattern> 894 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> { 895 bits<4> RdLo; 896 bits<4> RdHi; 897 let Inst{19-16} = RdHi; 898 let Inst{15-12} = RdLo; 899} 900 901// Extend instructions. 902class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin, 903 string opc, string asm, list<dag> pattern> 904 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin, 905 opc, asm, "", pattern> { 906 // All AExtI instructions have Rd and Rm register operands. 907 bits<4> Rd; 908 bits<4> Rm; 909 let Inst{15-12} = Rd; 910 let Inst{3-0} = Rm; 911 let Inst{7-4} = 0b0111; 912 let Inst{9-8} = 0b00; 913 let Inst{27-20} = opcod; 914 915 let Unpredictable{9-8} = 0b11; 916} 917 918// Misc Arithmetic instructions. 919class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops, 920 InstrItinClass itin, string opc, string asm, list<dag> pattern> 921 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin, 922 opc, asm, "", pattern> { 923 bits<4> Rd; 924 bits<4> Rm; 925 let Inst{27-20} = opcod; 926 let Inst{19-16} = 0b1111; 927 let Inst{15-12} = Rd; 928 let Inst{11-8} = 0b1111; 929 let Inst{7-4} = opc7_4; 930 let Inst{3-0} = Rm; 931} 932 933// Division instructions. 934class ADivA1I<bits<3> opcod, dag oops, dag iops, 935 InstrItinClass itin, string opc, string asm, list<dag> pattern> 936 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin, 937 opc, asm, "", pattern> { 938 bits<4> Rd; 939 bits<4> Rn; 940 bits<4> Rm; 941 let Inst{27-23} = 0b01110; 942 let Inst{22-20} = opcod; 943 let Inst{19-16} = Rd; 944 let Inst{15-12} = 0b1111; 945 let Inst{11-8} = Rm; 946 let Inst{7-4} = 0b0001; 947 let Inst{3-0} = Rn; 948} 949 950// PKH instructions 951def PKHLSLAsmOperand : ImmAsmOperand { 952 let Name = "PKHLSLImm"; 953 let ParserMethod = "parsePKHLSLImm"; 954} 955def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{ 956 let PrintMethod = "printPKHLSLShiftImm"; 957 let ParserMatchClass = PKHLSLAsmOperand; 958} 959def PKHASRAsmOperand : AsmOperandClass { 960 let Name = "PKHASRImm"; 961 let ParserMethod = "parsePKHASRImm"; 962} 963def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{ 964 let PrintMethod = "printPKHASRShiftImm"; 965 let ParserMatchClass = PKHASRAsmOperand; 966} 967 968class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin, 969 string opc, string asm, list<dag> pattern> 970 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin, 971 opc, asm, "", pattern> { 972 bits<4> Rd; 973 bits<4> Rn; 974 bits<4> Rm; 975 bits<5> sh; 976 let Inst{27-20} = opcod; 977 let Inst{19-16} = Rn; 978 let Inst{15-12} = Rd; 979 let Inst{11-7} = sh; 980 let Inst{6} = tb; 981 let Inst{5-4} = 0b01; 982 let Inst{3-0} = Rm; 983} 984 985//===----------------------------------------------------------------------===// 986 987// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode. 988class ARMPat<dag pattern, dag result> : Pat<pattern, result> { 989 list<Predicate> Predicates = [IsARM]; 990} 991class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> { 992 list<Predicate> Predicates = [IsARM, HasV5T]; 993} 994class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> { 995 list<Predicate> Predicates = [IsARM, HasV5TE]; 996} 997// ARMV5MOPat - Same as ARMV5TEPat with UseMulOps. 998class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> { 999 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps]; 1000} 1001class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> { 1002 list<Predicate> Predicates = [IsARM, HasV6]; 1003} 1004class VFPPat<dag pattern, dag result> : Pat<pattern, result> { 1005 list<Predicate> Predicates = [HasVFP2]; 1006} 1007class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> { 1008 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP]; 1009} 1010class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> { 1011 list<Predicate> Predicates = [IsThumb2, HasDSP]; 1012} 1013class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> { 1014 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP]; 1015} 1016//===----------------------------------------------------------------------===// 1017// Thumb Instruction Format Definitions. 1018// 1019 1020class ThumbI<dag oops, dag iops, AddrMode am, int sz, 1021 InstrItinClass itin, string asm, string cstr, list<dag> pattern> 1022 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1023 let OutOperandList = oops; 1024 let InOperandList = iops; 1025 let AsmString = asm; 1026 let Pattern = pattern; 1027 list<Predicate> Predicates = [IsThumb]; 1028} 1029 1030// TI - Thumb instruction. 1031class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern> 1032 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>; 1033 1034// Two-address instructions 1035class TIt<dag oops, dag iops, InstrItinClass itin, string asm, 1036 list<dag> pattern> 1037 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst", 1038 pattern>; 1039 1040// tBL, tBX 32-bit instructions 1041class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3, 1042 dag oops, dag iops, InstrItinClass itin, string asm, 1043 list<dag> pattern> 1044 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>, 1045 Encoding { 1046 let Inst{31-27} = opcod1; 1047 let Inst{15-14} = opcod2; 1048 let Inst{12} = opcod3; 1049} 1050 1051// BR_JT instructions 1052class TJTI<dag oops, dag iops, InstrItinClass itin, string asm, 1053 list<dag> pattern> 1054 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>; 1055 1056// Thumb1 only 1057class Thumb1I<dag oops, dag iops, AddrMode am, int sz, 1058 InstrItinClass itin, string asm, string cstr, list<dag> pattern> 1059 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1060 let OutOperandList = oops; 1061 let InOperandList = iops; 1062 let AsmString = asm; 1063 let Pattern = pattern; 1064 list<Predicate> Predicates = [IsThumb, IsThumb1Only]; 1065} 1066 1067class T1I<dag oops, dag iops, InstrItinClass itin, 1068 string asm, list<dag> pattern> 1069 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>; 1070class T1Ix2<dag oops, dag iops, InstrItinClass itin, 1071 string asm, list<dag> pattern> 1072 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>; 1073 1074// Two-address instructions 1075class T1It<dag oops, dag iops, InstrItinClass itin, 1076 string asm, string cstr, list<dag> pattern> 1077 : Thumb1I<oops, iops, AddrModeNone, 2, itin, 1078 asm, cstr, pattern>; 1079 1080// Thumb1 instruction that can either be predicated or set CPSR. 1081class Thumb1sI<dag oops, dag iops, AddrMode am, int sz, 1082 InstrItinClass itin, 1083 string opc, string asm, string cstr, list<dag> pattern> 1084 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1085 let OutOperandList = !con(oops, (outs s_cc_out:$s)); 1086 let InOperandList = !con(iops, (ins pred:$p)); 1087 let AsmString = !strconcat(opc, "${s}${p}", asm); 1088 let Pattern = pattern; 1089 let thumbArithFlagSetting = 1; 1090 list<Predicate> Predicates = [IsThumb, IsThumb1Only]; 1091 let DecoderNamespace = "ThumbSBit"; 1092} 1093 1094class T1sI<dag oops, dag iops, InstrItinClass itin, 1095 string opc, string asm, list<dag> pattern> 1096 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>; 1097 1098// Two-address instructions 1099class T1sIt<dag oops, dag iops, InstrItinClass itin, 1100 string opc, string asm, list<dag> pattern> 1101 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, 1102 "$Rn = $Rdn", pattern>; 1103 1104// Thumb1 instruction that can be predicated. 1105class Thumb1pI<dag oops, dag iops, AddrMode am, int sz, 1106 InstrItinClass itin, 1107 string opc, string asm, string cstr, list<dag> pattern> 1108 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1109 let OutOperandList = oops; 1110 let InOperandList = !con(iops, (ins pred:$p)); 1111 let AsmString = !strconcat(opc, "${p}", asm); 1112 let Pattern = pattern; 1113 list<Predicate> Predicates = [IsThumb, IsThumb1Only]; 1114} 1115 1116class T1pI<dag oops, dag iops, InstrItinClass itin, 1117 string opc, string asm, list<dag> pattern> 1118 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>; 1119 1120// Two-address instructions 1121class T1pIt<dag oops, dag iops, InstrItinClass itin, 1122 string opc, string asm, list<dag> pattern> 1123 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, 1124 "$Rn = $Rdn", pattern>; 1125 1126class T1pIs<dag oops, dag iops, 1127 InstrItinClass itin, string opc, string asm, list<dag> pattern> 1128 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>; 1129 1130class Encoding16 : Encoding { 1131 let Inst{31-16} = 0x0000; 1132} 1133 1134// A6.2 16-bit Thumb instruction encoding 1135class T1Encoding<bits<6> opcode> : Encoding16 { 1136 let Inst{15-10} = opcode; 1137} 1138 1139// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding. 1140class T1General<bits<5> opcode> : Encoding16 { 1141 let Inst{15-14} = 0b00; 1142 let Inst{13-9} = opcode; 1143} 1144 1145// A6.2.2 Data-processing encoding. 1146class T1DataProcessing<bits<4> opcode> : Encoding16 { 1147 let Inst{15-10} = 0b010000; 1148 let Inst{9-6} = opcode; 1149} 1150 1151// A6.2.3 Special data instructions and branch and exchange encoding. 1152class T1Special<bits<4> opcode> : Encoding16 { 1153 let Inst{15-10} = 0b010001; 1154 let Inst{9-6} = opcode; 1155} 1156 1157// A6.2.4 Load/store single data item encoding. 1158class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 { 1159 let Inst{15-12} = opA; 1160 let Inst{11-9} = opB; 1161} 1162class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative 1163 1164class T1BranchCond<bits<4> opcode> : Encoding16 { 1165 let Inst{15-12} = opcode; 1166} 1167 1168// Helper classes to encode Thumb1 loads and stores. For immediates, the 1169// following bits are used for "opA" (see A6.2.4): 1170// 1171// 0b0110 => Immediate, 4 bytes 1172// 0b1000 => Immediate, 2 bytes 1173// 0b0111 => Immediate, 1 byte 1174class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am, 1175 InstrItinClass itin, string opc, string asm, 1176 list<dag> pattern> 1177 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>, 1178 T1LoadStore<0b0101, opcode> { 1179 bits<3> Rt; 1180 bits<8> addr; 1181 let Inst{8-6} = addr{5-3}; // Rm 1182 let Inst{5-3} = addr{2-0}; // Rn 1183 let Inst{2-0} = Rt; 1184} 1185class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am, 1186 InstrItinClass itin, string opc, string asm, 1187 list<dag> pattern> 1188 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>, 1189 T1LoadStore<opA, {opB,?,?}> { 1190 bits<3> Rt; 1191 bits<8> addr; 1192 let Inst{10-6} = addr{7-3}; // imm5 1193 let Inst{5-3} = addr{2-0}; // Rn 1194 let Inst{2-0} = Rt; 1195} 1196 1197// A6.2.5 Miscellaneous 16-bit instructions encoding. 1198class T1Misc<bits<7> opcode> : Encoding16 { 1199 let Inst{15-12} = 0b1011; 1200 let Inst{11-5} = opcode; 1201} 1202 1203// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable. 1204class Thumb2I<dag oops, dag iops, AddrMode am, int sz, 1205 InstrItinClass itin, 1206 string opc, string asm, string cstr, list<dag> pattern> 1207 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1208 let OutOperandList = oops; 1209 let InOperandList = !con(iops, (ins pred:$p)); 1210 let AsmString = !strconcat(opc, "${p}", asm); 1211 let Pattern = pattern; 1212 list<Predicate> Predicates = [IsThumb2]; 1213 let DecoderNamespace = "Thumb2"; 1214} 1215 1216// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an 1217// input operand since by default it's a zero register. It will become an 1218// implicit def once it's "flipped". 1219// 1220// FIXME: This uses unified syntax so {s} comes before {p}. We should make it 1221// more consistent. 1222class Thumb2sI<dag oops, dag iops, AddrMode am, int sz, 1223 InstrItinClass itin, 1224 string opc, string asm, string cstr, list<dag> pattern> 1225 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1226 bits<1> s; // condition-code set flag ('1' if the insn should set the flags) 1227 let Inst{20} = s; 1228 1229 let OutOperandList = oops; 1230 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s)); 1231 let AsmString = !strconcat(opc, "${s}${p}", asm); 1232 let Pattern = pattern; 1233 list<Predicate> Predicates = [IsThumb2]; 1234 let DecoderNamespace = "Thumb2"; 1235} 1236 1237// Special cases 1238class Thumb2XI<dag oops, dag iops, AddrMode am, int sz, 1239 InstrItinClass itin, 1240 string asm, string cstr, list<dag> pattern> 1241 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1242 let OutOperandList = oops; 1243 let InOperandList = iops; 1244 let AsmString = asm; 1245 let Pattern = pattern; 1246 list<Predicate> Predicates = [IsThumb2]; 1247 let DecoderNamespace = "Thumb2"; 1248} 1249 1250class ThumbXI<dag oops, dag iops, AddrMode am, int sz, 1251 InstrItinClass itin, 1252 string asm, string cstr, list<dag> pattern> 1253 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> { 1254 let OutOperandList = oops; 1255 let InOperandList = iops; 1256 let AsmString = asm; 1257 let Pattern = pattern; 1258 list<Predicate> Predicates = [IsThumb, IsThumb1Only]; 1259 let DecoderNamespace = "Thumb"; 1260} 1261 1262class T2I<dag oops, dag iops, InstrItinClass itin, 1263 string opc, string asm, list<dag> pattern> 1264 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>; 1265class T2Ii12<dag oops, dag iops, InstrItinClass itin, 1266 string opc, string asm, list<dag> pattern> 1267 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>; 1268class T2Ii8<dag oops, dag iops, InstrItinClass itin, 1269 string opc, string asm, list<dag> pattern> 1270 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>; 1271class T2Iso<dag oops, dag iops, InstrItinClass itin, 1272 string opc, string asm, list<dag> pattern> 1273 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>; 1274class T2Ipc<dag oops, dag iops, InstrItinClass itin, 1275 string opc, string asm, list<dag> pattern> 1276 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>; 1277class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin, 1278 string opc, string asm, string cstr, list<dag> pattern> 1279 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr, 1280 pattern> { 1281 bits<4> Rt; 1282 bits<4> Rt2; 1283 bits<13> addr; 1284 let Inst{31-25} = 0b1110100; 1285 let Inst{24} = P; 1286 let Inst{23} = addr{8}; 1287 let Inst{22} = 1; 1288 let Inst{21} = W; 1289 let Inst{20} = isLoad; 1290 let Inst{19-16} = addr{12-9}; 1291 let Inst{15-12} = Rt{3-0}; 1292 let Inst{11-8} = Rt2{3-0}; 1293 let Inst{7-0} = addr{7-0}; 1294} 1295class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops, 1296 InstrItinClass itin, string opc, string asm, string cstr, 1297 list<dag> pattern> 1298 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr, 1299 pattern> { 1300 bits<4> Rt; 1301 bits<4> Rt2; 1302 bits<4> addr; 1303 bits<9> imm; 1304 let Inst{31-25} = 0b1110100; 1305 let Inst{24} = P; 1306 let Inst{23} = imm{8}; 1307 let Inst{22} = 1; 1308 let Inst{21} = W; 1309 let Inst{20} = isLoad; 1310 let Inst{19-16} = addr; 1311 let Inst{15-12} = Rt{3-0}; 1312 let Inst{11-8} = Rt2{3-0}; 1313 let Inst{7-0} = imm{7-0}; 1314} 1315 1316class T2sI<dag oops, dag iops, InstrItinClass itin, 1317 string opc, string asm, list<dag> pattern> 1318 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>; 1319 1320class T2XI<dag oops, dag iops, InstrItinClass itin, 1321 string asm, list<dag> pattern> 1322 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>; 1323class T2JTI<dag oops, dag iops, InstrItinClass itin, 1324 string asm, list<dag> pattern> 1325 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>; 1326 1327// Move to/from coprocessor instructions 1328class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm, 1329 list<dag> pattern> 1330 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> { 1331 let Inst{31-28} = opc; 1332} 1333 1334// Two-address instructions 1335class T2XIt<dag oops, dag iops, InstrItinClass itin, 1336 string asm, string cstr, list<dag> pattern> 1337 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>; 1338 1339// T2Ipreldst - Thumb2 pre-indexed load / store instructions. 1340class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre, 1341 dag oops, dag iops, 1342 AddrMode am, IndexMode im, InstrItinClass itin, 1343 string opc, string asm, string cstr, list<dag> pattern> 1344 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> { 1345 let OutOperandList = oops; 1346 let InOperandList = !con(iops, (ins pred:$p)); 1347 let AsmString = !strconcat(opc, "${p}", asm); 1348 let Pattern = pattern; 1349 list<Predicate> Predicates = [IsThumb2]; 1350 let DecoderNamespace = "Thumb2"; 1351 1352 bits<4> Rt; 1353 bits<13> addr; 1354 let Inst{31-27} = 0b11111; 1355 let Inst{26-25} = 0b00; 1356 let Inst{24} = signed; 1357 let Inst{23} = 0; 1358 let Inst{22-21} = opcod; 1359 let Inst{20} = load; 1360 let Inst{19-16} = addr{12-9}; 1361 let Inst{15-12} = Rt{3-0}; 1362 let Inst{11} = 1; 1363 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed 1364 let Inst{10} = pre; // The P bit. 1365 let Inst{9} = addr{8}; // Sign bit 1366 let Inst{8} = 1; // The W bit. 1367 let Inst{7-0} = addr{7-0}; 1368 1369 let DecoderMethod = "DecodeT2LdStPre"; 1370} 1371 1372// T2Ipostldst - Thumb2 post-indexed load / store instructions. 1373class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre, 1374 dag oops, dag iops, 1375 AddrMode am, IndexMode im, InstrItinClass itin, 1376 string opc, string asm, string cstr, list<dag> pattern> 1377 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> { 1378 let OutOperandList = oops; 1379 let InOperandList = !con(iops, (ins pred:$p)); 1380 let AsmString = !strconcat(opc, "${p}", asm); 1381 let Pattern = pattern; 1382 list<Predicate> Predicates = [IsThumb2]; 1383 let DecoderNamespace = "Thumb2"; 1384 1385 bits<4> Rt; 1386 bits<4> Rn; 1387 bits<9> offset; 1388 let Inst{31-27} = 0b11111; 1389 let Inst{26-25} = 0b00; 1390 let Inst{24} = signed; 1391 let Inst{23} = 0; 1392 let Inst{22-21} = opcod; 1393 let Inst{20} = load; 1394 let Inst{19-16} = Rn; 1395 let Inst{15-12} = Rt{3-0}; 1396 let Inst{11} = 1; 1397 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed 1398 let Inst{10} = pre; // The P bit. 1399 let Inst{9} = offset{8}; // Sign bit 1400 let Inst{8} = 1; // The W bit. 1401 let Inst{7-0} = offset{7-0}; 1402 1403 let DecoderMethod = "DecodeT2LdStPre"; 1404} 1405 1406// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode. 1407class T1Pat<dag pattern, dag result> : Pat<pattern, result> { 1408 list<Predicate> Predicates = [IsThumb, IsThumb1Only]; 1409} 1410 1411// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode. 1412class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> { 1413 list<Predicate> Predicates = [IsThumb2, HasV6T2]; 1414} 1415 1416// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode. 1417class T2Pat<dag pattern, dag result> : Pat<pattern, result> { 1418 list<Predicate> Predicates = [IsThumb2]; 1419} 1420 1421//===----------------------------------------------------------------------===// 1422 1423//===----------------------------------------------------------------------===// 1424// ARM VFP Instruction templates. 1425// 1426 1427// Almost all VFP instructions are predicable. 1428class VFPI<dag oops, dag iops, AddrMode am, int sz, 1429 IndexMode im, Format f, InstrItinClass itin, 1430 string opc, string asm, string cstr, list<dag> pattern> 1431 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> { 1432 bits<4> p; 1433 let Inst{31-28} = p; 1434 let OutOperandList = oops; 1435 let InOperandList = !con(iops, (ins pred:$p)); 1436 let AsmString = !strconcat(opc, "${p}", asm); 1437 let Pattern = pattern; 1438 let PostEncoderMethod = "VFPThumb2PostEncoder"; 1439 let DecoderNamespace = "VFP"; 1440 list<Predicate> Predicates = [HasVFP2]; 1441} 1442 1443// Special cases 1444class VFPXI<dag oops, dag iops, AddrMode am, int sz, 1445 IndexMode im, Format f, InstrItinClass itin, 1446 string asm, string cstr, list<dag> pattern> 1447 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> { 1448 bits<4> p; 1449 let Inst{31-28} = p; 1450 let OutOperandList = oops; 1451 let InOperandList = iops; 1452 let AsmString = asm; 1453 let Pattern = pattern; 1454 let PostEncoderMethod = "VFPThumb2PostEncoder"; 1455 let DecoderNamespace = "VFP"; 1456 list<Predicate> Predicates = [HasVFP2]; 1457} 1458 1459class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin, 1460 string opc, string asm, list<dag> pattern> 1461 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin, 1462 opc, asm, "", pattern> { 1463 let PostEncoderMethod = "VFPThumb2PostEncoder"; 1464} 1465 1466// ARM VFP addrmode5 loads and stores 1467class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops, 1468 InstrItinClass itin, 1469 string opc, string asm, list<dag> pattern> 1470 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone, 1471 VFPLdStFrm, itin, opc, asm, "", pattern> { 1472 // Instruction operands. 1473 bits<5> Dd; 1474 bits<13> addr; 1475 1476 // Encode instruction operands. 1477 let Inst{23} = addr{8}; // U (add = (U == '1')) 1478 let Inst{22} = Dd{4}; 1479 let Inst{19-16} = addr{12-9}; // Rn 1480 let Inst{15-12} = Dd{3-0}; 1481 let Inst{7-0} = addr{7-0}; // imm8 1482 1483 let Inst{27-24} = opcod1; 1484 let Inst{21-20} = opcod2; 1485 let Inst{11-9} = 0b101; 1486 let Inst{8} = 1; // Double precision 1487 1488 // Loads & stores operate on both NEON and VFP pipelines. 1489 let D = VFPNeonDomain; 1490} 1491 1492class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops, 1493 InstrItinClass itin, 1494 string opc, string asm, list<dag> pattern> 1495 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone, 1496 VFPLdStFrm, itin, opc, asm, "", pattern> { 1497 // Instruction operands. 1498 bits<5> Sd; 1499 bits<13> addr; 1500 1501 // Encode instruction operands. 1502 let Inst{23} = addr{8}; // U (add = (U == '1')) 1503 let Inst{22} = Sd{0}; 1504 let Inst{19-16} = addr{12-9}; // Rn 1505 let Inst{15-12} = Sd{4-1}; 1506 let Inst{7-0} = addr{7-0}; // imm8 1507 1508 let Inst{27-24} = opcod1; 1509 let Inst{21-20} = opcod2; 1510 let Inst{11-9} = 0b101; 1511 let Inst{8} = 0; // Single precision 1512 1513 // Loads & stores operate on both NEON and VFP pipelines. 1514 let D = VFPNeonDomain; 1515} 1516 1517class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops, 1518 InstrItinClass itin, 1519 string opc, string asm, list<dag> pattern> 1520 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone, 1521 VFPLdStFrm, itin, opc, asm, "", pattern> { 1522 list<Predicate> Predicates = [HasFullFP16]; 1523 1524 // Instruction operands. 1525 bits<5> Sd; 1526 bits<13> addr; 1527 1528 // Encode instruction operands. 1529 let Inst{23} = addr{8}; // U (add = (U == '1')) 1530 let Inst{22} = Sd{0}; 1531 let Inst{19-16} = addr{12-9}; // Rn 1532 let Inst{15-12} = Sd{4-1}; 1533 let Inst{7-0} = addr{7-0}; // imm8 1534 1535 let Inst{27-24} = opcod1; 1536 let Inst{21-20} = opcod2; 1537 let Inst{11-8} = 0b1001; // Half precision 1538 1539 // Loads & stores operate on both NEON and VFP pipelines. 1540 let D = VFPNeonDomain; 1541} 1542 1543// VFP Load / store multiple pseudo instructions. 1544class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr, 1545 list<dag> pattern> 1546 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain, 1547 cstr, itin> { 1548 let OutOperandList = oops; 1549 let InOperandList = !con(iops, (ins pred:$p)); 1550 let Pattern = pattern; 1551 list<Predicate> Predicates = [HasVFP2]; 1552} 1553 1554// Load / store multiple 1555 1556// Unknown precision 1557class AXXI4<dag oops, dag iops, IndexMode im, 1558 string asm, string cstr, list<dag> pattern> 1559 : VFPXI<oops, iops, AddrMode4, 4, im, 1560 VFPLdStFrm, NoItinerary, asm, cstr, pattern> { 1561 // Instruction operands. 1562 bits<4> Rn; 1563 bits<13> regs; 1564 1565 // Encode instruction operands. 1566 let Inst{19-16} = Rn; 1567 let Inst{22} = 0; 1568 let Inst{15-12} = regs{11-8}; 1569 let Inst{7-1} = regs{7-1}; 1570 1571 let Inst{27-25} = 0b110; 1572 let Inst{11-8} = 0b1011; 1573 let Inst{0} = 1; 1574} 1575 1576// Double precision 1577class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin, 1578 string asm, string cstr, list<dag> pattern> 1579 : VFPXI<oops, iops, AddrMode4, 4, im, 1580 VFPLdStMulFrm, itin, asm, cstr, pattern> { 1581 // Instruction operands. 1582 bits<4> Rn; 1583 bits<13> regs; 1584 1585 // Encode instruction operands. 1586 let Inst{19-16} = Rn; 1587 let Inst{22} = regs{12}; 1588 let Inst{15-12} = regs{11-8}; 1589 let Inst{7-1} = regs{7-1}; 1590 1591 let Inst{27-25} = 0b110; 1592 let Inst{11-9} = 0b101; 1593 let Inst{8} = 1; // Double precision 1594 let Inst{0} = 0; 1595} 1596 1597// Single Precision 1598class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin, 1599 string asm, string cstr, list<dag> pattern> 1600 : VFPXI<oops, iops, AddrMode4, 4, im, 1601 VFPLdStMulFrm, itin, asm, cstr, pattern> { 1602 // Instruction operands. 1603 bits<4> Rn; 1604 bits<13> regs; 1605 1606 // Encode instruction operands. 1607 let Inst{19-16} = Rn; 1608 let Inst{22} = regs{8}; 1609 let Inst{15-12} = regs{12-9}; 1610 let Inst{7-0} = regs{7-0}; 1611 1612 let Inst{27-25} = 0b110; 1613 let Inst{11-9} = 0b101; 1614 let Inst{8} = 0; // Single precision 1615} 1616 1617// Double precision, unary 1618class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4, 1619 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc, 1620 string asm, list<dag> pattern> 1621 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> { 1622 // Instruction operands. 1623 bits<5> Dd; 1624 bits<5> Dm; 1625 1626 // Encode instruction operands. 1627 let Inst{3-0} = Dm{3-0}; 1628 let Inst{5} = Dm{4}; 1629 let Inst{15-12} = Dd{3-0}; 1630 let Inst{22} = Dd{4}; 1631 1632 let Inst{27-23} = opcod1; 1633 let Inst{21-20} = opcod2; 1634 let Inst{19-16} = opcod3; 1635 let Inst{11-9} = 0b101; 1636 let Inst{8} = 1; // Double precision 1637 let Inst{7-6} = opcod4; 1638 let Inst{4} = opcod5; 1639 1640 let Predicates = [HasVFP2, HasDPVFP]; 1641} 1642 1643// Double precision, unary, not-predicated 1644class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4, 1645 bit opcod5, dag oops, dag iops, InstrItinClass itin, 1646 string asm, list<dag> pattern> 1647 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> { 1648 // Instruction operands. 1649 bits<5> Dd; 1650 bits<5> Dm; 1651 1652 let Inst{31-28} = 0b1111; 1653 1654 // Encode instruction operands. 1655 let Inst{3-0} = Dm{3-0}; 1656 let Inst{5} = Dm{4}; 1657 let Inst{15-12} = Dd{3-0}; 1658 let Inst{22} = Dd{4}; 1659 1660 let Inst{27-23} = opcod1; 1661 let Inst{21-20} = opcod2; 1662 let Inst{19-16} = opcod3; 1663 let Inst{11-9} = 0b101; 1664 let Inst{8} = 1; // Double precision 1665 let Inst{7-6} = opcod4; 1666 let Inst{4} = opcod5; 1667} 1668 1669// Double precision, binary 1670class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, 1671 dag iops, InstrItinClass itin, string opc, string asm, 1672 list<dag> pattern> 1673 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> { 1674 // Instruction operands. 1675 bits<5> Dd; 1676 bits<5> Dn; 1677 bits<5> Dm; 1678 1679 // Encode instruction operands. 1680 let Inst{3-0} = Dm{3-0}; 1681 let Inst{5} = Dm{4}; 1682 let Inst{19-16} = Dn{3-0}; 1683 let Inst{7} = Dn{4}; 1684 let Inst{15-12} = Dd{3-0}; 1685 let Inst{22} = Dd{4}; 1686 1687 let Inst{27-23} = opcod1; 1688 let Inst{21-20} = opcod2; 1689 let Inst{11-9} = 0b101; 1690 let Inst{8} = 1; // Double precision 1691 let Inst{6} = op6; 1692 let Inst{4} = op4; 1693 1694 let Predicates = [HasVFP2, HasDPVFP]; 1695} 1696 1697// FP, binary, not predicated 1698class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops, 1699 InstrItinClass itin, string asm, list<dag> pattern> 1700 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin, 1701 asm, "", pattern> 1702{ 1703 // Instruction operands. 1704 bits<5> Dd; 1705 bits<5> Dn; 1706 bits<5> Dm; 1707 1708 let Inst{31-28} = 0b1111; 1709 1710 // Encode instruction operands. 1711 let Inst{3-0} = Dm{3-0}; 1712 let Inst{5} = Dm{4}; 1713 let Inst{19-16} = Dn{3-0}; 1714 let Inst{7} = Dn{4}; 1715 let Inst{15-12} = Dd{3-0}; 1716 let Inst{22} = Dd{4}; 1717 1718 let Inst{27-23} = opcod1; 1719 let Inst{21-20} = opcod2; 1720 let Inst{11-9} = 0b101; 1721 let Inst{8} = 1; // double precision 1722 let Inst{6} = opcod3; 1723 let Inst{4} = 0; 1724 1725 let Predicates = [HasVFP2, HasDPVFP]; 1726} 1727 1728// Single precision, unary, predicated 1729class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4, 1730 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc, 1731 string asm, list<dag> pattern> 1732 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> { 1733 // Instruction operands. 1734 bits<5> Sd; 1735 bits<5> Sm; 1736 1737 // Encode instruction operands. 1738 let Inst{3-0} = Sm{4-1}; 1739 let Inst{5} = Sm{0}; 1740 let Inst{15-12} = Sd{4-1}; 1741 let Inst{22} = Sd{0}; 1742 1743 let Inst{27-23} = opcod1; 1744 let Inst{21-20} = opcod2; 1745 let Inst{19-16} = opcod3; 1746 let Inst{11-9} = 0b101; 1747 let Inst{8} = 0; // Single precision 1748 let Inst{7-6} = opcod4; 1749 let Inst{4} = opcod5; 1750} 1751 1752// Single precision, unary, non-predicated 1753class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4, 1754 bit opcod5, dag oops, dag iops, InstrItinClass itin, 1755 string asm, list<dag> pattern> 1756 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, 1757 VFPUnaryFrm, itin, asm, "", pattern> { 1758 // Instruction operands. 1759 bits<5> Sd; 1760 bits<5> Sm; 1761 1762 let Inst{31-28} = 0b1111; 1763 1764 // Encode instruction operands. 1765 let Inst{3-0} = Sm{4-1}; 1766 let Inst{5} = Sm{0}; 1767 let Inst{15-12} = Sd{4-1}; 1768 let Inst{22} = Sd{0}; 1769 1770 let Inst{27-23} = opcod1; 1771 let Inst{21-20} = opcod2; 1772 let Inst{19-16} = opcod3; 1773 let Inst{11-9} = 0b101; 1774 let Inst{8} = 0; // Single precision 1775 let Inst{7-6} = opcod4; 1776 let Inst{4} = opcod5; 1777} 1778 1779// Single precision unary, if no NEON. Same as ASuI except not available if 1780// NEON is enabled. 1781class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4, 1782 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc, 1783 string asm, list<dag> pattern> 1784 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm, 1785 pattern> { 1786 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP]; 1787} 1788 1789// Single precision, binary 1790class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops, 1791 InstrItinClass itin, string opc, string asm, list<dag> pattern> 1792 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> { 1793 // Instruction operands. 1794 bits<5> Sd; 1795 bits<5> Sn; 1796 bits<5> Sm; 1797 1798 // Encode instruction operands. 1799 let Inst{3-0} = Sm{4-1}; 1800 let Inst{5} = Sm{0}; 1801 let Inst{19-16} = Sn{4-1}; 1802 let Inst{7} = Sn{0}; 1803 let Inst{15-12} = Sd{4-1}; 1804 let Inst{22} = Sd{0}; 1805 1806 let Inst{27-23} = opcod1; 1807 let Inst{21-20} = opcod2; 1808 let Inst{11-9} = 0b101; 1809 let Inst{8} = 0; // Single precision 1810 let Inst{6} = op6; 1811 let Inst{4} = op4; 1812} 1813 1814// Single precision, binary, not predicated 1815class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops, 1816 InstrItinClass itin, string asm, list<dag> pattern> 1817 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, 1818 VFPBinaryFrm, itin, asm, "", pattern> 1819{ 1820 // Instruction operands. 1821 bits<5> Sd; 1822 bits<5> Sn; 1823 bits<5> Sm; 1824 1825 let Inst{31-28} = 0b1111; 1826 1827 // Encode instruction operands. 1828 let Inst{3-0} = Sm{4-1}; 1829 let Inst{5} = Sm{0}; 1830 let Inst{19-16} = Sn{4-1}; 1831 let Inst{7} = Sn{0}; 1832 let Inst{15-12} = Sd{4-1}; 1833 let Inst{22} = Sd{0}; 1834 1835 let Inst{27-23} = opcod1; 1836 let Inst{21-20} = opcod2; 1837 let Inst{11-9} = 0b101; 1838 let Inst{8} = 0; // Single precision 1839 let Inst{6} = opcod3; 1840 let Inst{4} = 0; 1841} 1842 1843// Single precision binary, if no NEON. Same as ASbI except not available if 1844// NEON is enabled. 1845class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, 1846 dag iops, InstrItinClass itin, string opc, string asm, 1847 list<dag> pattern> 1848 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> { 1849 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP]; 1850 1851 // Instruction operands. 1852 bits<5> Sd; 1853 bits<5> Sn; 1854 bits<5> Sm; 1855 1856 // Encode instruction operands. 1857 let Inst{3-0} = Sm{4-1}; 1858 let Inst{5} = Sm{0}; 1859 let Inst{19-16} = Sn{4-1}; 1860 let Inst{7} = Sn{0}; 1861 let Inst{15-12} = Sd{4-1}; 1862 let Inst{22} = Sd{0}; 1863} 1864 1865// Half precision, unary, predicated 1866class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4, 1867 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc, 1868 string asm, list<dag> pattern> 1869 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> { 1870 list<Predicate> Predicates = [HasFullFP16]; 1871 1872 // Instruction operands. 1873 bits<5> Sd; 1874 bits<5> Sm; 1875 1876 // Encode instruction operands. 1877 let Inst{3-0} = Sm{4-1}; 1878 let Inst{5} = Sm{0}; 1879 let Inst{15-12} = Sd{4-1}; 1880 let Inst{22} = Sd{0}; 1881 1882 let Inst{27-23} = opcod1; 1883 let Inst{21-20} = opcod2; 1884 let Inst{19-16} = opcod3; 1885 let Inst{11-8} = 0b1001; // Half precision 1886 let Inst{7-6} = opcod4; 1887 let Inst{4} = opcod5; 1888} 1889 1890// Half precision, unary, non-predicated 1891class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4, 1892 bit opcod5, dag oops, dag iops, InstrItinClass itin, 1893 string asm, list<dag> pattern> 1894 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, 1895 VFPUnaryFrm, itin, asm, "", pattern> { 1896 list<Predicate> Predicates = [HasFullFP16]; 1897 1898 // Instruction operands. 1899 bits<5> Sd; 1900 bits<5> Sm; 1901 1902 let Inst{31-28} = 0b1111; 1903 1904 // Encode instruction operands. 1905 let Inst{3-0} = Sm{4-1}; 1906 let Inst{5} = Sm{0}; 1907 let Inst{15-12} = Sd{4-1}; 1908 let Inst{22} = Sd{0}; 1909 1910 let Inst{27-23} = opcod1; 1911 let Inst{21-20} = opcod2; 1912 let Inst{19-16} = opcod3; 1913 let Inst{11-8} = 0b1001; // Half precision 1914 let Inst{7-6} = opcod4; 1915 let Inst{4} = opcod5; 1916} 1917 1918// Half precision, binary 1919class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops, 1920 InstrItinClass itin, string opc, string asm, list<dag> pattern> 1921 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> { 1922 list<Predicate> Predicates = [HasFullFP16]; 1923 1924 // Instruction operands. 1925 bits<5> Sd; 1926 bits<5> Sn; 1927 bits<5> Sm; 1928 1929 // Encode instruction operands. 1930 let Inst{3-0} = Sm{4-1}; 1931 let Inst{5} = Sm{0}; 1932 let Inst{19-16} = Sn{4-1}; 1933 let Inst{7} = Sn{0}; 1934 let Inst{15-12} = Sd{4-1}; 1935 let Inst{22} = Sd{0}; 1936 1937 let Inst{27-23} = opcod1; 1938 let Inst{21-20} = opcod2; 1939 let Inst{11-8} = 0b1001; // Half precision 1940 let Inst{6} = op6; 1941 let Inst{4} = op4; 1942} 1943 1944// Half precision, binary, not predicated 1945class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops, 1946 InstrItinClass itin, string asm, list<dag> pattern> 1947 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, 1948 VFPBinaryFrm, itin, asm, "", pattern> { 1949 list<Predicate> Predicates = [HasFullFP16]; 1950 1951 // Instruction operands. 1952 bits<5> Sd; 1953 bits<5> Sn; 1954 bits<5> Sm; 1955 1956 let Inst{31-28} = 0b1111; 1957 1958 // Encode instruction operands. 1959 let Inst{3-0} = Sm{4-1}; 1960 let Inst{5} = Sm{0}; 1961 let Inst{19-16} = Sn{4-1}; 1962 let Inst{7} = Sn{0}; 1963 let Inst{15-12} = Sd{4-1}; 1964 let Inst{22} = Sd{0}; 1965 1966 let Inst{27-23} = opcod1; 1967 let Inst{21-20} = opcod2; 1968 let Inst{11-8} = 0b1001; // Half precision 1969 let Inst{6} = opcod3; 1970 let Inst{4} = 0; 1971} 1972 1973// VFP conversion instructions 1974class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4, 1975 dag oops, dag iops, InstrItinClass itin, string opc, string asm, 1976 list<dag> pattern> 1977 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> { 1978 let Inst{27-23} = opcod1; 1979 let Inst{21-20} = opcod2; 1980 let Inst{19-16} = opcod3; 1981 let Inst{11-8} = opcod4; 1982 let Inst{6} = 1; 1983 let Inst{4} = 0; 1984} 1985 1986// VFP conversion between floating-point and fixed-point 1987class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5, 1988 dag oops, dag iops, InstrItinClass itin, string opc, string asm, 1989 list<dag> pattern> 1990 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> { 1991 bits<5> fbits; 1992 // size (fixed-point number): sx == 0 ? 16 : 32 1993 let Inst{7} = op5; // sx 1994 let Inst{5} = fbits{0}; 1995 let Inst{3-0} = fbits{4-1}; 1996} 1997 1998// VFP conversion instructions, if no NEON 1999class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4, 2000 dag oops, dag iops, InstrItinClass itin, 2001 string opc, string asm, list<dag> pattern> 2002 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm, 2003 pattern> { 2004 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP]; 2005} 2006 2007class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f, 2008 InstrItinClass itin, 2009 string opc, string asm, list<dag> pattern> 2010 : VFPAI<oops, iops, f, itin, opc, asm, pattern> { 2011 let Inst{27-20} = opcod1; 2012 let Inst{11-8} = opcod2; 2013 let Inst{4} = 1; 2014} 2015 2016class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, 2017 InstrItinClass itin, string opc, string asm, list<dag> pattern> 2018 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>; 2019 2020class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, 2021 InstrItinClass itin, string opc, string asm, list<dag> pattern> 2022 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>; 2023 2024class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, 2025 InstrItinClass itin, string opc, string asm, list<dag> pattern> 2026 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>; 2027 2028class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, 2029 InstrItinClass itin, string opc, string asm, list<dag> pattern> 2030 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>; 2031 2032//===----------------------------------------------------------------------===// 2033 2034//===----------------------------------------------------------------------===// 2035// ARM NEON Instruction templates. 2036// 2037 2038class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f, 2039 InstrItinClass itin, string opc, string dt, string asm, string cstr, 2040 list<dag> pattern> 2041 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> { 2042 let OutOperandList = oops; 2043 let InOperandList = !con(iops, (ins pred:$p)); 2044 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm); 2045 let Pattern = pattern; 2046 list<Predicate> Predicates = [HasNEON]; 2047 let DecoderNamespace = "NEON"; 2048} 2049 2050// Same as NeonI except it does not have a "data type" specifier. 2051class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f, 2052 InstrItinClass itin, string opc, string asm, string cstr, 2053 list<dag> pattern> 2054 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> { 2055 let OutOperandList = oops; 2056 let InOperandList = !con(iops, (ins pred:$p)); 2057 let AsmString = !strconcat(opc, "${p}", "\t", asm); 2058 let Pattern = pattern; 2059 list<Predicate> Predicates = [HasNEON]; 2060 let DecoderNamespace = "NEON"; 2061} 2062 2063// Same as NeonI except it is not predicated 2064class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f, 2065 InstrItinClass itin, string opc, string dt, string asm, string cstr, 2066 list<dag> pattern> 2067 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> { 2068 let OutOperandList = oops; 2069 let InOperandList = iops; 2070 let AsmString = !strconcat(opc, ".", dt, "\t", asm); 2071 let Pattern = pattern; 2072 list<Predicate> Predicates = [HasNEON]; 2073 let DecoderNamespace = "NEON"; 2074 2075 let Inst{31-28} = 0b1111; 2076} 2077 2078class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4, 2079 dag oops, dag iops, InstrItinClass itin, 2080 string opc, string dt, string asm, string cstr, list<dag> pattern> 2081 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm, 2082 cstr, pattern> { 2083 let Inst{31-24} = 0b11110100; 2084 let Inst{23} = op23; 2085 let Inst{21-20} = op21_20; 2086 let Inst{11-8} = op11_8; 2087 let Inst{7-4} = op7_4; 2088 2089 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder"; 2090 let DecoderNamespace = "NEONLoadStore"; 2091 2092 bits<5> Vd; 2093 bits<6> Rn; 2094 bits<4> Rm; 2095 2096 let Inst{22} = Vd{4}; 2097 let Inst{15-12} = Vd{3-0}; 2098 let Inst{19-16} = Rn{3-0}; 2099 let Inst{3-0} = Rm{3-0}; 2100} 2101 2102class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4, 2103 dag oops, dag iops, InstrItinClass itin, 2104 string opc, string dt, string asm, string cstr, list<dag> pattern> 2105 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc, 2106 dt, asm, cstr, pattern> { 2107 bits<3> lane; 2108} 2109 2110class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr> 2111 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr, 2112 itin> { 2113 let OutOperandList = oops; 2114 let InOperandList = !con(iops, (ins pred:$p)); 2115 list<Predicate> Predicates = [HasNEON]; 2116} 2117 2118class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr, 2119 list<dag> pattern> 2120 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr, 2121 itin> { 2122 let OutOperandList = oops; 2123 let InOperandList = !con(iops, (ins pred:$p)); 2124 let Pattern = pattern; 2125 list<Predicate> Predicates = [HasNEON]; 2126} 2127 2128class NDataI<dag oops, dag iops, Format f, InstrItinClass itin, 2129 string opc, string dt, string asm, string cstr, list<dag> pattern> 2130 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr, 2131 pattern> { 2132 let Inst{31-25} = 0b1111001; 2133 let PostEncoderMethod = "NEONThumb2DataIPostEncoder"; 2134 let DecoderNamespace = "NEONData"; 2135} 2136 2137class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin, 2138 string opc, string asm, string cstr, list<dag> pattern> 2139 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm, 2140 cstr, pattern> { 2141 let Inst{31-25} = 0b1111001; 2142 let PostEncoderMethod = "NEONThumb2DataIPostEncoder"; 2143 let DecoderNamespace = "NEONData"; 2144} 2145 2146// NEON "one register and a modified immediate" format. 2147class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6, 2148 bit op5, bit op4, 2149 dag oops, dag iops, InstrItinClass itin, 2150 string opc, string dt, string asm, string cstr, 2151 list<dag> pattern> 2152 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> { 2153 let Inst{23} = op23; 2154 let Inst{21-19} = op21_19; 2155 let Inst{11-8} = op11_8; 2156 let Inst{7} = op7; 2157 let Inst{6} = op6; 2158 let Inst{5} = op5; 2159 let Inst{4} = op4; 2160 2161 // Instruction operands. 2162 bits<5> Vd; 2163 bits<13> SIMM; 2164 2165 let Inst{15-12} = Vd{3-0}; 2166 let Inst{22} = Vd{4}; 2167 let Inst{24} = SIMM{7}; 2168 let Inst{18-16} = SIMM{6-4}; 2169 let Inst{3-0} = SIMM{3-0}; 2170 let DecoderMethod = "DecodeNEONModImmInstruction"; 2171} 2172 2173// NEON 2 vector register format. 2174class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16, 2175 bits<5> op11_7, bit op6, bit op4, 2176 dag oops, dag iops, InstrItinClass itin, 2177 string opc, string dt, string asm, string cstr, list<dag> pattern> 2178 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> { 2179 let Inst{24-23} = op24_23; 2180 let Inst{21-20} = op21_20; 2181 let Inst{19-18} = op19_18; 2182 let Inst{17-16} = op17_16; 2183 let Inst{11-7} = op11_7; 2184 let Inst{6} = op6; 2185 let Inst{4} = op4; 2186 2187 // Instruction operands. 2188 bits<5> Vd; 2189 bits<5> Vm; 2190 2191 let Inst{15-12} = Vd{3-0}; 2192 let Inst{22} = Vd{4}; 2193 let Inst{3-0} = Vm{3-0}; 2194 let Inst{5} = Vm{4}; 2195} 2196 2197// Same as N2V but not predicated. 2198class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6, 2199 dag oops, dag iops, InstrItinClass itin, string OpcodeStr, 2200 string Dt, list<dag> pattern> 2201 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin, 2202 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> { 2203 bits<5> Vd; 2204 bits<5> Vm; 2205 2206 // Encode instruction operands 2207 let Inst{22} = Vd{4}; 2208 let Inst{15-12} = Vd{3-0}; 2209 let Inst{5} = Vm{4}; 2210 let Inst{3-0} = Vm{3-0}; 2211 2212 // Encode constant bits 2213 let Inst{27-23} = 0b00111; 2214 let Inst{21-20} = 0b11; 2215 let Inst{19-18} = op19_18; 2216 let Inst{17-16} = op17_16; 2217 let Inst{11} = 0; 2218 let Inst{10-8} = op10_8; 2219 let Inst{7} = op7; 2220 let Inst{6} = op6; 2221 let Inst{4} = 0; 2222 2223 let DecoderNamespace = "NEON"; 2224} 2225 2226// Same as N2V except it doesn't have a datatype suffix. 2227class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16, 2228 bits<5> op11_7, bit op6, bit op4, 2229 dag oops, dag iops, InstrItinClass itin, 2230 string opc, string asm, string cstr, list<dag> pattern> 2231 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> { 2232 let Inst{24-23} = op24_23; 2233 let Inst{21-20} = op21_20; 2234 let Inst{19-18} = op19_18; 2235 let Inst{17-16} = op17_16; 2236 let Inst{11-7} = op11_7; 2237 let Inst{6} = op6; 2238 let Inst{4} = op4; 2239 2240 // Instruction operands. 2241 bits<5> Vd; 2242 bits<5> Vm; 2243 2244 let Inst{15-12} = Vd{3-0}; 2245 let Inst{22} = Vd{4}; 2246 let Inst{3-0} = Vm{3-0}; 2247 let Inst{5} = Vm{4}; 2248} 2249 2250// NEON 2 vector register with immediate. 2251class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4, 2252 dag oops, dag iops, Format f, InstrItinClass itin, 2253 string opc, string dt, string asm, string cstr, list<dag> pattern> 2254 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> { 2255 let Inst{24} = op24; 2256 let Inst{23} = op23; 2257 let Inst{11-8} = op11_8; 2258 let Inst{7} = op7; 2259 let Inst{6} = op6; 2260 let Inst{4} = op4; 2261 2262 // Instruction operands. 2263 bits<5> Vd; 2264 bits<5> Vm; 2265 bits<6> SIMM; 2266 2267 let Inst{15-12} = Vd{3-0}; 2268 let Inst{22} = Vd{4}; 2269 let Inst{3-0} = Vm{3-0}; 2270 let Inst{5} = Vm{4}; 2271 let Inst{21-16} = SIMM{5-0}; 2272} 2273 2274// NEON 3 vector register format. 2275 2276class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, 2277 bit op4, dag oops, dag iops, Format f, InstrItinClass itin, 2278 string opc, string dt, string asm, string cstr, 2279 list<dag> pattern> 2280 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> { 2281 let Inst{24} = op24; 2282 let Inst{23} = op23; 2283 let Inst{21-20} = op21_20; 2284 let Inst{11-8} = op11_8; 2285 let Inst{6} = op6; 2286 let Inst{4} = op4; 2287} 2288 2289class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4, 2290 dag oops, dag iops, Format f, InstrItinClass itin, 2291 string opc, string dt, string asm, string cstr, list<dag> pattern> 2292 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4, 2293 oops, iops, f, itin, opc, dt, asm, cstr, pattern> { 2294 // Instruction operands. 2295 bits<5> Vd; 2296 bits<5> Vn; 2297 bits<5> Vm; 2298 2299 let Inst{15-12} = Vd{3-0}; 2300 let Inst{22} = Vd{4}; 2301 let Inst{19-16} = Vn{3-0}; 2302 let Inst{7} = Vn{4}; 2303 let Inst{3-0} = Vm{3-0}; 2304 let Inst{5} = Vm{4}; 2305} 2306 2307class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6, 2308 bit op4, dag oops, dag iops,Format f, InstrItinClass itin, 2309 string OpcodeStr, string Dt, list<dag> pattern> 2310 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr, 2311 Dt, "$Vd, $Vn, $Vm", "", pattern> { 2312 bits<5> Vd; 2313 bits<5> Vn; 2314 bits<5> Vm; 2315 2316 // Encode instruction operands 2317 let Inst{22} = Vd{4}; 2318 let Inst{15-12} = Vd{3-0}; 2319 let Inst{19-16} = Vn{3-0}; 2320 let Inst{7} = Vn{4}; 2321 let Inst{5} = Vm{4}; 2322 let Inst{3-0} = Vm{3-0}; 2323 2324 // Encode constant bits 2325 let Inst{27-23} = op27_23; 2326 let Inst{21-20} = op21_20; 2327 let Inst{11-8} = op11_8; 2328 let Inst{6} = op6; 2329 let Inst{4} = op4; 2330} 2331 2332class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, 2333 bit op4, dag oops, dag iops, Format f, InstrItinClass itin, 2334 string opc, string dt, string asm, string cstr, 2335 list<dag> pattern> 2336 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4, 2337 oops, iops, f, itin, opc, dt, asm, cstr, pattern> { 2338 2339 // Instruction operands. 2340 bits<5> Vd; 2341 bits<5> Vn; 2342 bits<5> Vm; 2343 bit lane; 2344 2345 let Inst{15-12} = Vd{3-0}; 2346 let Inst{22} = Vd{4}; 2347 let Inst{19-16} = Vn{3-0}; 2348 let Inst{7} = Vn{4}; 2349 let Inst{3-0} = Vm{3-0}; 2350 let Inst{5} = lane; 2351} 2352 2353class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, 2354 bit op4, dag oops, dag iops, Format f, InstrItinClass itin, 2355 string opc, string dt, string asm, string cstr, 2356 list<dag> pattern> 2357 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4, 2358 oops, iops, f, itin, opc, dt, asm, cstr, pattern> { 2359 2360 // Instruction operands. 2361 bits<5> Vd; 2362 bits<5> Vn; 2363 bits<5> Vm; 2364 bits<2> lane; 2365 2366 let Inst{15-12} = Vd{3-0}; 2367 let Inst{22} = Vd{4}; 2368 let Inst{19-16} = Vn{3-0}; 2369 let Inst{7} = Vn{4}; 2370 let Inst{2-0} = Vm{2-0}; 2371 let Inst{5} = lane{1}; 2372 let Inst{3} = lane{0}; 2373} 2374 2375// Same as N3V except it doesn't have a data type suffix. 2376class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, 2377 bit op4, 2378 dag oops, dag iops, Format f, InstrItinClass itin, 2379 string opc, string asm, string cstr, list<dag> pattern> 2380 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> { 2381 let Inst{24} = op24; 2382 let Inst{23} = op23; 2383 let Inst{21-20} = op21_20; 2384 let Inst{11-8} = op11_8; 2385 let Inst{6} = op6; 2386 let Inst{4} = op4; 2387 2388 // Instruction operands. 2389 bits<5> Vd; 2390 bits<5> Vn; 2391 bits<5> Vm; 2392 2393 let Inst{15-12} = Vd{3-0}; 2394 let Inst{22} = Vd{4}; 2395 let Inst{19-16} = Vn{3-0}; 2396 let Inst{7} = Vn{4}; 2397 let Inst{3-0} = Vm{3-0}; 2398 let Inst{5} = Vm{4}; 2399} 2400 2401// NEON VMOVs between scalar and core registers. 2402class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3, 2403 dag oops, dag iops, Format f, InstrItinClass itin, 2404 string opc, string dt, string asm, list<dag> pattern> 2405 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain, 2406 "", itin> { 2407 let Inst{27-20} = opcod1; 2408 let Inst{11-8} = opcod2; 2409 let Inst{6-5} = opcod3; 2410 let Inst{4} = 1; 2411 // A8.6.303, A8.6.328, A8.6.329 2412 let Inst{3-0} = 0b0000; 2413 2414 let OutOperandList = oops; 2415 let InOperandList = !con(iops, (ins pred:$p)); 2416 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm); 2417 let Pattern = pattern; 2418 list<Predicate> Predicates = [HasNEON]; 2419 2420 let PostEncoderMethod = "NEONThumb2DupPostEncoder"; 2421 let DecoderNamespace = "NEONDup"; 2422 2423 bits<5> V; 2424 bits<4> R; 2425 bits<4> p; 2426 bits<4> lane; 2427 2428 let Inst{31-28} = p{3-0}; 2429 let Inst{7} = V{4}; 2430 let Inst{19-16} = V{3-0}; 2431 let Inst{15-12} = R{3-0}; 2432} 2433class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3, 2434 dag oops, dag iops, InstrItinClass itin, 2435 string opc, string dt, string asm, list<dag> pattern> 2436 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin, 2437 opc, dt, asm, pattern>; 2438class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3, 2439 dag oops, dag iops, InstrItinClass itin, 2440 string opc, string dt, string asm, list<dag> pattern> 2441 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin, 2442 opc, dt, asm, pattern>; 2443class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3, 2444 dag oops, dag iops, InstrItinClass itin, 2445 string opc, string dt, string asm, list<dag> pattern> 2446 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin, 2447 opc, dt, asm, pattern>; 2448 2449// Vector Duplicate Lane (from scalar to all elements) 2450class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops, 2451 InstrItinClass itin, string opc, string dt, string asm, 2452 list<dag> pattern> 2453 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> { 2454 let Inst{24-23} = 0b11; 2455 let Inst{21-20} = 0b11; 2456 let Inst{19-16} = op19_16; 2457 let Inst{11-7} = 0b11000; 2458 let Inst{6} = op6; 2459 let Inst{4} = 0; 2460 2461 bits<5> Vd; 2462 bits<5> Vm; 2463 2464 let Inst{22} = Vd{4}; 2465 let Inst{15-12} = Vd{3-0}; 2466 let Inst{5} = Vm{4}; 2467 let Inst{3-0} = Vm{3-0}; 2468} 2469 2470// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON 2471// for single-precision FP. 2472class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> { 2473 list<Predicate> Predicates = [HasNEON,UseNEONForFP]; 2474} 2475 2476// VFP/NEON Instruction aliases for type suffices. 2477// Note: When EmitPriority == 1, the alias will be used for printing 2478class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> : 2479 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasVFP2]>; 2480 2481// Note: When EmitPriority == 1, the alias will be used for printing 2482multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> { 2483 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>; 2484 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>; 2485 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>; 2486 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>; 2487} 2488 2489// Note: When EmitPriority == 1, the alias will be used for printing 2490multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> { 2491 let Predicates = [HasNEON] in { 2492 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>; 2493 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>; 2494 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>; 2495 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>; 2496} 2497} 2498 2499// The same alias classes using AsmPseudo instead, for the more complex 2500// stuff in NEON that InstAlias can't quite handle. 2501// Note that we can't use anonymous defm references here like we can 2502// above, as we care about the ultimate instruction enum names generated, unlike 2503// for instalias defs. 2504class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> : 2505 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>; 2506 2507// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM. 2508def : TokenAlias<".s8", ".i8">; 2509def : TokenAlias<".u8", ".i8">; 2510def : TokenAlias<".s16", ".i16">; 2511def : TokenAlias<".u16", ".i16">; 2512def : TokenAlias<".s32", ".i32">; 2513def : TokenAlias<".u32", ".i32">; 2514def : TokenAlias<".s64", ".i64">; 2515def : TokenAlias<".u64", ".i64">; 2516 2517def : TokenAlias<".i8", ".8">; 2518def : TokenAlias<".i16", ".16">; 2519def : TokenAlias<".i32", ".32">; 2520def : TokenAlias<".i64", ".64">; 2521 2522def : TokenAlias<".p8", ".8">; 2523def : TokenAlias<".p16", ".16">; 2524 2525def : TokenAlias<".f32", ".32">; 2526def : TokenAlias<".f64", ".64">; 2527def : TokenAlias<".f", ".f32">; 2528def : TokenAlias<".d", ".f64">; 2529