X86InstrControl.td 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. //===-- X86InstrControl.td - Control Flow Instructions -----*- 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. // This file describes the X86 jump, return, call, and related instructions.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. //===----------------------------------------------------------------------===//
  13. // Control Flow Instructions.
  14. //
  15. // Return instructions.
  16. //
  17. // The X86retflag return instructions are variadic because we may add ST0 and
  18. // ST1 arguments when returning values on the x87 stack.
  19. let isTerminator = 1, isReturn = 1, isBarrier = 1,
  20. hasCtrlDep = 1, FPForm = SpecialFP, SchedRW = [WriteJumpLd] in {
  21. def RET32 : I <0xC3, RawFrm, (outs), (ins variable_ops),
  22. "ret{l}", []>, OpSize32, Requires<[Not64BitMode]>;
  23. def RET64 : I <0xC3, RawFrm, (outs), (ins variable_ops),
  24. "ret{q}", []>, OpSize32, Requires<[In64BitMode]>;
  25. def RET16 : I <0xC3, RawFrm, (outs), (ins),
  26. "ret{w}", []>, OpSize16;
  27. def RETI32 : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
  28. "ret{l}\t$amt", []>, OpSize32, Requires<[Not64BitMode]>;
  29. def RETI64 : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
  30. "ret{q}\t$amt", []>, OpSize32, Requires<[In64BitMode]>;
  31. def RETI16 : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt),
  32. "ret{w}\t$amt", []>, OpSize16;
  33. def LRET32 : I <0xCB, RawFrm, (outs), (ins),
  34. "{l}ret{l|f}", []>, OpSize32;
  35. def LRET64 : RI <0xCB, RawFrm, (outs), (ins),
  36. "{l}ret{|f}q", []>, Requires<[In64BitMode]>;
  37. def LRET16 : I <0xCB, RawFrm, (outs), (ins),
  38. "{l}ret{w|f}", []>, OpSize16;
  39. def LRETI32 : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
  40. "{l}ret{l|f}\t$amt", []>, OpSize32;
  41. def LRETI64 : RIi16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
  42. "{l}ret{|f}q\t$amt", []>, Requires<[In64BitMode]>;
  43. def LRETI16 : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
  44. "{l}ret{w|f}\t$amt", []>, OpSize16;
  45. // The machine return from interrupt instruction, but sometimes we need to
  46. // perform a post-epilogue stack adjustment. Codegen emits the pseudo form
  47. // which expands to include an SP adjustment if necessary.
  48. def IRET16 : I <0xcf, RawFrm, (outs), (ins), "iret{w}", []>,
  49. OpSize16;
  50. def IRET32 : I <0xcf, RawFrm, (outs), (ins), "iret{l|d}", []>, OpSize32;
  51. def IRET64 : RI <0xcf, RawFrm, (outs), (ins), "iretq", []>, Requires<[In64BitMode]>;
  52. let isCodeGenOnly = 1 in
  53. def IRET : PseudoI<(outs), (ins i32imm:$adj), [(X86iret timm:$adj)]>;
  54. def RET : PseudoI<(outs), (ins i32imm:$adj, variable_ops), [(X86retflag timm:$adj)]>;
  55. }
  56. // Unconditional branches.
  57. let isBarrier = 1, isBranch = 1, isTerminator = 1, SchedRW = [WriteJump] in {
  58. def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
  59. "jmp\t$dst", [(br bb:$dst)]>;
  60. let hasSideEffects = 0, isCodeGenOnly = 1, ForceDisassemble = 1 in {
  61. def JMP_2 : Ii16PCRel<0xE9, RawFrm, (outs), (ins brtarget16:$dst),
  62. "jmp\t$dst", []>, OpSize16;
  63. def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget32:$dst),
  64. "jmp\t$dst", []>, OpSize32;
  65. }
  66. }
  67. // Conditional Branches.
  68. let isBranch = 1, isTerminator = 1, Uses = [EFLAGS], SchedRW = [WriteJump],
  69. isCodeGenOnly = 1, ForceDisassemble = 1 in {
  70. def JCC_1 : Ii8PCRel <0x70, AddCCFrm, (outs),
  71. (ins brtarget8:$dst, ccode:$cond),
  72. "j${cond}\t$dst",
  73. [(X86brcond bb:$dst, timm:$cond, EFLAGS)]>;
  74. let hasSideEffects = 0 in {
  75. def JCC_2 : Ii16PCRel<0x80, AddCCFrm, (outs),
  76. (ins brtarget16:$dst, ccode:$cond),
  77. "j${cond}\t$dst",
  78. []>, OpSize16, TB;
  79. def JCC_4 : Ii32PCRel<0x80, AddCCFrm, (outs),
  80. (ins brtarget32:$dst, ccode:$cond),
  81. "j${cond}\t$dst",
  82. []>, TB, OpSize32;
  83. }
  84. }
  85. def : InstAlias<"jo\t$dst", (JCC_1 brtarget8:$dst, 0), 0>;
  86. def : InstAlias<"jno\t$dst", (JCC_1 brtarget8:$dst, 1), 0>;
  87. def : InstAlias<"jb\t$dst", (JCC_1 brtarget8:$dst, 2), 0>;
  88. def : InstAlias<"jae\t$dst", (JCC_1 brtarget8:$dst, 3), 0>;
  89. def : InstAlias<"je\t$dst", (JCC_1 brtarget8:$dst, 4), 0>;
  90. def : InstAlias<"jne\t$dst", (JCC_1 brtarget8:$dst, 5), 0>;
  91. def : InstAlias<"jbe\t$dst", (JCC_1 brtarget8:$dst, 6), 0>;
  92. def : InstAlias<"ja\t$dst", (JCC_1 brtarget8:$dst, 7), 0>;
  93. def : InstAlias<"js\t$dst", (JCC_1 brtarget8:$dst, 8), 0>;
  94. def : InstAlias<"jns\t$dst", (JCC_1 brtarget8:$dst, 9), 0>;
  95. def : InstAlias<"jp\t$dst", (JCC_1 brtarget8:$dst, 10), 0>;
  96. def : InstAlias<"jnp\t$dst", (JCC_1 brtarget8:$dst, 11), 0>;
  97. def : InstAlias<"jl\t$dst", (JCC_1 brtarget8:$dst, 12), 0>;
  98. def : InstAlias<"jge\t$dst", (JCC_1 brtarget8:$dst, 13), 0>;
  99. def : InstAlias<"jle\t$dst", (JCC_1 brtarget8:$dst, 14), 0>;
  100. def : InstAlias<"jg\t$dst", (JCC_1 brtarget8:$dst, 15), 0>;
  101. // jcx/jecx/jrcx instructions.
  102. let isBranch = 1, isTerminator = 1, hasSideEffects = 0, SchedRW = [WriteJump] in {
  103. // These are the 32-bit versions of this instruction for the asmparser. In
  104. // 32-bit mode, the address size prefix is jcxz and the unprefixed version is
  105. // jecxz.
  106. let Uses = [CX] in
  107. def JCXZ : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
  108. "jcxz\t$dst", []>, AdSize16, Requires<[Not64BitMode]>;
  109. let Uses = [ECX] in
  110. def JECXZ : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
  111. "jecxz\t$dst", []>, AdSize32;
  112. let Uses = [RCX] in
  113. def JRCXZ : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
  114. "jrcxz\t$dst", []>, AdSize64, Requires<[In64BitMode]>;
  115. }
  116. // Indirect branches
  117. let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
  118. def JMP16r : I<0xFF, MRM4r, (outs), (ins GR16:$dst), "jmp{w}\t{*}$dst",
  119. [(brind GR16:$dst)]>, Requires<[Not64BitMode]>,
  120. OpSize16, Sched<[WriteJump]>;
  121. def JMP16m : I<0xFF, MRM4m, (outs), (ins i16mem:$dst), "jmp{w}\t{*}$dst",
  122. [(brind (loadi16 addr:$dst))]>, Requires<[Not64BitMode]>,
  123. OpSize16, Sched<[WriteJumpLd]>;
  124. def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
  125. [(brind GR32:$dst)]>, Requires<[Not64BitMode]>,
  126. OpSize32, Sched<[WriteJump]>;
  127. def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
  128. [(brind (loadi32 addr:$dst))]>, Requires<[Not64BitMode]>,
  129. OpSize32, Sched<[WriteJumpLd]>;
  130. def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst",
  131. [(brind GR64:$dst)]>, Requires<[In64BitMode]>,
  132. Sched<[WriteJump]>;
  133. def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst",
  134. [(brind (loadi64 addr:$dst))]>, Requires<[In64BitMode]>,
  135. Sched<[WriteJumpLd]>;
  136. // Win64 wants indirect jumps leaving the function to have a REX_W prefix.
  137. // These are switched from TAILJMPr/m64_REX in MCInstLower.
  138. let isCodeGenOnly = 1, hasREX_WPrefix = 1 in {
  139. def JMP64r_REX : I<0xFF, MRM4r, (outs), (ins GR64:$dst),
  140. "rex64 jmp{q}\t{*}$dst", []>, Sched<[WriteJump]>;
  141. let mayLoad = 1 in
  142. def JMP64m_REX : I<0xFF, MRM4m, (outs), (ins i64mem:$dst),
  143. "rex64 jmp{q}\t{*}$dst", []>, Sched<[WriteJumpLd]>;
  144. }
  145. // Non-tracking jumps for IBT, use with caution.
  146. let isCodeGenOnly = 1 in {
  147. def JMP16r_NT : I<0xFF, MRM4r, (outs), (ins GR16 : $dst), "jmp{w}\t{*}$dst",
  148. [(X86NoTrackBrind GR16 : $dst)]>, Requires<[Not64BitMode]>,
  149. OpSize16, Sched<[WriteJump]>, NOTRACK;
  150. def JMP16m_NT : I<0xFF, MRM4m, (outs), (ins i16mem : $dst), "jmp{w}\t{*}$dst",
  151. [(X86NoTrackBrind (loadi16 addr : $dst))]>,
  152. Requires<[Not64BitMode]>, OpSize16, Sched<[WriteJumpLd]>,
  153. NOTRACK;
  154. def JMP32r_NT : I<0xFF, MRM4r, (outs), (ins GR32 : $dst), "jmp{l}\t{*}$dst",
  155. [(X86NoTrackBrind GR32 : $dst)]>, Requires<[Not64BitMode]>,
  156. OpSize32, Sched<[WriteJump]>, NOTRACK;
  157. def JMP32m_NT : I<0xFF, MRM4m, (outs), (ins i32mem : $dst), "jmp{l}\t{*}$dst",
  158. [(X86NoTrackBrind (loadi32 addr : $dst))]>,
  159. Requires<[Not64BitMode]>, OpSize32, Sched<[WriteJumpLd]>,
  160. NOTRACK;
  161. def JMP64r_NT : I<0xFF, MRM4r, (outs), (ins GR64 : $dst), "jmp{q}\t{*}$dst",
  162. [(X86NoTrackBrind GR64 : $dst)]>, Requires<[In64BitMode]>,
  163. Sched<[WriteJump]>, NOTRACK;
  164. def JMP64m_NT : I<0xFF, MRM4m, (outs), (ins i64mem : $dst), "jmp{q}\t{*}$dst",
  165. [(X86NoTrackBrind(loadi64 addr : $dst))]>,
  166. Requires<[In64BitMode]>, Sched<[WriteJumpLd]>, NOTRACK;
  167. }
  168. let Predicates = [Not64BitMode], AsmVariantName = "att" in {
  169. def FARJMP16i : Iseg16<0xEA, RawFrmImm16, (outs),
  170. (ins i16imm:$off, i16imm:$seg),
  171. "ljmp{w}\t$seg, $off", []>,
  172. OpSize16, Sched<[WriteJump]>;
  173. def FARJMP32i : Iseg32<0xEA, RawFrmImm16, (outs),
  174. (ins i32imm:$off, i16imm:$seg),
  175. "ljmp{l}\t$seg, $off", []>,
  176. OpSize32, Sched<[WriteJump]>;
  177. }
  178. let mayLoad = 1 in {
  179. def FARJMP64m : RI<0xFF, MRM5m, (outs), (ins opaquemem:$dst),
  180. "ljmp{q}\t{*}$dst", []>, Sched<[WriteJump]>, Requires<[In64BitMode]>;
  181. let AsmVariantName = "att" in
  182. def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaquemem:$dst),
  183. "ljmp{w}\t{*}$dst", []>, OpSize16, Sched<[WriteJumpLd]>;
  184. def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaquemem:$dst),
  185. "{l}jmp{l}\t{*}$dst", []>, OpSize32, Sched<[WriteJumpLd]>;
  186. }
  187. }
  188. // Loop instructions
  189. let isBranch = 1, isTerminator = 1, SchedRW = [WriteJump] in {
  190. def LOOP : Ii8PCRel<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
  191. def LOOPE : Ii8PCRel<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
  192. def LOOPNE : Ii8PCRel<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
  193. }
  194. //===----------------------------------------------------------------------===//
  195. // Call Instructions...
  196. //
  197. let isCall = 1 in
  198. // All calls clobber the non-callee saved registers. ESP is marked as
  199. // a use to prevent stack-pointer assignments that appear immediately
  200. // before calls from potentially appearing dead. Uses for argument
  201. // registers are added manually.
  202. let Uses = [ESP, SSP] in {
  203. def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
  204. (outs), (ins i32imm_brtarget:$dst),
  205. "call{l}\t$dst", []>, OpSize32,
  206. Requires<[Not64BitMode]>, Sched<[WriteJump]>;
  207. let hasSideEffects = 0 in
  208. def CALLpcrel16 : Ii16PCRel<0xE8, RawFrm,
  209. (outs), (ins i16imm_brtarget:$dst),
  210. "call{w}\t$dst", []>, OpSize16,
  211. Sched<[WriteJump]>;
  212. def CALL16r : I<0xFF, MRM2r, (outs), (ins GR16:$dst),
  213. "call{w}\t{*}$dst", [(X86call GR16:$dst)]>,
  214. OpSize16, Requires<[Not64BitMode]>, Sched<[WriteJump]>;
  215. def CALL16m : I<0xFF, MRM2m, (outs), (ins i16mem:$dst),
  216. "call{w}\t{*}$dst", [(X86call (loadi16 addr:$dst))]>,
  217. OpSize16, Requires<[Not64BitMode,FavorMemIndirectCall]>,
  218. Sched<[WriteJumpLd]>;
  219. def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst),
  220. "call{l}\t{*}$dst", [(X86call GR32:$dst)]>, OpSize32,
  221. Requires<[Not64BitMode,NotUseIndirectThunkCalls]>,
  222. Sched<[WriteJump]>;
  223. def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst),
  224. "call{l}\t{*}$dst", [(X86call (loadi32 addr:$dst))]>,
  225. OpSize32,
  226. Requires<[Not64BitMode,FavorMemIndirectCall,
  227. NotUseIndirectThunkCalls]>,
  228. Sched<[WriteJumpLd]>;
  229. // Non-tracking calls for IBT, use with caution.
  230. let isCodeGenOnly = 1 in {
  231. def CALL16r_NT : I<0xFF, MRM2r, (outs), (ins GR16 : $dst),
  232. "call{w}\t{*}$dst",[(X86NoTrackCall GR16 : $dst)]>,
  233. OpSize16, Requires<[Not64BitMode]>, Sched<[WriteJump]>, NOTRACK;
  234. def CALL16m_NT : I<0xFF, MRM2m, (outs), (ins i16mem : $dst),
  235. "call{w}\t{*}$dst",[(X86NoTrackCall(loadi16 addr : $dst))]>,
  236. OpSize16, Requires<[Not64BitMode,FavorMemIndirectCall]>,
  237. Sched<[WriteJumpLd]>, NOTRACK;
  238. def CALL32r_NT : I<0xFF, MRM2r, (outs), (ins GR32 : $dst),
  239. "call{l}\t{*}$dst",[(X86NoTrackCall GR32 : $dst)]>,
  240. OpSize32, Requires<[Not64BitMode]>, Sched<[WriteJump]>, NOTRACK;
  241. def CALL32m_NT : I<0xFF, MRM2m, (outs), (ins i32mem : $dst),
  242. "call{l}\t{*}$dst",[(X86NoTrackCall(loadi32 addr : $dst))]>,
  243. OpSize32, Requires<[Not64BitMode,FavorMemIndirectCall]>,
  244. Sched<[WriteJumpLd]>, NOTRACK;
  245. }
  246. let Predicates = [Not64BitMode], AsmVariantName = "att" in {
  247. def FARCALL16i : Iseg16<0x9A, RawFrmImm16, (outs),
  248. (ins i16imm:$off, i16imm:$seg),
  249. "lcall{w}\t$seg, $off", []>,
  250. OpSize16, Sched<[WriteJump]>;
  251. def FARCALL32i : Iseg32<0x9A, RawFrmImm16, (outs),
  252. (ins i32imm:$off, i16imm:$seg),
  253. "lcall{l}\t$seg, $off", []>,
  254. OpSize32, Sched<[WriteJump]>;
  255. }
  256. let mayLoad = 1 in {
  257. def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaquemem:$dst),
  258. "lcall{w}\t{*}$dst", []>, OpSize16, Sched<[WriteJumpLd]>;
  259. def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaquemem:$dst),
  260. "{l}call{l}\t{*}$dst", []>, OpSize32, Sched<[WriteJumpLd]>;
  261. }
  262. }
  263. // Tail call stuff.
  264. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1,
  265. isCodeGenOnly = 1, Uses = [ESP, SSP] in {
  266. def TCRETURNdi : PseudoI<(outs), (ins i32imm_brtarget:$dst, i32imm:$offset),
  267. []>, Sched<[WriteJump]>, NotMemoryFoldable;
  268. def TCRETURNri : PseudoI<(outs), (ins ptr_rc_tailcall:$dst, i32imm:$offset),
  269. []>, Sched<[WriteJump]>, NotMemoryFoldable;
  270. let mayLoad = 1 in
  271. def TCRETURNmi : PseudoI<(outs), (ins i32mem_TC:$dst, i32imm:$offset),
  272. []>, Sched<[WriteJumpLd]>;
  273. def TAILJMPd : PseudoI<(outs), (ins i32imm_brtarget:$dst),
  274. []>, Sched<[WriteJump]>;
  275. def TAILJMPr : PseudoI<(outs), (ins ptr_rc_tailcall:$dst),
  276. []>, Sched<[WriteJump]>;
  277. let mayLoad = 1 in
  278. def TAILJMPm : PseudoI<(outs), (ins i32mem_TC:$dst),
  279. []>, Sched<[WriteJumpLd]>;
  280. }
  281. // Conditional tail calls are similar to the above, but they are branches
  282. // rather than barriers, and they use EFLAGS.
  283. let isCall = 1, isTerminator = 1, isReturn = 1, isBranch = 1,
  284. isCodeGenOnly = 1, SchedRW = [WriteJump] in
  285. let Uses = [ESP, EFLAGS, SSP] in {
  286. def TCRETURNdicc : PseudoI<(outs),
  287. (ins i32imm_brtarget:$dst, i32imm:$offset, i32imm:$cond),
  288. []>;
  289. // This gets substituted to a conditional jump instruction in MC lowering.
  290. def TAILJMPd_CC : PseudoI<(outs), (ins i32imm_brtarget:$dst, i32imm:$cond), []>;
  291. }
  292. //===----------------------------------------------------------------------===//
  293. // Call Instructions...
  294. //
  295. // RSP is marked as a use to prevent stack-pointer assignments that appear
  296. // immediately before calls from potentially appearing dead. Uses for argument
  297. // registers are added manually.
  298. let isCall = 1, Uses = [RSP, SSP], SchedRW = [WriteJump] in {
  299. // NOTE: this pattern doesn't match "X86call imm", because we do not know
  300. // that the offset between an arbitrary immediate and the call will fit in
  301. // the 32-bit pcrel field that we have.
  302. def CALL64pcrel32 : Ii32PCRel<0xE8, RawFrm,
  303. (outs), (ins i64i32imm_brtarget:$dst),
  304. "call{q}\t$dst", []>, OpSize32,
  305. Requires<[In64BitMode]>;
  306. def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst),
  307. "call{q}\t{*}$dst", [(X86call GR64:$dst)]>,
  308. Requires<[In64BitMode,NotUseIndirectThunkCalls]>;
  309. def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst),
  310. "call{q}\t{*}$dst", [(X86call (loadi64 addr:$dst))]>,
  311. Requires<[In64BitMode,FavorMemIndirectCall,
  312. NotUseIndirectThunkCalls]>;
  313. // Non-tracking calls for IBT, use with caution.
  314. let isCodeGenOnly = 1 in {
  315. def CALL64r_NT : I<0xFF, MRM2r, (outs), (ins GR64 : $dst),
  316. "call{q}\t{*}$dst",[(X86NoTrackCall GR64 : $dst)]>,
  317. Requires<[In64BitMode]>, NOTRACK;
  318. def CALL64m_NT : I<0xFF, MRM2m, (outs), (ins i64mem : $dst),
  319. "call{q}\t{*}$dst",
  320. [(X86NoTrackCall(loadi64 addr : $dst))]>,
  321. Requires<[In64BitMode,FavorMemIndirectCall]>, NOTRACK;
  322. }
  323. let mayLoad = 1 in
  324. def FARCALL64m : RI<0xFF, MRM3m, (outs), (ins opaquemem:$dst),
  325. "lcall{q}\t{*}$dst", []>;
  326. }
  327. let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1,
  328. isCodeGenOnly = 1, Uses = [RSP, SSP] in {
  329. def TCRETURNdi64 : PseudoI<(outs),
  330. (ins i64i32imm_brtarget:$dst, i32imm:$offset),
  331. []>, Sched<[WriteJump]>;
  332. def TCRETURNri64 : PseudoI<(outs),
  333. (ins ptr_rc_tailcall:$dst, i32imm:$offset),
  334. []>, Sched<[WriteJump]>, NotMemoryFoldable;
  335. let mayLoad = 1 in
  336. def TCRETURNmi64 : PseudoI<(outs),
  337. (ins i64mem_TC:$dst, i32imm:$offset),
  338. []>, Sched<[WriteJumpLd]>, NotMemoryFoldable;
  339. def TAILJMPd64 : PseudoI<(outs), (ins i64i32imm_brtarget:$dst),
  340. []>, Sched<[WriteJump]>;
  341. def TAILJMPr64 : PseudoI<(outs), (ins ptr_rc_tailcall:$dst),
  342. []>, Sched<[WriteJump]>;
  343. let mayLoad = 1 in
  344. def TAILJMPm64 : PseudoI<(outs), (ins i64mem_TC:$dst),
  345. []>, Sched<[WriteJumpLd]>;
  346. // Win64 wants indirect jumps leaving the function to have a REX_W prefix.
  347. let hasREX_WPrefix = 1 in {
  348. def TAILJMPr64_REX : PseudoI<(outs), (ins ptr_rc_tailcall:$dst),
  349. []>, Sched<[WriteJump]>;
  350. let mayLoad = 1 in
  351. def TAILJMPm64_REX : PseudoI<(outs), (ins i64mem_TC:$dst),
  352. []>, Sched<[WriteJumpLd]>;
  353. }
  354. }
  355. let isPseudo = 1, isCall = 1, isCodeGenOnly = 1,
  356. Uses = [RSP, SSP],
  357. usesCustomInserter = 1,
  358. SchedRW = [WriteJump] in {
  359. def INDIRECT_THUNK_CALL32 :
  360. PseudoI<(outs), (ins GR32:$dst), [(X86call GR32:$dst)]>,
  361. Requires<[Not64BitMode,UseIndirectThunkCalls]>;
  362. def INDIRECT_THUNK_CALL64 :
  363. PseudoI<(outs), (ins GR64:$dst), [(X86call GR64:$dst)]>,
  364. Requires<[In64BitMode,UseIndirectThunkCalls]>;
  365. // Indirect thunk variant of indirect tail calls.
  366. let isTerminator = 1, isReturn = 1, isBarrier = 1 in {
  367. def INDIRECT_THUNK_TCRETURN64 :
  368. PseudoI<(outs), (ins GR64:$dst, i32imm:$offset), []>;
  369. def INDIRECT_THUNK_TCRETURN32 :
  370. PseudoI<(outs), (ins GR32:$dst, i32imm:$offset), []>;
  371. }
  372. }
  373. let isPseudo = 1, isCall = 1, isCodeGenOnly = 1,
  374. Uses = [RSP, SSP],
  375. SchedRW = [WriteJump] in {
  376. def CALL64m_RVMARKER :
  377. PseudoI<(outs), (ins i64imm:$rvfunc, i64mem:$dst), [(X86call_rvmarker tglobaladdr:$rvfunc, (loadi64 addr:$dst))]>,
  378. Requires<[In64BitMode]>;
  379. def CALL64r_RVMARKER :
  380. PseudoI<(outs), (ins i64imm:$rvfunc, GR64:$dst), [(X86call_rvmarker tglobaladdr:$rvfunc, GR64:$dst)]>,
  381. Requires<[In64BitMode]>;
  382. def CALL64pcrel32_RVMARKER :
  383. PseudoI<(outs), (ins i64imm:$rvfunc, i64i32imm_brtarget:$dst), []>,
  384. Requires<[In64BitMode]>;
  385. }
  386. // Conditional tail calls are similar to the above, but they are branches
  387. // rather than barriers, and they use EFLAGS.
  388. let isCall = 1, isTerminator = 1, isReturn = 1, isBranch = 1,
  389. isCodeGenOnly = 1, SchedRW = [WriteJump] in
  390. let Uses = [RSP, EFLAGS, SSP] in {
  391. def TCRETURNdi64cc : PseudoI<(outs),
  392. (ins i64i32imm_brtarget:$dst, i32imm:$offset,
  393. i32imm:$cond), []>;
  394. // This gets substituted to a conditional jump instruction in MC lowering.
  395. def TAILJMPd64_CC : PseudoI<(outs),
  396. (ins i64i32imm_brtarget:$dst, i32imm:$cond), []>;
  397. }