[X86][AsmParser] Treat '%' as the modulo operator under Intel syntax
authorReid Kleckner <rnk@google.com>
Tue, 31 Oct 2017 16:47:38 +0000 (16:47 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 31 Oct 2017 16:47:38 +0000 (16:47 +0000)
It can't be a register prefix, anyway. This is consistent with the masm
docs on MSDN: https://msdn.microsoft.com/en-us/library/t4ax90d2.aspx

This is a straight-forward extension of our support for "MOD"
implemented in https://reviews.llvm.org/D33876 / r306425

llvm-svn: 317011

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/test/MC/X86/intel-syntax-bitwise-ops.s

index 16fd506..b8ea2f0 100644 (file)
@@ -1470,6 +1470,7 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
     case AsmToken::Tilde:   SM.onNot(); break;
     case AsmToken::Star:    SM.onStar(); break;
     case AsmToken::Slash:   SM.onDivide(); break;
+    case AsmToken::Percent: SM.onMod(); break;
     case AsmToken::Pipe:    SM.onOr(); break;
     case AsmToken::Caret:   SM.onXor(); break;
     case AsmToken::Amp:     SM.onAnd(); break;
index a0b2580..2ebad7c 100644 (file)
@@ -72,4 +72,9 @@
     mov eax, ~(5 mod 3)
 // CHECK: movl  $-2, %eax
     mov eax, (-5 mod 3)
-
+// CHECK: movl  $-3, %eax
+    mov eax, ~(5 % 3)
+// CHECK: movl  $-2, %eax
+    mov eax, (-5 % 3)
+// CHECK: movl  $-2, %eax
+    mov eax, -5 % 3