X86InstrFormats.td 42 KB

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