[clang] 188d92b - [X86] Don't treat mxcsr as a register name when parsing MS inline assembly.

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 13 15:26:52 PST 2019


Author: Craig Topper
Date: 2019-11-13T15:26:18-08:00
New Revision: 188d92b9470de71532ec58060cd75f913fd68e59

URL: https://github.com/llvm/llvm-project/commit/188d92b9470de71532ec58060cd75f913fd68e59
DIFF: https://github.com/llvm/llvm-project/commit/188d92b9470de71532ec58060cd75f913fd68e59.diff

LOG: [X86] Don't treat mxcsr as a register name when parsing MS inline assembly.

No instruction takes mxcsr as a an operand so we should always
treat it as an identifier name.

Added: 
    

Modified: 
    clang/test/CodeGen/ms-inline-asm.c
    llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGen/ms-inline-asm.c b/clang/test/CodeGen/ms-inline-asm.c
index ca9b937a7cde..00d408f431c4 100644
--- a/clang/test/CodeGen/ms-inline-asm.c
+++ b/clang/test/CodeGen/ms-inline-asm.c
@@ -592,13 +592,21 @@ void t41(unsigned short a) {
 }
 
 void t42() {
-// CHECK-LABEL: define void @t42
+// CHECK-LABEL: define void @t42(
   int flags;
   __asm mov flags, eax
 // CHECK: mov $0, eax
 // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags)
 }
 
+void t42b() {
+// CHECK-LABEL: define void @t42b(
+  int mxcsr;
+  __asm mov mxcsr, eax
+// CHECK: mov $0, eax
+// CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %mxcsr)
+}
+
 void t43() {
 // CHECK-LABEL: define void @t43
   C strct;

diff  --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 25be79ec2b1e..b5fbbc427a29 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1112,9 +1112,10 @@ bool X86AsmParser::ParseRegister(unsigned &RegNo,
   if (RegNo == 0)
     RegNo = MatchRegisterName(Tok.getString().lower());
 
-  // The "flags" register cannot be referenced directly.
+  // The "flags" and "mxcsr" registers cannot be referenced directly.
   // Treat it as an identifier instead.
-  if (isParsingInlineAsm() && isParsingIntelSyntax() && RegNo == X86::EFLAGS)
+  if (isParsingInlineAsm() && isParsingIntelSyntax() &&
+      (RegNo == X86::EFLAGS || RegNo == X86::MXCSR))
     RegNo = 0;
 
   if (!is64BitMode()) {


        


More information about the cfe-commits mailing list