summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Davis <cdavis@mines.edu>2011-05-25 04:51:25 +0000
committerCharles Davis <cdavis@mines.edu>2011-05-25 04:51:25 +0000
commit575630ccb8a267405146a0c14fba7a5b74e1e4c3 (patch)
treed8bb3add92df01b09aa18ff925a773d4daddffa5
parentda86a0828495948efd509262167a7f390cda3216 (diff)
downloadllvm-575630ccb8a267405146a0c14fba7a5b74e1e4c3.tar.gz
llvm-575630ccb8a267405146a0c14fba7a5b74e1e4c3.tar.bz2
llvm-575630ccb8a267405146a0c14fba7a5b74e1e4c3.tar.xz
Add tests for .seh_savereg and .seh_savexmm parsing. Once again, fix the
buggy methods that parse these directives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132045 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/MC/MCParser/COFFAsmParser.cpp23
-rw-r--r--test/MC/AsmParser/directive_seh.s6
2 files changed, 23 insertions, 6 deletions
diff --git a/lib/MC/MCParser/COFFAsmParser.cpp b/lib/MC/MCParser/COFFAsmParser.cpp
index 540df377bb..7fde4fec38 100644
--- a/lib/MC/MCParser/COFFAsmParser.cpp
+++ b/lib/MC/MCParser/COFFAsmParser.cpp
@@ -303,6 +303,10 @@ bool COFFAsmParser::ParseSEHDirectiveSaveReg(StringRef, SMLoc L) {
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 @@ bool COFFAsmParser::ParseSEHDirectiveSaveXMM(StringRef, SMLoc L) {
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::ParseAtUnwindOrAtExcept(bool &unwind, bool &except) {
}
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 @@ bool COFFAsmParser::ParseSEHRegisterNumber(unsigned &RegNo) {
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;
}
diff --git a/test/MC/AsmParser/directive_seh.s b/test/MC/AsmParser/directive_seh.s
index e14be4367a..8b27542fb3 100644
--- a/test/MC/AsmParser/directive_seh.s
+++ b/test/MC/AsmParser/directive_seh.s
@@ -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 @@ func:
.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