[llvm-commits] [llvm] r132045 - in /llvm/trunk: lib/MC/MCParser/COFFAsmParser.cpp test/MC/AsmParser/directive_seh.s

Charles Davis cdavis at mines.edu
Tue May 24 21:51:25 PDT 2011


Author: cdavis
Date: Tue May 24 23:51:25 2011
New Revision: 132045

URL: http://llvm.org/viewvc/llvm-project?rev=132045&view=rev
Log:
Add tests for .seh_savereg and .seh_savexmm parsing. Once again, fix the
buggy methods that parse these directives.

Modified:
    llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
    llvm/trunk/test/MC/AsmParser/directive_seh.s

Modified: llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=132045&r1=132044&r2=132045&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp Tue May 24 23:51:25 2011
@@ -303,6 +303,10 @@
   int64_t Off;
   if (ParseSEHRegisterNumber(Reg))
     return true;
+  if (getLexer().isNot(AsmToken::Comma))
+    return TokError("expected comma");
+
+  Lex();
   SMLoc startLoc = getLexer().getLoc();
   if (getParser().ParseAbsoluteExpression(Off))
     return true;
@@ -326,6 +330,10 @@
   int64_t Off;
   if (ParseSEHRegisterNumber(Reg))
     return true;
+  if (getLexer().isNot(AsmToken::Comma))
+    return TokError("expected comma");
+
+  Lex();
   SMLoc startLoc = getLexer().getLoc();
   if (getParser().ParseAbsoluteExpression(Off))
     return true;
@@ -387,14 +395,13 @@
 }
 
 bool COFFAsmParser::ParseSEHRegisterNumber(unsigned &RegNo) {
-  int64_t n;
   SMLoc startLoc = getLexer().getLoc();
-  if (getParser().ParseAbsoluteExpression(n)) {
+  if (getLexer().is(AsmToken::Percent)) {
     const TargetAsmInfo &asmInfo = getContext().getTargetAsmInfo();
     SMLoc endLoc;
     unsigned LLVMRegNo;
     if (getParser().getTargetParser().ParseRegister(LLVMRegNo,startLoc,endLoc))
-      return Error(startLoc, "expected register or number");
+      return true;
 
     // Check that this is a non-volatile register.
     const unsigned *NVRegs = asmInfo.getCalleeSavedRegs();
@@ -410,11 +417,15 @@
       return Error(startLoc,"register can't be represented in SEH unwind info");
     RegNo = SEHRegNo;
   }
-  else
+  else {
+    int64_t n;
+    if (getParser().ParseAbsoluteExpression(n))
+      return true;
+    if (n > 15)
+      return Error(startLoc, "register number is too high");
     RegNo = n;
+  }
 
-  if (RegNo > 15)
-    return Error(startLoc, "register number is too high");
   return false;
 }
 

Modified: llvm/trunk/test/MC/AsmParser/directive_seh.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_seh.s?rev=132045&r1=132044&r2=132045&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_seh.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_seh.s Tue May 24 23:51:25 2011
@@ -3,6 +3,8 @@
 # CHECK: .seh_proc func
 # CHECK: .seh_pushframe @code
 # CHECK: .seh_stackalloc 24
+# CHECK: .seh_savereg 6, 16
+# CHECK: .seh_savexmm 8, 0
 # CHECK: .seh_endprologue
 # CHECK: .seh_handler __C_specific_handler, @except
 # CHECK: .seh_endproc
@@ -15,6 +17,10 @@
     .seh_pushframe @code
     subq $24, %rsp
     .seh_stackalloc 24
+    movq %rsi, 16(%rsp)
+    .seh_savereg %rsi, 16
+    movups %xmm8, (%rsp)
+    .seh_savexmm %xmm8, 0
     .seh_endprologue
     .seh_handler __C_specific_handler, @except
     addq $24, %rsp





More information about the llvm-commits mailing list