[X86] Emit REX prefix immediately before the opcode
authorAmir Ayupov <aaupov@fb.com>
Thu, 3 Mar 2022 07:20:15 +0000 (23:20 -0800)
committerAmir Ayupov <aaupov@fb.com>
Wed, 16 Mar 2022 15:30:31 +0000 (08:30 -0700)
Fix prefix emission order to emit REX immediately before the opcode (SDM vol2,
2.1, Figure 2-1). According to SDM vol2 2.2.1, "Other placements are ignored".

This fix has a side effect of outputting segment override prefix in a different
order than previously (benign).

Follow-up to https://reviews.llvm.org/D120592

Reviewed By: skan, craig.topper

Differential Revision: https://reviews.llvm.org/D120871

llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
llvm/test/MC/Disassembler/X86/moffs.txt
llvm/test/MC/X86/I186-32.s
llvm/test/MC/X86/I186-64.s
llvm/test/MC/X86/I386-32.s
llvm/test/MC/X86/I386-64.s
llvm/test/MC/X86/I86-32.s
llvm/test/MC/X86/I86-64.s
llvm/test/MC/X86/code16gcc.s
llvm/test/MC/X86/index-operations.s
llvm/test/MC/X86/x86-16.s

index c03bbb6..527df81 100644 (file)
@@ -617,14 +617,6 @@ bool X86MCCodeEmitter::emitPrefixImpl(unsigned &CurOp, const MCInst &MI,
       Flags & X86::IP_HAS_AD_SIZE)
     emitByte(0x67, OS);
 
-  // Encoding type for this instruction.
-  uint64_t Encoding = TSFlags & X86II::EncodingMask;
-  bool HasREX = false;
-  if (Encoding)
-    emitVEXOpcodePrefix(MemoryOperand, MI, OS);
-  else
-    HasREX = emitOpcodePrefix(MemoryOperand, MI, STI, OS);
-
   uint64_t Form = TSFlags & X86II::FormMask;
   switch (Form) {
   default:
@@ -654,6 +646,15 @@ bool X86MCCodeEmitter::emitPrefixImpl(unsigned &CurOp, const MCInst &MI,
   }
   }
 
+  // REX prefix is optional, but if used must be immediately before the opcode
+  // Encoding type for this instruction.
+  uint64_t Encoding = TSFlags & X86II::EncodingMask;
+  bool HasREX = false;
+  if (Encoding)
+    emitVEXOpcodePrefix(MemoryOperand, MI, OS);
+  else
+    HasREX = emitOpcodePrefix(MemoryOperand, MI, STI, OS);
+
   return HasREX;
 }
 
index ac18859..cbabd45 100644 (file)
@@ -37,9 +37,9 @@
 # 64: movw 0x5a5a5a5a, %ax # encoding: [0x67,0x66,0xa1,0x5a,0x5a,0x5a,0x5a]
 0x67 0x66 0xa1 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a
 
-# 16: movl %es:0x5a5a5a5a, %eax # encoding: [0x67,0x66,0x26,0xa1,0x5a,0x5a,0x5a,0x5a]
-# 32: movw %es:0x5a5a, %ax # encoding: [0x67,0x66,0x26,0xa1,0x5a,0x5a]
-# 64: movw %es:0x5a5a5a5a, %ax # encoding: [0x67,0x66,0x26,0xa1,0x5a,0x5a,0x5a,0x5a]
+# 16: movl %es:0x5a5a5a5a, %eax # encoding: [0x67,0x26,0x66,0xa1,0x5a,0x5a,0x5a,0x5a]
+# 32: movw %es:0x5a5a, %ax # encoding: [0x67,0x26,0x66,0xa1,0x5a,0x5a]
+# 64: movw %es:0x5a5a5a5a, %ax # encoding: [0x67,0x26,0x66,0xa1,0x5a,0x5a,0x5a,0x5a]
 0x67 0x26 0x66 0xa1 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a # encoding: [0xa0,0x5a,0x5a]
 
 
@@ -79,8 +79,8 @@
 # 64: movw %ax, 0x5a5a5a5a # encoding: [0x67,0x66,0xa3,0x5a,0x5a,0x5a,0x5a]
 0x67 0x66 0xa3 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a
 
-# 16: movl %eax, %es:0x5a5a5a5a # encoding: [0x67,0x66,0x26,0xa3,0x5a,0x5a,0x5a,0x5a]
-# 32: movw %ax, %es:0x5a5a # encoding: [0x67,0x66,0x26,0xa3,0x5a,0x5a]
-# 64: movw %ax, %es:0x5a5a5a5a # encoding: [0x67,0x66,0x26,0xa3,0x5a,0x5a,0x5a,0x5a]
+# 16: movl %eax, %es:0x5a5a5a5a # encoding: [0x67,0x26,0x66,0xa3,0x5a,0x5a,0x5a,0x5a]
+# 32: movw %ax, %es:0x5a5a # encoding: [0x67,0x26,0x66,0xa3,0x5a,0x5a]
+# 64: movw %ax, %es:0x5a5a5a5a # encoding: [0x67,0x26,0x66,0xa3,0x5a,0x5a,0x5a,0x5a]
 0x67 0x26 0x66 0xa3 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a
 
index adb7802..afa28a1 100644 (file)
@@ -57,7 +57,7 @@ outsb %es:(%esi), %dx
 outsl %es:(%esi), %dx 
 
 // CHECK: outsw %es:(%esi), %dx 
-// CHECK: encoding: [0x66,0x26,0x6f]        
+// CHECK: encoding: [0x26,0x66,0x6f]        
 outsw %es:(%esi), %dx 
 
 // CHECK: popal 
@@ -269,7 +269,7 @@ repne outsb %es:(%esi), %dx
 repne outsl %es:(%esi), %dx 
 
 // CHECK: repne outsw %es:(%esi), %dx 
-// CHECK: encoding: [0xf2,0x66,0x26,0x6f]       
+// CHECK: encoding: [0xf2,0x26,0x66,0x6f]       
 repne outsw %es:(%esi), %dx 
 
 // CHECK: rep outsb %es:(%esi), %dx 
@@ -281,7 +281,7 @@ rep outsb %es:(%esi), %dx
 rep outsl %es:(%esi), %dx 
 
 // CHECK: rep outsw %es:(%esi), %dx 
-// CHECK: encoding: [0xf3,0x66,0x26,0x6f]       
+// CHECK: encoding: [0xf3,0x26,0x66,0x6f]       
 rep outsw %es:(%esi), %dx 
 
 // CHECK: rolb $0, -485498096(%edx,%eax,4) 
index 18aa124..0ee6fee 100644 (file)
@@ -33,7 +33,7 @@ outsb %gs:(%rsi), %dx
 outsl %gs:(%rsi), %dx 
 
 // CHECK: outsw %gs:(%rsi), %dx 
-// CHECK: encoding: [0x66,0x65,0x6f]        
+// CHECK: encoding: [0x65,0x66,0x6f]        
 outsw %gs:(%rsi), %dx 
 
 // CHECK: pushq $0 
@@ -289,7 +289,7 @@ repne outsb %gs:(%rsi), %dx
 repne outsl %gs:(%rsi), %dx 
 
 // CHECK: repne outsw %gs:(%rsi), %dx 
-// CHECK: encoding: [0xf2,0x66,0x65,0x6f]       
+// CHECK: encoding: [0xf2,0x65,0x66,0x6f]       
 repne outsw %gs:(%rsi), %dx 
 
 // CHECK: rep outsb %gs:(%rsi), %dx 
@@ -301,7 +301,7 @@ rep outsb %gs:(%rsi), %dx
 rep outsl %gs:(%rsi), %dx 
 
 // CHECK: rep outsw %gs:(%rsi), %dx 
-// CHECK: encoding: [0xf3,0x66,0x65,0x6f]       
+// CHECK: encoding: [0xf3,0x65,0x66,0x6f]       
 rep outsw %gs:(%rsi), %dx 
 
 // CHECK: rolb $0, 485498096 
index d4c73d7..0915300 100644 (file)
@@ -153,7 +153,7 @@ cmpsb %es:(%edi), %es:(%esi)
 cmpsl %es:(%edi), %es:(%esi) 
 
 // CHECK: cmpsw %es:(%edi), %es:(%esi) 
-// CHECK: encoding: [0x66,0x26,0xa7]        
+// CHECK: encoding: [0x26,0x66,0xa7]        
 cmpsw %es:(%edi), %es:(%esi) 
 
 // CHECK: insb %dx, %es:(%edi) 
@@ -193,7 +193,7 @@ movsb %es:(%esi), %es:(%edi)
 movsl %es:(%esi), %es:(%edi) 
 
 // CHECK: movsw %es:(%esi), %es:(%edi) 
-// CHECK: encoding: [0x66,0x26,0xa5]        
+// CHECK: encoding: [0x26,0x66,0xa5]        
 movsw %es:(%esi), %es:(%edi) 
 
 // CHECK: outsb %es:(%esi), %dx 
@@ -205,7 +205,7 @@ outsb %es:(%esi), %dx
 outsl %es:(%esi), %dx 
 
 // CHECK: outsw %es:(%esi), %dx 
-// CHECK: encoding: [0x66,0x26,0x6f]        
+// CHECK: encoding: [0x26,0x66,0x6f]        
 outsw %es:(%esi), %dx 
 
 // CHECK: popal 
@@ -249,7 +249,7 @@ rep cmpsb %es:(%edi), %es:(%esi)
 rep cmpsl %es:(%edi), %es:(%esi) 
 
 // CHECK: rep cmpsw %es:(%edi), %es:(%esi) 
-// CHECK: encoding: [0xf3,0x66,0x26,0xa7]       
+// CHECK: encoding: [0xf3,0x26,0x66,0xa7]       
 rep cmpsw %es:(%edi), %es:(%esi) 
 
 // CHECK: rep insb %dx, %es:(%edi) 
@@ -277,7 +277,7 @@ rep movsb %es:(%esi), %es:(%edi)
 rep movsl %es:(%esi), %es:(%edi) 
 
 // CHECK: rep movsw %es:(%esi), %es:(%edi) 
-// CHECK: encoding: [0xf3,0x66,0x26,0xa5]       
+// CHECK: encoding: [0xf3,0x26,0x66,0xa5]       
 rep movsw %es:(%esi), %es:(%edi) 
 
 // CHECK: repne cmpsb %es:(%edi), %es:(%esi) 
@@ -289,7 +289,7 @@ repne cmpsb %es:(%edi), %es:(%esi)
 repne cmpsl %es:(%edi), %es:(%esi) 
 
 // CHECK: repne cmpsw %es:(%edi), %es:(%esi) 
-// CHECK: encoding: [0xf2,0x66,0x26,0xa7]       
+// CHECK: encoding: [0xf2,0x26,0x66,0xa7]       
 repne cmpsw %es:(%edi), %es:(%esi) 
 
 // CHECK: repne insb %dx, %es:(%edi) 
@@ -317,7 +317,7 @@ repne movsb %es:(%esi), %es:(%edi)
 repne movsl %es:(%esi), %es:(%edi) 
 
 // CHECK: repne movsw %es:(%esi), %es:(%edi) 
-// CHECK: encoding: [0xf2,0x66,0x26,0xa5]       
+// CHECK: encoding: [0xf2,0x26,0x66,0xa5]       
 repne movsw %es:(%esi), %es:(%edi) 
 
 // CHECK: repne outsb %es:(%esi), %dx 
@@ -329,7 +329,7 @@ repne outsb %es:(%esi), %dx
 repne outsl %es:(%esi), %dx 
 
 // CHECK: repne outsw %es:(%esi), %dx 
-// CHECK: encoding: [0xf2,0x66,0x26,0x6f]       
+// CHECK: encoding: [0xf2,0x26,0x66,0x6f]       
 repne outsw %es:(%esi), %dx 
 
 // CHECK: repne scasl %es:(%edi), %eax 
@@ -349,7 +349,7 @@ rep outsb %es:(%esi), %dx
 rep outsl %es:(%esi), %dx 
 
 // CHECK: rep outsw %es:(%esi), %dx 
-// CHECK: encoding: [0xf3,0x66,0x26,0x6f]       
+// CHECK: encoding: [0xf3,0x26,0x66,0x6f]       
 rep outsw %es:(%esi), %dx 
 
 // CHECK: rep scasl %es:(%edi), %eax 
index b626534..b4f2c79 100644 (file)
@@ -226,11 +226,11 @@ cmpsb %es:(%rdi), %gs:(%rsi)
 cmpsl %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: cmpsq %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0x48,0x65,0xa7]        
+// CHECK: encoding: [0x65,0x48,0xa7]        
 cmpsq %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: cmpsw %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0x66,0x65,0xa7]        
+// CHECK: encoding: [0x65,0x66,0xa7]        
 cmpsw %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: insb %dx, %es:(%rdi) 
@@ -306,11 +306,11 @@ movsbl (%rdx), %r13d
 movsl %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: movsq %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0x48,0x65,0xa5]        
+// CHECK: encoding: [0x65,0x48,0xa5]        
 movsq %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: movsw %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0x66,0x65,0xa5]        
+// CHECK: encoding: [0x65,0x66,0xa5]        
 movsw %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: movswl 485498096, %r13d 
@@ -418,7 +418,7 @@ outsb %gs:(%rsi), %dx
 outsl %gs:(%rsi), %dx 
 
 // CHECK: outsw %gs:(%rsi), %dx 
-// CHECK: encoding: [0x66,0x65,0x6f]        
+// CHECK: encoding: [0x65,0x66,0x6f]        
 outsw %gs:(%rsi), %dx 
 
 // CHECK: rep cmpsb %es:(%rdi), %gs:(%rsi) 
@@ -430,11 +430,11 @@ rep cmpsb %es:(%rdi), %gs:(%rsi)
 rep cmpsl %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: rep cmpsq %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf3,0x48,0x65,0xa7]       
+// CHECK: encoding: [0xf3,0x65,0x48,0xa7]       
 rep cmpsq %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: rep cmpsw %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf3,0x66,0x65,0xa7]       
+// CHECK: encoding: [0xf3,0x65,0x66,0xa7]       
 rep cmpsw %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: rep insb %dx, %es:(%rdi) 
@@ -462,11 +462,11 @@ rep movsb %gs:(%rsi), %es:(%rdi)
 rep movsl %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: rep movsq %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf3,0x48,0x65,0xa5]       
+// CHECK: encoding: [0xf3,0x65,0x48,0xa5]       
 rep movsq %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: rep movsw %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf3,0x66,0x65,0xa5]       
+// CHECK: encoding: [0xf3,0x65,0x66,0xa5]       
 rep movsw %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne cmpsb %es:(%rdi), %gs:(%rsi) 
@@ -478,11 +478,11 @@ repne cmpsb %es:(%rdi), %gs:(%rsi)
 repne cmpsl %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: repne cmpsq %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf2,0x48,0x65,0xa7]       
+// CHECK: encoding: [0xf2,0x65,0x48,0xa7]       
 repne cmpsq %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: repne cmpsw %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf2,0x66,0x65,0xa7]       
+// CHECK: encoding: [0xf2,0x65,0x66,0xa7]       
 repne cmpsw %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: repne insb %dx, %es:(%rdi) 
@@ -510,11 +510,11 @@ repne movsb %gs:(%rsi), %es:(%rdi)
 repne movsl %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne movsq %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf2,0x48,0x65,0xa5]       
+// CHECK: encoding: [0xf2,0x65,0x48,0xa5]       
 repne movsq %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne movsw %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf2,0x66,0x65,0xa5]       
+// CHECK: encoding: [0xf2,0x65,0x66,0xa5]       
 repne movsw %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne outsb %gs:(%rsi), %dx 
@@ -526,7 +526,7 @@ repne outsb %gs:(%rsi), %dx
 repne outsl %gs:(%rsi), %dx 
 
 // CHECK: repne outsw %gs:(%rsi), %dx 
-// CHECK: encoding: [0xf2,0x66,0x65,0x6f]       
+// CHECK: encoding: [0xf2,0x65,0x66,0x6f]       
 repne outsw %gs:(%rsi), %dx 
 
 // CHECK: repne scasl %es:(%rdi), %eax 
@@ -546,7 +546,7 @@ rep outsb %gs:(%rsi), %dx
 rep outsl %gs:(%rsi), %dx 
 
 // CHECK: rep outsw %gs:(%rsi), %dx 
-// CHECK: encoding: [0xf3,0x66,0x65,0x6f]       
+// CHECK: encoding: [0xf3,0x65,0x66,0x6f]       
 rep outsw %gs:(%rsi), %dx 
 
 // CHECK: rep scasl %es:(%rdi), %eax 
index 5914864..b422c92 100644 (file)
@@ -565,7 +565,7 @@ cmpsb %es:(%edi), %es:(%esi)
 cmpsl %es:(%edi), %es:(%esi) 
 
 // CHECK: cmpsw %es:(%edi), %es:(%esi) 
-// CHECK: encoding: [0x66,0x26,0xa7]        
+// CHECK: encoding: [0x26,0x66,0xa7]        
 cmpsw %es:(%edi), %es:(%esi) 
 
 // CHECK: cmpw $0, -485498096(%edx,%eax,4) 
@@ -1197,7 +1197,7 @@ lock xchgl %eax, (%edx)
 lodsb %es:(%esi), %al 
 
 // CHECK: lodsw %es:(%esi), %ax 
-// CHECK: encoding: [0x66,0x26,0xad]        
+// CHECK: encoding: [0x26,0x66,0xad]        
 lodsw %es:(%esi), %ax 
 
 // CHECK: loop 64 
@@ -1345,7 +1345,7 @@ movsb %es:(%esi), %es:(%edi)
 movsl %es:(%esi), %es:(%edi) 
 
 // CHECK: movsw %es:(%esi), %es:(%edi) 
-// CHECK: encoding: [0x66,0x26,0xa5]        
+// CHECK: encoding: [0x26,0x66,0xa5]        
 movsw %es:(%esi), %es:(%edi) 
 
 // CHECK: movw $0, -485498096(%edx,%eax,4) 
@@ -2221,7 +2221,7 @@ rep cmpsb %es:(%edi), %es:(%esi)
 rep cmpsl %es:(%edi), %es:(%esi) 
 
 // CHECK: rep cmpsw %es:(%edi), %es:(%esi) 
-// CHECK: encoding: [0xf3,0x66,0x26,0xa7]       
+// CHECK: encoding: [0xf3,0x26,0x66,0xa7]       
 rep cmpsw %es:(%edi), %es:(%esi) 
 
 // CHECK: rep lodsb %es:(%esi), %al 
@@ -2229,7 +2229,7 @@ rep cmpsw %es:(%edi), %es:(%esi)
 rep lodsb %es:(%esi), %al 
 
 // CHECK: rep lodsw %es:(%esi), %ax 
-// CHECK: encoding: [0xf3,0x66,0x26,0xad]       
+// CHECK: encoding: [0xf3,0x26,0x66,0xad]       
 rep lodsw %es:(%esi), %ax 
 
 // CHECK: rep movsb %es:(%esi), %es:(%edi) 
@@ -2241,7 +2241,7 @@ rep movsb %es:(%esi), %es:(%edi)
 rep movsl %es:(%esi), %es:(%edi) 
 
 // CHECK: rep movsw %es:(%esi), %es:(%edi) 
-// CHECK: encoding: [0xf3,0x66,0x26,0xa5]       
+// CHECK: encoding: [0xf3,0x26,0x66,0xa5]       
 rep movsw %es:(%esi), %es:(%edi) 
 
 // CHECK: repne cmpsb %es:(%edi), %es:(%esi) 
@@ -2253,7 +2253,7 @@ repne cmpsb %es:(%edi), %es:(%esi)
 repne cmpsl %es:(%edi), %es:(%esi) 
 
 // CHECK: repne cmpsw %es:(%edi), %es:(%esi) 
-// CHECK: encoding: [0xf2,0x66,0x26,0xa7]       
+// CHECK: encoding: [0xf2,0x26,0x66,0xa7]       
 repne cmpsw %es:(%edi), %es:(%esi) 
 
 // CHECK: repne lodsb %es:(%esi), %al 
@@ -2261,7 +2261,7 @@ repne cmpsw %es:(%edi), %es:(%esi)
 repne lodsb %es:(%esi), %al 
 
 // CHECK: repne lodsw %es:(%esi), %ax 
-// CHECK: encoding: [0xf2,0x66,0x26,0xad]       
+// CHECK: encoding: [0xf2,0x26,0x66,0xad]       
 repne lodsw %es:(%esi), %ax 
 
 // CHECK: repne movsb %es:(%esi), %es:(%edi) 
@@ -2273,7 +2273,7 @@ repne movsb %es:(%esi), %es:(%edi)
 repne movsl %es:(%esi), %es:(%edi) 
 
 // CHECK: repne movsw %es:(%esi), %es:(%edi) 
-// CHECK: encoding: [0xf2,0x66,0x26,0xa5]       
+// CHECK: encoding: [0xf2,0x26,0x66,0xa5]       
 repne movsw %es:(%esi), %es:(%edi) 
 
 // CHECK: repne scasb %es:(%edi), %al 
index 6ea78e2..7e9544e 100644 (file)
@@ -873,11 +873,11 @@ cmpsb %es:(%rdi), %gs:(%rsi)
 cmpsl %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: cmpsq %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0x48,0x65,0xa7]        
+// CHECK: encoding: [0x65,0x48,0xa7]        
 cmpsq %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: cmpsw %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0x66,0x65,0xa7]        
+// CHECK: encoding: [0x65,0x66,0xa7]        
 cmpsw %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: cmpw $0, 485498096 
@@ -1645,7 +1645,7 @@ leal (%rdx), %r13d
 lodsb %gs:(%rsi), %al 
 
 // CHECK: lodsw %gs:(%rsi), %ax 
-// CHECK: encoding: [0x66,0x65,0xad]        
+// CHECK: encoding: [0x65,0x66,0xad]        
 lodsw %gs:(%rsi), %ax 
 
 // CHECK: loop 64 
@@ -1821,11 +1821,11 @@ movsb %gs:(%rsi), %es:(%rdi)
 movsl %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: movsq %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0x48,0x65,0xa5]        
+// CHECK: encoding: [0x65,0x48,0xa5]        
 movsq %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: movsw %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0x66,0x65,0xa5]        
+// CHECK: encoding: [0x65,0x66,0xa5]        
 movsw %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: movw $0, 485498096 
@@ -2985,11 +2985,11 @@ rep cmpsb %es:(%rdi), %gs:(%rsi)
 rep cmpsl %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: rep cmpsq %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf3,0x48,0x65,0xa7]       
+// CHECK: encoding: [0xf3,0x65,0x48,0xa7]       
 rep cmpsq %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: rep cmpsw %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf3,0x66,0x65,0xa7]       
+// CHECK: encoding: [0xf3,0x65,0x66,0xa7]       
 rep cmpsw %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: rep lodsb %gs:(%rsi), %al 
@@ -2997,7 +2997,7 @@ rep cmpsw %es:(%rdi), %gs:(%rsi)
 rep lodsb %gs:(%rsi), %al 
 
 // CHECK: rep lodsw %gs:(%rsi), %ax 
-// CHECK: encoding: [0xf3,0x66,0x65,0xad]       
+// CHECK: encoding: [0xf3,0x65,0x66,0xad]       
 rep lodsw %gs:(%rsi), %ax 
 
 // CHECK: rep movsb %gs:(%rsi), %es:(%rdi) 
@@ -3009,11 +3009,11 @@ rep movsb %gs:(%rsi), %es:(%rdi)
 rep movsl %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: rep movsq %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf3,0x48,0x65,0xa5]       
+// CHECK: encoding: [0xf3,0x65,0x48,0xa5]       
 rep movsq %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: rep movsw %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf3,0x66,0x65,0xa5]       
+// CHECK: encoding: [0xf3,0x65,0x66,0xa5]       
 rep movsw %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne cmpsb %es:(%rdi), %gs:(%rsi) 
@@ -3025,11 +3025,11 @@ repne cmpsb %es:(%rdi), %gs:(%rsi)
 repne cmpsl %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: repne cmpsq %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf2,0x48,0x65,0xa7]       
+// CHECK: encoding: [0xf2,0x65,0x48,0xa7]       
 repne cmpsq %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: repne cmpsw %es:(%rdi), %gs:(%rsi) 
-// CHECK: encoding: [0xf2,0x66,0x65,0xa7]       
+// CHECK: encoding: [0xf2,0x65,0x66,0xa7]       
 repne cmpsw %es:(%rdi), %gs:(%rsi) 
 
 // CHECK: repne lodsb %gs:(%rsi), %al 
@@ -3037,7 +3037,7 @@ repne cmpsw %es:(%rdi), %gs:(%rsi)
 repne lodsb %gs:(%rsi), %al 
 
 // CHECK: repne lodsw %gs:(%rsi), %ax 
-// CHECK: encoding: [0xf2,0x66,0x65,0xad]       
+// CHECK: encoding: [0xf2,0x65,0x66,0xad]       
 repne lodsw %gs:(%rsi), %ax 
 
 // CHECK: repne movsb %gs:(%rsi), %es:(%rdi) 
@@ -3049,11 +3049,11 @@ repne movsb %gs:(%rsi), %es:(%rdi)
 repne movsl %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne movsq %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf2,0x48,0x65,0xa5]       
+// CHECK: encoding: [0xf2,0x65,0x48,0xa5]       
 repne movsq %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne movsw %gs:(%rsi), %es:(%rdi) 
-// CHECK: encoding: [0xf2,0x66,0x65,0xa5]       
+// CHECK: encoding: [0xf2,0x65,0x66,0xa5]       
 repne movsw %gs:(%rsi), %es:(%rdi) 
 
 // CHECK: repne scasb %es:(%rdi), %al 
index bb7940c..4b669bf 100644 (file)
@@ -11,7 +11,7 @@
        lodsb (%esi), %al
        //CHECK:        lodsb   (%esi), %al             # encoding: [0x67,0xac]
        lodsl %gs:(%esi)
-       //CHECK:        lodsl   %gs:(%esi), %eax        # encoding: [0x67,0x66,0x65,0xad]
+       //CHECK:        lodsl   %gs:(%esi), %eax        # encoding: [0x67,0x65,0x66,0xad]
        lods (%esi), %ax
        //CHECK:        lodsw   (%esi), %ax             # encoding: [0x67,0xad]
        stosw
        cmpsw (%edi), (%esi)
        //CHECK:        cmpsw   %es:(%edi), (%esi)      # encoding: [0x67,0xa7]
        cmpsl %es:(%edi), %ss:(%esi)
-       //CHECK:        cmpsl   %es:(%edi), %ss:(%esi)  # encoding: [0x67,0x66,0x36,0xa7]
+       //CHECK:        cmpsl   %es:(%edi), %ss:(%esi)  # encoding: [0x67,0x36,0x66,0xa7]
        movsb (%esi), (%edi)
        //CHECK:        movsb   (%esi), %es:(%edi)      # encoding: [0x67,0xa4]
        movsl %gs:(%esi), (%edi)
-       //CHECK:        movsl   %gs:(%esi), %es:(%edi)  # encoding: [0x67,0x66,0x65,0xa5]
+       //CHECK:        movsl   %gs:(%esi), %es:(%edi)  # encoding: [0x67,0x65,0x66,0xa5]
        outsb
        //CHECK:        outsb   (%esi), %dx             # encoding: [0x67,0x6e]
        outsw %fs:(%esi), %dx
index 425b194..0c39fe8 100644 (file)
@@ -28,7 +28,7 @@ lodsb (%si), %al
 lodsl %gs:(%esi)
 // 64: lodsl %gs:(%esi), %eax # encoding: [0x67,0x65,0xad]
 // 32: lodsl %gs:(%esi), %eax # encoding: [0x65,0xad]
-// 16: lodsl %gs:(%esi), %eax # encoding: [0x67,0x66,0x65,0xad]
+// 16: lodsl %gs:(%esi), %eax # encoding: [0x67,0x65,0x66,0xad]
 
 lodsl (%edi), %eax
 // ERR64: invalid operand
@@ -113,7 +113,7 @@ cmpsb (%di), (%esi)
 cmpsl %es:(%edi), %ss:(%esi)
 // 64: cmpsl %es:(%edi), %ss:(%esi) # encoding: [0x67,0x36,0xa7]
 // 32: cmpsl %es:(%edi), %ss:(%esi) # encoding: [0x36,0xa7]
-// 16: cmpsl %es:(%edi), %ss:(%esi) # encoding: [0x67,0x66,0x36,0xa7]
+// 16: cmpsl %es:(%edi), %ss:(%esi) # encoding: [0x67,0x36,0x66,0xa7]
 
 cmpsq (%rdi), (%rsi)
 // 64: cmpsq %es:(%rdi), (%rsi) # encoding: [0x48,0xa7]
@@ -128,7 +128,7 @@ movsb (%esi), (%edi)
 movsl %gs:(%esi), (%edi)
 // 64: movsl %gs:(%esi), %es:(%edi) # encoding: [0x67,0x65,0xa5]
 // 32: movsl %gs:(%esi), %es:(%edi) # encoding: [0x65,0xa5]
-// 16: movsl %gs:(%esi), %es:(%edi) # encoding: [0x67,0x66,0x65,0xa5]
+// 16: movsl %gs:(%esi), %es:(%edi) # encoding: [0x67,0x65,0x66,0xa5]
 
 outsb
 // 64: outsb (%rsi), %dx # encoding: [0x6e]
@@ -136,8 +136,8 @@ outsb
 // 16: outsb (%si), %dx # encoding: [0x6e]
 
 outsw %fs:(%esi), %dx
-// 64: outsw %fs:(%esi), %dx # encoding: [0x67,0x66,0x64,0x6f]
-// 32: outsw %fs:(%esi), %dx # encoding: [0x66,0x64,0x6f]
+// 64: outsw %fs:(%esi), %dx # encoding: [0x67,0x64,0x66,0x6f]
+// 32: outsw %fs:(%esi), %dx # encoding: [0x64,0x66,0x6f]
 // 16: outsw %fs:(%esi), %dx # encoding: [0x67,0x64,0x6f]
 
 insw %dx, (%edi)
index 9f8c639..6670e73 100644 (file)
@@ -340,7 +340,7 @@ cmovnae     %bx,%bx
 // CHECK:  encoding: [0x9b]
        fwait
 
-// CHECK: [0x66,0x65,0xa1,0x7c,0x00]
+// CHECK: [0x65,0x66,0xa1,0x7c,0x00]
         movl   %gs:124, %eax
 
 // CHECK: pusha