X86InstrFormats.td 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. //===-- X86InstrFormats.td - X86 Instruction Formats -------*- 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. // X86 Instruction Format Definitions.
  10. //
  11. // Format specifies the encoding used by the instruction. This is part of the
  12. // ad-hoc solution used to emit machine instruction encodings by our machine
  13. // code emitter.
  14. class Format<bits<7> val> {
  15. bits<7> Value = val;
  16. }
  17. def Pseudo : Format<0>;
  18. def RawFrm : Format<1>;
  19. def AddRegFrm : Format<2>;
  20. def RawFrmMemOffs : Format<3>;
  21. def RawFrmSrc : Format<4>;
  22. def RawFrmDst : Format<5>;
  23. def RawFrmDstSrc : Format<6>;
  24. def RawFrmImm8 : Format<7>;
  25. def RawFrmImm16 : Format<8>;
  26. def AddCCFrm : Format<9>;
  27. def PrefixByte : Format<10>;
  28. def MRMDestMem4VOp3CC : Format<20>;
  29. def MRMr0 : Format<21>;
  30. def MRMSrcMemFSIB : Format<22>;
  31. def MRMDestMemFSIB : Format<23>;
  32. def MRMDestMem : Format<24>;
  33. def MRMSrcMem : Format<25>;
  34. def MRMSrcMem4VOp3 : Format<26>;
  35. def MRMSrcMemOp4 : Format<27>;
  36. def MRMSrcMemCC : Format<28>;
  37. def MRMXmCC: Format<30>;
  38. def MRMXm : Format<31>;
  39. def MRM0m : Format<32>; def MRM1m : Format<33>; def MRM2m : Format<34>;
  40. def MRM3m : Format<35>; def MRM4m : Format<36>; def MRM5m : Format<37>;
  41. def MRM6m : Format<38>; def MRM7m : Format<39>;
  42. def MRMDestReg : Format<40>;
  43. def MRMSrcReg : Format<41>;
  44. def MRMSrcReg4VOp3 : Format<42>;
  45. def MRMSrcRegOp4 : Format<43>;
  46. def MRMSrcRegCC : Format<44>;
  47. def MRMXrCC: Format<46>;
  48. def MRMXr : Format<47>;
  49. def MRM0r : Format<48>; def MRM1r : Format<49>; def MRM2r : Format<50>;
  50. def MRM3r : Format<51>; def MRM4r : Format<52>; def MRM5r : Format<53>;
  51. def MRM6r : Format<54>; def MRM7r : Format<55>;
  52. def MRM0X : Format<56>; def MRM1X : Format<57>; def MRM2X : Format<58>;
  53. def MRM3X : Format<59>; def MRM4X : Format<60>; def MRM5X : Format<61>;
  54. def MRM6X : Format<62>; def MRM7X : Format<63>;
  55. def MRM_C0 : Format<64>; def MRM_C1 : Format<65>; def MRM_C2 : Format<66>;
  56. def MRM_C3 : Format<67>; def MRM_C4 : Format<68>; def MRM_C5 : Format<69>;
  57. def MRM_C6 : Format<70>; def MRM_C7 : Format<71>; def MRM_C8 : Format<72>;
  58. def MRM_C9 : Format<73>; def MRM_CA : Format<74>; def MRM_CB : Format<75>;
  59. def MRM_CC : Format<76>; def MRM_CD : Format<77>; def MRM_CE : Format<78>;
  60. def MRM_CF : Format<79>; def MRM_D0 : Format<80>; def MRM_D1 : Format<81>;
  61. def MRM_D2 : Format<82>; def MRM_D3 : Format<83>; def MRM_D4 : Format<84>;
  62. def MRM_D5 : Format<85>; def MRM_D6 : Format<86>; def MRM_D7 : Format<87>;
  63. def MRM_D8 : Format<88>; def MRM_D9 : Format<89>; def MRM_DA : Format<90>;
  64. def MRM_DB : Format<91>; def MRM_DC : Format<92>; def MRM_DD : Format<93>;
  65. def MRM_DE : Format<94>; def MRM_DF : Format<95>; def MRM_E0 : Format<96>;
  66. def MRM_E1 : Format<97>; def MRM_E2 : Format<98>; def MRM_E3 : Format<99>;
  67. def MRM_E4 : Format<100>; def MRM_E5 : Format<101>; def MRM_E6 : Format<102>;
  68. def MRM_E7 : Format<103>; def MRM_E8 : Format<104>; def MRM_E9 : Format<105>;
  69. def MRM_EA : Format<106>; def MRM_EB : Format<107>; def MRM_EC : Format<108>;
  70. def MRM_ED : Format<109>; def MRM_EE : Format<110>; def MRM_EF : Format<111>;
  71. def MRM_F0 : Format<112>; def MRM_F1 : Format<113>; def MRM_F2 : Format<114>;
  72. def MRM_F3 : Format<115>; def MRM_F4 : Format<116>; def MRM_F5 : Format<117>;
  73. def MRM_F6 : Format<118>; def MRM_F7 : Format<119>; def MRM_F8 : Format<120>;
  74. def MRM_F9 : Format<121>; def MRM_FA : Format<122>; def MRM_FB : Format<123>;
  75. def MRM_FC : Format<124>; def MRM_FD : Format<125>; def MRM_FE : Format<126>;
  76. def MRM_FF : Format<127>;
  77. // ImmType - This specifies the immediate type used by an instruction. This is
  78. // part of the ad-hoc solution used to emit machine instruction encodings by our
  79. // machine code emitter.
  80. class ImmType<bits<4> val> {
  81. bits<4> Value = val;
  82. }
  83. def NoImm : ImmType<0>;
  84. def Imm8 : ImmType<1>;
  85. def Imm8PCRel : ImmType<2>;
  86. def Imm8Reg : ImmType<3>; // Register encoded in [7:4].
  87. def Imm16 : ImmType<4>;
  88. def Imm16PCRel : ImmType<5>;
  89. def Imm32 : ImmType<6>;
  90. def Imm32PCRel : ImmType<7>;
  91. def Imm32S : ImmType<8>;
  92. def Imm64 : ImmType<9>;
  93. // FPFormat - This specifies what form this FP instruction has. This is used by
  94. // the Floating-Point stackifier pass.
  95. class FPFormat<bits<3> val> {
  96. bits<3> Value = val;
  97. }
  98. def NotFP : FPFormat<0>;
  99. def ZeroArgFP : FPFormat<1>;
  100. def OneArgFP : FPFormat<2>;
  101. def OneArgFPRW : FPFormat<3>;
  102. def TwoArgFP : FPFormat<4>;
  103. def CompareFP : FPFormat<5>;
  104. def CondMovFP : FPFormat<6>;
  105. def SpecialFP : FPFormat<7>;
  106. // Class specifying the SSE execution domain, used by the SSEDomainFix pass.
  107. // Keep in sync with tables in X86InstrInfo.cpp.
  108. class Domain<bits<2> val> {
  109. bits<2> Value = val;
  110. }
  111. def GenericDomain : Domain<0>;
  112. def SSEPackedSingle : Domain<1>;
  113. def SSEPackedDouble : Domain<2>;
  114. def SSEPackedInt : Domain<3>;
  115. // Class specifying the vector form of the decompressed
  116. // displacement of 8-bit.
  117. class CD8VForm<bits<3> val> {
  118. bits<3> Value = val;
  119. }
  120. def CD8VF : CD8VForm<0>; // v := VL
  121. def CD8VH : CD8VForm<1>; // v := VL/2
  122. def CD8VQ : CD8VForm<2>; // v := VL/4
  123. def CD8VO : CD8VForm<3>; // v := VL/8
  124. // The tuple (subvector) forms.
  125. def CD8VT1 : CD8VForm<4>; // v := 1
  126. def CD8VT2 : CD8VForm<5>; // v := 2
  127. def CD8VT4 : CD8VForm<6>; // v := 4
  128. def CD8VT8 : CD8VForm<7>; // v := 8
  129. // Class specifying the prefix used an opcode extension.
  130. class Prefix<bits<3> val> {
  131. bits<3> Value = val;
  132. }
  133. def NoPrfx : Prefix<0>;
  134. def PD : Prefix<1>;
  135. def XS : Prefix<2>;
  136. def XD : Prefix<3>;
  137. def PS : Prefix<4>; // Similar to NoPrfx, but disassembler uses this to know
  138. // that other instructions with this opcode use PD/XS/XD
  139. // and if any of those is not supported they shouldn't
  140. // decode to this instruction. e.g. ANDSS/ANDSD don't
  141. // exist, but the 0xf2/0xf3 encoding shouldn't
  142. // disable to ANDPS.
  143. // Class specifying the opcode map.
  144. class Map<bits<4> val> {
  145. bits<4> Value = val;
  146. }
  147. def OB : Map<0>;
  148. def TB : Map<1>;
  149. def T8 : Map<2>;
  150. def TA : Map<3>;
  151. def XOP8 : Map<4>;
  152. def XOP9 : Map<5>;
  153. def XOPA : Map<6>;
  154. def ThreeDNow : Map<7>;
  155. def T_MAP5 : Map<8>;
  156. def T_MAP6 : Map<9>;
  157. // Class specifying the encoding
  158. class Encoding<bits<2> val> {
  159. bits<2> Value = val;
  160. }
  161. def EncNormal : Encoding<0>;
  162. def EncVEX : Encoding<1>;
  163. def EncXOP : Encoding<2>;
  164. def EncEVEX : Encoding<3>;
  165. // Operand size for encodings that change based on mode.
  166. class OperandSize<bits<2> val> {
  167. bits<2> Value = val;
  168. }
  169. def OpSizeFixed : OperandSize<0>; // Never needs a 0x66 prefix.
  170. def OpSize16 : OperandSize<1>; // Needs 0x66 prefix in 32-bit mode.
  171. def OpSize32 : OperandSize<2>; // Needs 0x66 prefix in 16-bit mode.
  172. // Address size for encodings that change based on mode.
  173. class AddressSize<bits<2> val> {
  174. bits<2> Value = val;
  175. }
  176. def AdSizeX : AddressSize<0>; // Address size determined using addr operand.
  177. def AdSize16 : AddressSize<1>; // Encodes a 16-bit address.
  178. def AdSize32 : AddressSize<2>; // Encodes a 32-bit address.
  179. def AdSize64 : AddressSize<3>; // Encodes a 64-bit address.
  180. // Prefix byte classes which are used to indicate to the ad-hoc machine code
  181. // emitter that various prefix bytes are required.
  182. class OpSize16 { OperandSize OpSize = OpSize16; }
  183. class OpSize32 { OperandSize OpSize = OpSize32; }
  184. class AdSize16 { AddressSize AdSize = AdSize16; }
  185. class AdSize32 { AddressSize AdSize = AdSize32; }
  186. class AdSize64 { AddressSize AdSize = AdSize64; }
  187. class REX_W { bit hasREX_W = 1; }
  188. class LOCK { bit hasLockPrefix = 1; }
  189. class REP { bit hasREPPrefix = 1; }
  190. class TB { Map OpMap = TB; }
  191. class T8 { Map OpMap = T8; }
  192. class TA { Map OpMap = TA; }
  193. class XOP8 { Map OpMap = XOP8; Prefix OpPrefix = PS; }
  194. class XOP9 { Map OpMap = XOP9; Prefix OpPrefix = PS; }
  195. class XOPA { Map OpMap = XOPA; Prefix OpPrefix = PS; }
  196. class ThreeDNow { Map OpMap = ThreeDNow; }
  197. class T_MAP5 { Map OpMap = T_MAP5; }
  198. class T_MAP5PS : T_MAP5 { Prefix OpPrefix = PS; } // none
  199. class T_MAP5PD : T_MAP5 { Prefix OpPrefix = PD; } // 0x66
  200. class T_MAP5XS : T_MAP5 { Prefix OpPrefix = XS; } // 0xF3
  201. class T_MAP5XD : T_MAP5 { Prefix OpPrefix = XD; } // 0xF2
  202. class T_MAP6 { Map OpMap = T_MAP6; }
  203. class T_MAP6PS : T_MAP6 { Prefix OpPrefix = PS; }
  204. class T_MAP6PD : T_MAP6 { Prefix OpPrefix = PD; }
  205. class T_MAP6XS : T_MAP6 { Prefix OpPrefix = XS; }
  206. class T_MAP6XD : T_MAP6 { Prefix OpPrefix = XD; }
  207. class OBXS { Prefix OpPrefix = XS; }
  208. class PS : TB { Prefix OpPrefix = PS; }
  209. class PD : TB { Prefix OpPrefix = PD; }
  210. class XD : TB { Prefix OpPrefix = XD; }
  211. class XS : TB { Prefix OpPrefix = XS; }
  212. class T8PS : T8 { Prefix OpPrefix = PS; }
  213. class T8PD : T8 { Prefix OpPrefix = PD; }
  214. class T8XD : T8 { Prefix OpPrefix = XD; }
  215. class T8XS : T8 { Prefix OpPrefix = XS; }
  216. class TAPS : TA { Prefix OpPrefix = PS; }
  217. class TAPD : TA { Prefix OpPrefix = PD; }
  218. class TAXD : TA { Prefix OpPrefix = XD; }
  219. class TAXS : TA { Prefix OpPrefix = XS; }
  220. class VEX { Encoding OpEnc = EncVEX; }
  221. class VEX_W { bit HasVEX_W = 1; }
  222. class VEX_WIG { bit IgnoresVEX_W = 1; }
  223. // Special version of VEX_W that can be changed to VEX.W==0 for EVEX2VEX.
  224. class VEX_W1X { bit HasVEX_W = 1; bit EVEX_W1_VEX_W0 = 1; }
  225. class VEX_4V : VEX { bit hasVEX_4V = 1; }
  226. class VEX_L { bit hasVEX_L = 1; }
  227. class VEX_LIG { bit ignoresVEX_L = 1; }
  228. class EVEX { Encoding OpEnc = EncEVEX; }
  229. class EVEX_4V : EVEX { bit hasVEX_4V = 1; }
  230. class EVEX_K { bit hasEVEX_K = 1; }
  231. class EVEX_KZ : EVEX_K { bit hasEVEX_Z = 1; }
  232. class EVEX_B { bit hasEVEX_B = 1; }
  233. class EVEX_RC { bit hasEVEX_RC = 1; }
  234. class EVEX_V512 { bit hasEVEX_L2 = 1; bit hasVEX_L = 0; }
  235. class EVEX_V256 { bit hasEVEX_L2 = 0; bit hasVEX_L = 1; }
  236. class EVEX_V128 { bit hasEVEX_L2 = 0; bit hasVEX_L = 0; }
  237. class NOTRACK { bit hasNoTrackPrefix = 1; }
  238. class SIMD_EXC { list<Register> Uses = [MXCSR]; bit mayRaiseFPException = 1; }
  239. // Specify AVX512 8-bit compressed displacement encoding based on the vector
  240. // element size in bits (8, 16, 32, 64) and the CDisp8 form.
  241. class EVEX_CD8<int esize, CD8VForm form> {
  242. int CD8_EltSize = !srl(esize, 3);
  243. bits<3> CD8_Form = form.Value;
  244. }
  245. class XOP { Encoding OpEnc = EncXOP; }
  246. class XOP_4V : XOP { bit hasVEX_4V = 1; }
  247. // Specify the alternative register form instruction to replace the current
  248. // instruction in case it was picked during generation of memory folding tables
  249. class FoldGenData<string _RegisterForm> {
  250. string FoldGenRegForm = _RegisterForm;
  251. }
  252. // Provide a specific instruction to be used by the EVEX2VEX conversion.
  253. class EVEX2VEXOverride<string VEXInstrName> {
  254. string EVEX2VEXOverride = VEXInstrName;
  255. }
  256. // Mark the instruction as "illegal to memory fold/unfold"
  257. class NotMemoryFoldable { bit isMemoryFoldable = 0; }
  258. // Prevent EVEX->VEX conversion from considering this instruction.
  259. class NotEVEX2VEXConvertible { bit notEVEX2VEXConvertible = 1; }
  260. // Force the instruction to use VEX encoding.
  261. class ExplicitVEXPrefix { bit ExplicitVEXPrefix = 1; }
  262. class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
  263. string AsmStr, Domain d = GenericDomain>
  264. : Instruction {
  265. let Namespace = "X86";
  266. bits<8> Opcode = opcod;
  267. Format Form = f;
  268. bits<7> FormBits = Form.Value;
  269. ImmType ImmT = i;
  270. dag OutOperandList = outs;
  271. dag InOperandList = ins;
  272. string AsmString = AsmStr;
  273. // If this is a pseudo instruction, mark it isCodeGenOnly.
  274. let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
  275. let HasPositionOrder = 1;
  276. //
  277. // Attributes specific to X86 instructions...
  278. //
  279. bit ForceDisassemble = 0; // Force instruction to disassemble even though it's
  280. // isCodeGenonly. Needed to hide an ambiguous
  281. // AsmString from the parser, but still disassemble.
  282. OperandSize OpSize = OpSizeFixed; // Does this instruction's encoding change
  283. // based on operand size of the mode?
  284. bits<2> OpSizeBits = OpSize.Value;
  285. AddressSize AdSize = AdSizeX; // Does this instruction's encoding change
  286. // based on address size of the mode?
  287. bits<2> AdSizeBits = AdSize.Value;
  288. Prefix OpPrefix = NoPrfx; // Which prefix byte does this inst have?
  289. bits<3> OpPrefixBits = OpPrefix.Value;
  290. Map OpMap = OB; // Which opcode map does this inst have?
  291. bits<4> OpMapBits = OpMap.Value;
  292. bit hasREX_W = 0; // Does this inst require the REX.W prefix?
  293. FPFormat FPForm = NotFP; // What flavor of FP instruction is this?
  294. bit hasLockPrefix = 0; // Does this inst have a 0xF0 prefix?
  295. Domain ExeDomain = d;
  296. bit hasREPPrefix = 0; // Does this inst have a REP prefix?
  297. Encoding OpEnc = EncNormal; // Encoding used by this instruction
  298. bits<2> OpEncBits = OpEnc.Value;
  299. bit HasVEX_W = 0; // Does this inst set the VEX_W field?
  300. bit IgnoresVEX_W = 0; // Does this inst ignore VEX_W field?
  301. bit EVEX_W1_VEX_W0 = 0; // This EVEX inst with VEX.W==1 can become a VEX
  302. // instruction with VEX.W == 0.
  303. bit hasVEX_4V = 0; // Does this inst require the VEX.VVVV field?
  304. bit hasVEX_L = 0; // Does this inst use large (256-bit) registers?
  305. bit ignoresVEX_L = 0; // Does this instruction ignore the L-bit
  306. bit hasEVEX_K = 0; // Does this inst require masking?
  307. bit hasEVEX_Z = 0; // Does this inst set the EVEX_Z field?
  308. bit hasEVEX_L2 = 0; // Does this inst set the EVEX_L2 field?
  309. bit hasEVEX_B = 0; // Does this inst set the EVEX_B field?
  310. bits<3> CD8_Form = 0; // Compressed disp8 form - vector-width.
  311. // Declare it int rather than bits<4> so that all bits are defined when
  312. // assigning to bits<7>.
  313. int CD8_EltSize = 0; // Compressed disp8 form - element-size in bytes.
  314. bit hasEVEX_RC = 0; // Explicitly specified rounding control in FP instruction.
  315. bit hasNoTrackPrefix = 0; // Does this inst has 0x3E (NoTrack) prefix?
  316. // Vector size in bytes.
  317. bits<7> VectSize = !if(hasEVEX_L2, 64, !if(hasVEX_L, 32, 16));
  318. // The scaling factor for AVX512's compressed displacement is either
  319. // - the size of a power-of-two number of elements or
  320. // - the size of a single element for broadcasts or
  321. // - the total vector size divided by a power-of-two number.
  322. // Possible values are: 0 (non-AVX512 inst), 1, 2, 4, 8, 16, 32 and 64.
  323. bits<7> CD8_Scale = !if (!eq (OpEnc.Value, EncEVEX.Value),
  324. !if (CD8_Form{2},
  325. !shl(CD8_EltSize, CD8_Form{1-0}),
  326. !if (hasEVEX_B,
  327. CD8_EltSize,
  328. !srl(VectSize, CD8_Form{1-0}))), 0);
  329. // Used in the memory folding generation (TableGen backend) to point to an alternative
  330. // instruction to replace the current one in case it got picked during generation.
  331. string FoldGenRegForm = ?;
  332. // Used to prevent an explicit EVEX2VEX override for this instruction.
  333. string EVEX2VEXOverride = ?;
  334. bit isMemoryFoldable = 1; // Is it allowed to memory fold/unfold this instruction?
  335. bit notEVEX2VEXConvertible = 0; // Prevent EVEX->VEX conversion.
  336. bit ExplicitVEXPrefix = 0; // Force the instruction to use VEX encoding.
  337. // Force to check predicate before compress EVEX to VEX encoding.
  338. bit checkVEXPredicate = 0;
  339. // TSFlags layout should be kept in sync with X86BaseInfo.h.
  340. let TSFlags{6-0} = FormBits;
  341. let TSFlags{8-7} = OpSizeBits;
  342. let TSFlags{10-9} = AdSizeBits;
  343. // No need for 3rd bit, we don't need to distinguish NoPrfx from PS.
  344. let TSFlags{12-11} = OpPrefixBits{1-0};
  345. let TSFlags{16-13} = OpMapBits;
  346. let TSFlags{17} = hasREX_W;
  347. let TSFlags{21-18} = ImmT.Value;
  348. let TSFlags{24-22} = FPForm.Value;
  349. let TSFlags{25} = hasLockPrefix;
  350. let TSFlags{26} = hasREPPrefix;
  351. let TSFlags{28-27} = ExeDomain.Value;
  352. let TSFlags{30-29} = OpEncBits;
  353. let TSFlags{38-31} = Opcode;
  354. // Currently no need for second bit in TSFlags - W Ignore is equivalent to 0.
  355. let TSFlags{39} = HasVEX_W;
  356. let TSFlags{40} = hasVEX_4V;
  357. let TSFlags{41} = hasVEX_L;
  358. let TSFlags{42} = hasEVEX_K;
  359. let TSFlags{43} = hasEVEX_Z;
  360. let TSFlags{44} = hasEVEX_L2;
  361. let TSFlags{45} = hasEVEX_B;
  362. // If we run out of TSFlags bits, it's possible to encode this in 3 bits.
  363. let TSFlags{52-46} = CD8_Scale;
  364. let TSFlags{53} = hasEVEX_RC;
  365. let TSFlags{54} = hasNoTrackPrefix;
  366. let TSFlags{55} = ExplicitVEXPrefix;
  367. }
  368. class PseudoI<dag oops, dag iops, list<dag> pattern>
  369. : X86Inst<0, Pseudo, NoImm, oops, iops, ""> {
  370. let Pattern = pattern;
  371. }
  372. class I<bits<8> o, Format f, dag outs, dag ins, string asm,
  373. list<dag> pattern, Domain d = GenericDomain>
  374. : X86Inst<o, f, NoImm, outs, ins, asm, d> {
  375. let Pattern = pattern;
  376. let CodeSize = 3;
  377. }
  378. class Ii8<bits<8> o, Format f, dag outs, dag ins, string asm,
  379. list<dag> pattern, Domain d = GenericDomain>
  380. : X86Inst<o, f, Imm8, outs, ins, asm, d> {
  381. let Pattern = pattern;
  382. let CodeSize = 3;
  383. }
  384. class Ii8Reg<bits<8> o, Format f, dag outs, dag ins, string asm,
  385. list<dag> pattern, Domain d = GenericDomain>
  386. : X86Inst<o, f, Imm8Reg, outs, ins, asm, d> {
  387. let Pattern = pattern;
  388. let CodeSize = 3;
  389. }
  390. class Ii8PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
  391. list<dag> pattern>
  392. : X86Inst<o, f, Imm8PCRel, outs, ins, asm> {
  393. let Pattern = pattern;
  394. let CodeSize = 3;
  395. }
  396. class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm,
  397. list<dag> pattern>
  398. : X86Inst<o, f, Imm16, outs, ins, asm> {
  399. let Pattern = pattern;
  400. let CodeSize = 3;
  401. }
  402. class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm,
  403. list<dag> pattern>
  404. : X86Inst<o, f, Imm32, outs, ins, asm> {
  405. let Pattern = pattern;
  406. let CodeSize = 3;
  407. }
  408. class Ii32S<bits<8> o, Format f, dag outs, dag ins, string asm,
  409. list<dag> pattern>
  410. : X86Inst<o, f, Imm32S, outs, ins, asm> {
  411. let Pattern = pattern;
  412. let CodeSize = 3;
  413. }
  414. class Ii64<bits<8> o, Format f, dag outs, dag ins, string asm,
  415. list<dag> pattern>
  416. : X86Inst<o, f, Imm64, outs, ins, asm> {
  417. let Pattern = pattern;
  418. let CodeSize = 3;
  419. }
  420. class Ii16PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
  421. list<dag> pattern>
  422. : X86Inst<o, f, Imm16PCRel, outs, ins, asm> {
  423. let Pattern = pattern;
  424. let CodeSize = 3;
  425. }
  426. class Ii32PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
  427. list<dag> pattern>
  428. : X86Inst<o, f, Imm32PCRel, outs, ins, asm> {
  429. let Pattern = pattern;
  430. let CodeSize = 3;
  431. }
  432. // FPStack Instruction Templates:
  433. // FPI - Floating Point Instruction template.
  434. class FPI<bits<8> o, Format F, dag outs, dag ins, string asm>
  435. : I<o, F, outs, ins, asm, []> {
  436. let Defs = [FPSW];
  437. let Predicates = [HasX87];
  438. }
  439. // FpI_ - Floating Point Pseudo Instruction template.
  440. class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern>
  441. : PseudoI<outs, ins, pattern> {
  442. let FPForm = fp;
  443. let Defs = [FPSW];
  444. let Predicates = [HasX87];
  445. }
  446. // Templates for instructions that use a 16- or 32-bit segmented address as
  447. // their only operand: lcall (FAR CALL) and ljmp (FAR JMP)
  448. //
  449. // Iseg16 - 16-bit segment selector, 16-bit offset
  450. // Iseg32 - 16-bit segment selector, 32-bit offset
  451. class Iseg16 <bits<8> o, Format f, dag outs, dag ins, string asm,
  452. list<dag> pattern>
  453. : X86Inst<o, f, Imm16, outs, ins, asm> {
  454. let Pattern = pattern;
  455. let CodeSize = 3;
  456. }
  457. class Iseg32 <bits<8> o, Format f, dag outs, dag ins, string asm,
  458. list<dag> pattern>
  459. : X86Inst<o, f, Imm32, outs, ins, asm> {
  460. let Pattern = pattern;
  461. let CodeSize = 3;
  462. }
  463. // SI - SSE 1 & 2 scalar instructions
  464. class SI<bits<8> o, Format F, dag outs, dag ins, string asm,
  465. list<dag> pattern, Domain d = GenericDomain>
  466. : I<o, F, outs, ins, asm, pattern, d> {
  467. let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
  468. !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
  469. !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
  470. !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
  471. !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
  472. [UseSSE1])))));
  473. // AVX instructions have a 'v' prefix in the mnemonic
  474. let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
  475. !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
  476. asm));
  477. }
  478. // SI - SSE 1 & 2 scalar intrinsics - vex form available on AVX512
  479. class SI_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
  480. list<dag> pattern, Domain d = GenericDomain>
  481. : I<o, F, outs, ins, asm, pattern, d> {
  482. let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
  483. !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
  484. !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
  485. !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
  486. !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
  487. [UseSSE1])))));
  488. // AVX instructions have a 'v' prefix in the mnemonic
  489. let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
  490. !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
  491. asm));
  492. }
  493. // SIi8 - SSE 1 & 2 scalar instructions - vex form available on AVX512
  494. class SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  495. list<dag> pattern>
  496. : Ii8<o, F, outs, ins, asm, pattern> {
  497. let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
  498. !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
  499. !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
  500. [UseSSE2])));
  501. // AVX instructions have a 'v' prefix in the mnemonic
  502. let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
  503. !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
  504. asm));
  505. }
  506. // PI - SSE 1 & 2 packed instructions
  507. class PI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
  508. Domain d>
  509. : I<o, F, outs, ins, asm, pattern, d> {
  510. let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
  511. !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
  512. !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
  513. [UseSSE1])));
  514. // AVX instructions have a 'v' prefix in the mnemonic
  515. let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
  516. !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
  517. asm));
  518. }
  519. // MMXPI - SSE 1 & 2 packed instructions with MMX operands
  520. class MMXPI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
  521. Domain d>
  522. : I<o, F, outs, ins, asm, pattern, d> {
  523. let Predicates = !if(!eq(OpPrefix.Value, PD.Value), [HasMMX, HasSSE2],
  524. [HasMMX, HasSSE1]);
  525. }
  526. // PIi8 - SSE 1 & 2 packed instructions with immediate
  527. class PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  528. list<dag> pattern, Domain d>
  529. : Ii8<o, F, outs, ins, asm, pattern, d> {
  530. let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
  531. !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
  532. !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
  533. [UseSSE1])));
  534. // AVX instructions have a 'v' prefix in the mnemonic
  535. let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
  536. !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
  537. asm));
  538. }
  539. // SSE1 Instruction Templates:
  540. //
  541. // SSI - SSE1 instructions with XS prefix.
  542. // PSI - SSE1 instructions with PS prefix.
  543. // PSIi8 - SSE1 instructions with ImmT == Imm8 and PS prefix.
  544. // VSSI - SSE1 instructions with XS prefix in AVX form.
  545. // VPSI - SSE1 instructions with PS prefix in AVX form, packed single.
  546. class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
  547. list<dag> pattern>
  548. : I<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE1]>;
  549. class SSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  550. list<dag> pattern>
  551. : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE1]>;
  552. class PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
  553. list<dag> pattern>
  554. : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, PS,
  555. Requires<[UseSSE1]>;
  556. class PSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  557. list<dag> pattern>
  558. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedSingle>, PS,
  559. Requires<[UseSSE1]>;
  560. class VSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
  561. list<dag> pattern>
  562. : I<o, F, outs, ins, !strconcat("v", asm), pattern>, XS,
  563. Requires<[HasAVX]>;
  564. class VPSI<bits<8> o, Format F, dag outs, dag ins, string asm,
  565. list<dag> pattern>
  566. : I<o, F, outs, ins, !strconcat("v", asm), pattern, SSEPackedSingle>, PS,
  567. Requires<[HasAVX]>;
  568. // SSE2 Instruction Templates:
  569. //
  570. // SDI - SSE2 instructions with XD prefix.
  571. // SDIi8 - SSE2 instructions with ImmT == Imm8 and XD prefix.
  572. // S2SI - SSE2 instructions with XS prefix.
  573. // SSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix.
  574. // PDI - SSE2 instructions with PD prefix, packed double domain.
  575. // PDIi8 - SSE2 instructions with ImmT == Imm8 and PD prefix.
  576. // VSDI - SSE2 scalar instructions with XD prefix in AVX form.
  577. // VPDI - SSE2 vector instructions with PD prefix in AVX form,
  578. // packed double domain.
  579. // VS2I - SSE2 scalar instructions with PD prefix in AVX form.
  580. // S2I - SSE2 scalar instructions with PD prefix.
  581. // MMXSDIi8 - SSE2 instructions with ImmT == Imm8 and XD prefix as well as
  582. // MMX operands.
  583. // MMXSSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix as well as
  584. // MMX operands.
  585. class SDI<bits<8> o, Format F, dag outs, dag ins, string asm,
  586. list<dag> pattern>
  587. : I<o, F, outs, ins, asm, pattern>, XD, Requires<[UseSSE2]>;
  588. class SDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  589. list<dag> pattern>
  590. : Ii8<o, F, outs, ins, asm, pattern>, XD, Requires<[UseSSE2]>;
  591. class S2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
  592. list<dag> pattern>
  593. : I<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
  594. class S2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  595. list<dag> pattern>
  596. : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
  597. class PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
  598. list<dag> pattern>
  599. : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
  600. Requires<[UseSSE2]>;
  601. class PDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  602. list<dag> pattern>
  603. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
  604. Requires<[UseSSE2]>;
  605. class VSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
  606. list<dag> pattern>
  607. : I<o, F, outs, ins, !strconcat("v", asm), pattern>, XD,
  608. Requires<[UseAVX]>;
  609. class VS2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
  610. list<dag> pattern>
  611. : I<o, F, outs, ins, !strconcat("v", asm), pattern>, XS,
  612. Requires<[HasAVX]>;
  613. class VPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
  614. list<dag> pattern>
  615. : I<o, F, outs, ins, !strconcat("v", asm), pattern, SSEPackedDouble>,
  616. PD, Requires<[HasAVX]>;
  617. class VS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
  618. list<dag> pattern>
  619. : I<o, F, outs, ins, !strconcat("v", asm), pattern>, PD,
  620. Requires<[UseAVX]>;
  621. class S2I<bits<8> o, Format F, dag outs, dag ins, string asm,
  622. list<dag> pattern>
  623. : I<o, F, outs, ins, asm, pattern>, PD, Requires<[UseSSE2]>;
  624. class MMXSDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  625. list<dag> pattern>
  626. : Ii8<o, F, outs, ins, asm, pattern>, XD, Requires<[HasMMX, HasSSE2]>;
  627. class MMXS2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  628. list<dag> pattern>
  629. : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasMMX, HasSSE2]>;
  630. // SSE3 Instruction Templates:
  631. //
  632. // S3I - SSE3 instructions with PD prefixes.
  633. // S3SI - SSE3 instructions with XS prefix.
  634. // S3DI - SSE3 instructions with XD prefix.
  635. class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,
  636. list<dag> pattern>
  637. : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, XS,
  638. Requires<[UseSSE3]>;
  639. class S3DI<bits<8> o, Format F, dag outs, dag ins, string asm,
  640. list<dag> pattern>
  641. : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, XD,
  642. Requires<[UseSSE3]>;
  643. class S3I<bits<8> o, Format F, dag outs, dag ins, string asm,
  644. list<dag> pattern>
  645. : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
  646. Requires<[UseSSE3]>;
  647. // SSSE3 Instruction Templates:
  648. //
  649. // SS38I - SSSE3 instructions with T8 prefix.
  650. // SS3AI - SSSE3 instructions with TA prefix.
  651. // MMXSS38I - SSSE3 instructions with T8 prefix and MMX operands.
  652. // MMXSS3AI - SSSE3 instructions with TA prefix and MMX operands.
  653. //
  654. // Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
  655. // uses the MMX registers. The 64-bit versions are grouped with the MMX
  656. // classes. They need to be enabled even if AVX is enabled.
  657. class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
  658. list<dag> pattern>
  659. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
  660. Requires<[UseSSSE3]>;
  661. class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
  662. list<dag> pattern>
  663. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  664. Requires<[UseSSSE3]>;
  665. class MMXSS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
  666. list<dag> pattern>
  667. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PS,
  668. Requires<[HasMMX, HasSSSE3]>;
  669. class MMXSS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
  670. list<dag> pattern>
  671. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPS,
  672. Requires<[HasMMX, HasSSSE3]>;
  673. // SSE4.1 Instruction Templates:
  674. //
  675. // SS48I - SSE 4.1 instructions with T8 prefix.
  676. // SS41AIi8 - SSE 4.1 instructions with TA prefix and ImmT == Imm8.
  677. //
  678. class SS48I<bits<8> o, Format F, dag outs, dag ins, string asm,
  679. list<dag> pattern>
  680. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
  681. Requires<[UseSSE41]>;
  682. class SS4AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  683. list<dag> pattern>
  684. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  685. Requires<[UseSSE41]>;
  686. // SSE4.2 Instruction Templates:
  687. //
  688. // SS428I - SSE 4.2 instructions with T8 prefix.
  689. class SS428I<bits<8> o, Format F, dag outs, dag ins, string asm,
  690. list<dag> pattern>
  691. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
  692. Requires<[UseSSE42]>;
  693. // SS42AI = SSE 4.2 instructions with TA prefix
  694. class SS42AI<bits<8> o, Format F, dag outs, dag ins, string asm,
  695. list<dag> pattern>
  696. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  697. Requires<[UseSSE42]>;
  698. // CRC32I - SSE 4.2 CRC32 instructions.
  699. // NOTE: 'HasCRC32' is used as CRC32 instructions are GPR only and not directly
  700. // controlled by the SSE42 flag.
  701. class CRC32I<bits<8> o, Format F, dag outs, dag ins, string asm,
  702. list<dag> pattern>
  703. : I<o, F, outs, ins, asm, pattern>, T8XD, Requires<[HasCRC32]>;
  704. // AVX Instruction Templates:
  705. // Instructions introduced in AVX (no SSE equivalent forms)
  706. //
  707. // AVX8I - AVX instructions with T8PD prefix.
  708. // AVXAIi8 - AVX instructions with TAPD prefix and ImmT = Imm8.
  709. class AVX8I<bits<8> o, Format F, dag outs, dag ins, string asm,
  710. list<dag> pattern>
  711. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
  712. Requires<[HasAVX]>;
  713. class AVXAIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  714. list<dag> pattern>
  715. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  716. Requires<[HasAVX]>;
  717. // AVX2 Instruction Templates:
  718. // Instructions introduced in AVX2 (no SSE equivalent forms)
  719. //
  720. // AVX28I - AVX2 instructions with T8PD prefix.
  721. // AVX2AIi8 - AVX2 instructions with TAPD prefix and ImmT = Imm8.
  722. class AVX28I<bits<8> o, Format F, dag outs, dag ins, string asm,
  723. list<dag> pattern>
  724. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
  725. Requires<[HasAVX2]>;
  726. class AVX2AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  727. list<dag> pattern>
  728. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  729. Requires<[HasAVX2]>;
  730. // AVX-512 Instruction Templates:
  731. // Instructions introduced in AVX-512 (no SSE equivalent forms)
  732. //
  733. // AVX5128I - AVX-512 instructions with T8PD prefix.
  734. // AVX512AIi8 - AVX-512 instructions with TAPD prefix and ImmT = Imm8.
  735. // AVX512PDI - AVX-512 instructions with PD, double packed.
  736. // AVX512PSI - AVX-512 instructions with PS, single packed.
  737. // AVX512XS8I - AVX-512 instructions with T8 and XS prefixes.
  738. // AVX512XSI - AVX-512 instructions with XS prefix, generic domain.
  739. // AVX512BI - AVX-512 instructions with PD, int packed domain.
  740. // AVX512SI - AVX-512 scalar instructions with PD prefix.
  741. class AVX5128I<bits<8> o, Format F, dag outs, dag ins, string asm,
  742. list<dag> pattern>
  743. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
  744. Requires<[HasAVX512]>;
  745. class AVX5128IBase : T8PD {
  746. Domain ExeDomain = SSEPackedInt;
  747. }
  748. class AVX512XS8I<bits<8> o, Format F, dag outs, dag ins, string asm,
  749. list<dag> pattern>
  750. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8XS,
  751. Requires<[HasAVX512]>;
  752. class AVX512XSI<bits<8> o, Format F, dag outs, dag ins, string asm,
  753. list<dag> pattern>
  754. : I<o, F, outs, ins, asm, pattern>, XS,
  755. Requires<[HasAVX512]>;
  756. class AVX512XDI<bits<8> o, Format F, dag outs, dag ins, string asm,
  757. list<dag> pattern>
  758. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, XD,
  759. Requires<[HasAVX512]>;
  760. class AVX512BI<bits<8> o, Format F, dag outs, dag ins, string asm,
  761. list<dag> pattern>
  762. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, PD,
  763. Requires<[HasAVX512]>;
  764. class AVX512BIBase : PD {
  765. Domain ExeDomain = SSEPackedInt;
  766. }
  767. class AVX512BIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  768. list<dag> pattern>
  769. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, PD,
  770. Requires<[HasAVX512]>;
  771. class AVX512BIi8Base : PD {
  772. Domain ExeDomain = SSEPackedInt;
  773. ImmType ImmT = Imm8;
  774. }
  775. class AVX512XSIi8Base : XS {
  776. Domain ExeDomain = SSEPackedInt;
  777. ImmType ImmT = Imm8;
  778. }
  779. class AVX512XDIi8Base : XD {
  780. Domain ExeDomain = SSEPackedInt;
  781. ImmType ImmT = Imm8;
  782. }
  783. class AVX512PSIi8Base : PS {
  784. Domain ExeDomain = SSEPackedSingle;
  785. ImmType ImmT = Imm8;
  786. }
  787. class AVX512PDIi8Base : PD {
  788. Domain ExeDomain = SSEPackedDouble;
  789. ImmType ImmT = Imm8;
  790. }
  791. class AVX512AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  792. list<dag> pattern>
  793. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  794. Requires<[HasAVX512]>;
  795. class AVX512AIi8Base : TAPD {
  796. ImmType ImmT = Imm8;
  797. }
  798. class AVX512Ii8<bits<8> o, Format F, dag outs, dag ins, string asm,
  799. list<dag> pattern>
  800. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>,
  801. Requires<[HasAVX512]>;
  802. class AVX512PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
  803. list<dag> pattern>
  804. : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
  805. Requires<[HasAVX512]>;
  806. class AVX512PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
  807. list<dag> pattern>
  808. : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, PS,
  809. Requires<[HasAVX512]>;
  810. class AVX512PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  811. list<dag> pattern, Domain d>
  812. : Ii8<o, F, outs, ins, asm, pattern, d>, Requires<[HasAVX512]>;
  813. class AVX512PI<bits<8> o, Format F, dag outs, dag ins, string asm,
  814. list<dag> pattern, Domain d>
  815. : I<o, F, outs, ins, asm, pattern, d>, Requires<[HasAVX512]>;
  816. class AVX512FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
  817. list<dag>pattern>
  818. : I<o, F, outs, ins, asm, pattern>, T8PD,
  819. EVEX_4V, Requires<[HasAVX512]>;
  820. class AVX512<bits<8> o, Format F, dag outs, dag ins, string asm,
  821. list<dag>pattern>
  822. : I<o, F, outs, ins, asm, pattern>, Requires<[HasAVX512]>;
  823. // AES Instruction Templates:
  824. //
  825. // AES8I
  826. // These use the same encoding as the SSE4.2 T8 and TA encodings.
  827. class AES8I<bits<8> o, Format F, dag outs, dag ins, string asm,
  828. list<dag>pattern>
  829. : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
  830. Requires<[NoAVX, HasAES]>;
  831. class AESAI<bits<8> o, Format F, dag outs, dag ins, string asm,
  832. list<dag> pattern>
  833. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  834. Requires<[NoAVX, HasAES]>;
  835. // PCLMUL Instruction Templates
  836. class PCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  837. list<dag>pattern>
  838. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD;
  839. // FMA3 Instruction Templates
  840. class FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
  841. list<dag>pattern>
  842. : I<o, F, outs, ins, asm, pattern>, T8PD,
  843. VEX_4V, FMASC, Requires<[HasFMA, NoFMA4, NoVLX]>;
  844. class FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
  845. list<dag>pattern>
  846. : I<o, F, outs, ins, asm, pattern>, T8PD,
  847. VEX_4V, FMASC, Requires<[HasFMA, NoFMA4, NoAVX512]>;
  848. class FMA3S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
  849. list<dag>pattern>
  850. : I<o, F, outs, ins, asm, pattern>, T8PD,
  851. VEX_4V, FMASC, Requires<[HasFMA, NoAVX512]>;
  852. // FMA4 Instruction Templates
  853. class FMA4<bits<8> o, Format F, dag outs, dag ins, string asm,
  854. list<dag>pattern>
  855. : Ii8Reg<o, F, outs, ins, asm, pattern>, TAPD,
  856. VEX_4V, FMASC, Requires<[HasFMA4, NoVLX]>;
  857. class FMA4S<bits<8> o, Format F, dag outs, dag ins, string asm,
  858. list<dag>pattern>
  859. : Ii8Reg<o, F, outs, ins, asm, pattern>, TAPD,
  860. VEX_4V, FMASC, Requires<[HasFMA4, NoAVX512]>;
  861. class FMA4S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
  862. list<dag>pattern>
  863. : Ii8Reg<o, F, outs, ins, asm, pattern>, TAPD,
  864. VEX_4V, FMASC, Requires<[HasFMA4]>;
  865. // XOP 2, 3 and 4 Operand Instruction Template
  866. class IXOP<bits<8> o, Format F, dag outs, dag ins, string asm,
  867. list<dag> pattern>
  868. : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
  869. XOP9, Requires<[HasXOP]>;
  870. // XOP 2 and 3 Operand Instruction Templates with imm byte
  871. class IXOPi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  872. list<dag> pattern>
  873. : Ii8<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
  874. XOP8, Requires<[HasXOP]>;
  875. // XOP 4 Operand Instruction Templates with imm byte
  876. class IXOPi8Reg<bits<8> o, Format F, dag outs, dag ins, string asm,
  877. list<dag> pattern>
  878. : Ii8Reg<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
  879. XOP8, Requires<[HasXOP]>;
  880. // XOP 5 operand instruction (VEX encoding!)
  881. class IXOP5<bits<8> o, Format F, dag outs, dag ins, string asm,
  882. list<dag>pattern>
  883. : Ii8Reg<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
  884. VEX_4V, Requires<[HasXOP]>;
  885. // X86-64 Instruction templates...
  886. //
  887. class RI<bits<8> o, Format F, dag outs, dag ins, string asm,
  888. list<dag> pattern>
  889. : I<o, F, outs, ins, asm, pattern>, REX_W;
  890. class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
  891. list<dag> pattern>
  892. : Ii8<o, F, outs, ins, asm, pattern>, REX_W;
  893. class RIi16 <bits<8> o, Format F, dag outs, dag ins, string asm,
  894. list<dag> pattern>
  895. : Ii16<o, F, outs, ins, asm, pattern>, REX_W;
  896. class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
  897. list<dag> pattern>
  898. : Ii32<o, F, outs, ins, asm, pattern>, REX_W;
  899. class RIi32S <bits<8> o, Format F, dag outs, dag ins, string asm,
  900. list<dag> pattern>
  901. : Ii32S<o, F, outs, ins, asm, pattern>, REX_W;
  902. class RIi64<bits<8> o, Format F, dag outs, dag ins, string asm,
  903. list<dag> pattern>
  904. : Ii64<o, F, outs, ins, asm, pattern>, REX_W;
  905. class RS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
  906. list<dag> pattern>
  907. : S2I<o, F, outs, ins, asm, pattern>, REX_W;
  908. class VRS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
  909. list<dag> pattern>
  910. : VS2I<o, F, outs, ins, asm, pattern>, VEX_W;
  911. // MMX Instruction templates
  912. //
  913. // MMXI - MMX instructions with TB prefix.
  914. // MMXI32 - MMX instructions with TB prefix valid only in 32 bit mode.
  915. // MMXI64 - MMX instructions with TB prefix valid only in 64 bit mode.
  916. // MMX2I - MMX / SSE2 instructions with PD prefix.
  917. // MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
  918. // MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
  919. // MMXID - MMX instructions with XD prefix.
  920. // MMXIS - MMX instructions with XS prefix.
  921. class MMXI<bits<8> o, Format F, dag outs, dag ins, string asm,
  922. list<dag> pattern>
  923. : I<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX]>;
  924. class MMXI32<bits<8> o, Format F, dag outs, dag ins, string asm,
  925. list<dag> pattern>
  926. : I<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX,Not64BitMode]>;
  927. class MMXI64<bits<8> o, Format F, dag outs, dag ins, string asm,
  928. list<dag> pattern>
  929. : I<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX,In64BitMode]>;
  930. class MMXRI<bits<8> o, Format F, dag outs, dag ins, string asm,
  931. list<dag> pattern>
  932. : I<o, F, outs, ins, asm, pattern>, PS, REX_W,
  933. Requires<[HasMMX,In64BitMode]>;
  934. class MMX2I<bits<8> o, Format F, dag outs, dag ins, string asm,
  935. list<dag> pattern>
  936. : I<o, F, outs, ins, asm, pattern>, PD, Requires<[HasMMX]>;
  937. class MMXIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
  938. list<dag> pattern>
  939. : Ii8<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX]>;
  940. class MMXID<bits<8> o, Format F, dag outs, dag ins, string asm,
  941. list<dag> pattern>
  942. : Ii8<o, F, outs, ins, asm, pattern>, XD, Requires<[HasMMX]>;
  943. class MMXIS<bits<8> o, Format F, dag outs, dag ins, string asm,
  944. list<dag> pattern>
  945. : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasMMX]>;