[PATCH] D24346: [x86] Accept 'retn' as an alias to 'ret[lqw]'\'ret' (At&t\Intel)

coby via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 08:10:10 PDT 2016


coby created this revision.
coby added reviewers: dwmw2, delena.
coby added a subscriber: llvm-commits.
coby set the repository for this revision to rL LLVM.

Implement 'retn' simply by aliasing it to the relevant 'ret' instruction

Repository:
  rL LLVM

https://reviews.llvm.org/D24346

Files:
  lib/Target/X86/X86InstrInfo.td
  test/MC/X86/ret.s

Index: lib/Target/X86/X86InstrInfo.td
===================================================================
--- lib/Target/X86/X86InstrInfo.td
+++ lib/Target/X86/X86InstrInfo.td
@@ -2626,6 +2626,12 @@
 def : MnemonicAlias<"ret", "retl", "att">, Requires<[In32BitMode]>;
 def : MnemonicAlias<"ret", "retq", "att">, Requires<[In64BitMode]>;
 
+// Apply 'ret' behavior to 'retn'
+def : MnemonicAlias<"retn", "retw", "att">, Requires<[In16BitMode]>;
+def : MnemonicAlias<"retn", "retl", "att">, Requires<[In32BitMode]>;
+def : MnemonicAlias<"retn", "retq", "att">, Requires<[In64BitMode]>;
+def : MnemonicAlias<"retn", "ret", "intel">;
+
 def : MnemonicAlias<"sal", "shl", "intel">;
 def : MnemonicAlias<"salb", "shlb", "att">;
 def : MnemonicAlias<"salw", "shlw", "att">;
Index: test/MC/X86/ret.s
===================================================================
--- test/MC/X86/ret.s
+++ test/MC/X86/ret.s
@@ -57,6 +57,22 @@
 // ERR32: error: instruction requires: 64-bit mode
 // ERR16: error: instruction requires: 64-bit mode
 
+	retn
+// 64: retq
+// 64: encoding: [0xc3]
+// 32: retl
+// 32: encoding: [0xc3]
+// 16: retw
+// 16: encoding: [0xc3]
+
+  retn $0
+// 64: retq $0
+// 64: encoding: [0xc2,0x00,0x00]
+// 32: retl $0
+// 32: encoding: [0xc2,0x00,0x00]
+// 16: retw $0
+// 16: encoding: [0xc2,0x00,0x00]
+
 	lret
 // 64: lretl
 // 64: encoding: [0xcb]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24346.70700.patch
Type: text/x-patch
Size: 1364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160908/bca4d3fe/attachment.bin>


More information about the llvm-commits mailing list