mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-04 17:47:58 +00:00
Add a test for the .seh_handler directive. Fix problems with the parsing
method exposed by the test. While we're at it, simplify the .seh_proc parsing method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132028 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
56926a3961
commit
309213279e
@ -184,20 +184,17 @@ bool COFFAsmParser::ParseDirectiveEndef(StringRef, SMLoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool COFFAsmParser::ParseSEHDirectiveStartProc(StringRef, SMLoc) {
|
bool COFFAsmParser::ParseSEHDirectiveStartProc(StringRef, SMLoc) {
|
||||||
const MCExpr *e;
|
StringRef SymbolID;
|
||||||
const MCSymbolRefExpr *funcExpr;
|
if (getParser().ParseIdentifier(SymbolID))
|
||||||
SMLoc startLoc = getLexer().getLoc();
|
|
||||||
if (getParser().ParseExpression(e))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(funcExpr = dyn_cast<MCSymbolRefExpr>(e)))
|
|
||||||
return Error(startLoc, "expected symbol");
|
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
|
|
||||||
|
MCSymbol *Symbol = getContext().GetOrCreateSymbol(SymbolID);
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
getStreamer().EmitWin64EHStartProc(&funcExpr->getSymbol());
|
getStreamer().EmitWin64EHStartProc(Symbol);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,29 +217,28 @@ bool COFFAsmParser::ParseSEHDirectiveEndChained(StringRef, SMLoc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool COFFAsmParser::ParseSEHDirectiveHandler(StringRef, SMLoc) {
|
bool COFFAsmParser::ParseSEHDirectiveHandler(StringRef, SMLoc) {
|
||||||
const MCExpr *e;
|
StringRef SymbolID;
|
||||||
const MCSymbolRefExpr *funcExpr;
|
if (getParser().ParseIdentifier(SymbolID))
|
||||||
SMLoc startLoc = getLexer().getLoc();
|
|
||||||
if (getParser().ParseExpression(e))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(funcExpr = dyn_cast<MCSymbolRefExpr>(e)))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return Error(startLoc, "expected symbol");
|
return TokError("you must specify one or both of @unwind or @except");
|
||||||
|
Lex();
|
||||||
bool unwind = false, except = false;
|
bool unwind = false, except = false;
|
||||||
startLoc = getLexer().getLoc();
|
if (ParseAtUnwindOrAtExcept(unwind, except))
|
||||||
if (!ParseAtUnwindOrAtExcept(unwind, except))
|
return true;
|
||||||
return Error(startLoc,"you must specify one or both of @unwind or @except");
|
|
||||||
if (getLexer().is(AsmToken::Comma)) {
|
if (getLexer().is(AsmToken::Comma)) {
|
||||||
Lex();
|
Lex();
|
||||||
if (!ParseAtUnwindOrAtExcept(unwind, except))
|
if (ParseAtUnwindOrAtExcept(unwind, except))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in directive");
|
return TokError("unexpected token in directive");
|
||||||
|
|
||||||
|
MCSymbol *handler = getContext().GetOrCreateSymbol(SymbolID);
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
getStreamer().EmitWin64EHHandler(&funcExpr->getSymbol(), unwind, except);
|
getStreamer().EmitWin64EHHandler(handler, unwind, except);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,12 +368,15 @@ bool COFFAsmParser::ParseSEHDirectiveEndProlog(StringRef, SMLoc) {
|
|||||||
|
|
||||||
bool COFFAsmParser::ParseAtUnwindOrAtExcept(bool &unwind, bool &except) {
|
bool COFFAsmParser::ParseAtUnwindOrAtExcept(bool &unwind, bool &except) {
|
||||||
StringRef identifier;
|
StringRef identifier;
|
||||||
|
if (getLexer().isNot(AsmToken::At))
|
||||||
|
return TokError("a handler attribute must begin with '@'");
|
||||||
SMLoc startLoc = getLexer().getLoc();
|
SMLoc startLoc = getLexer().getLoc();
|
||||||
if (!getParser().ParseIdentifier(identifier))
|
Lex();
|
||||||
|
if (getParser().ParseIdentifier(identifier))
|
||||||
return Error(startLoc, "expected @unwind or @except");
|
return Error(startLoc, "expected @unwind or @except");
|
||||||
if (identifier == "@unwind")
|
if (identifier == "unwind")
|
||||||
unwind = true;
|
unwind = true;
|
||||||
else if (identifier == "@except")
|
else if (identifier == "except")
|
||||||
except = true;
|
except = true;
|
||||||
else
|
else
|
||||||
return Error(startLoc, "expected @unwind or @except");
|
return Error(startLoc, "expected @unwind or @except");
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# RUN: llvm-mc -triple x86_64-pc-win32 %s | FileCheck %s
|
# RUN: llvm-mc -triple x86_64-pc-win32 %s | FileCheck %s
|
||||||
|
|
||||||
# CHECK: .seh_proc func
|
# CHECK: .seh_proc func
|
||||||
# CHECK: .seh_stackalloc 8
|
# CHECK: .seh_stackalloc 24
|
||||||
# CHECK: .seh_endprologue
|
# CHECK: .seh_endprologue
|
||||||
|
# CHECK: .seh_handler __C_specific_handler, @except
|
||||||
# CHECK: .seh_endproc
|
# CHECK: .seh_endproc
|
||||||
|
|
||||||
.text
|
.text
|
||||||
@ -10,9 +11,10 @@
|
|||||||
.def func; .scl 2; .type 32; .endef
|
.def func; .scl 2; .type 32; .endef
|
||||||
.seh_proc func
|
.seh_proc func
|
||||||
func:
|
func:
|
||||||
subq $8, %rsp
|
subq $24, %rsp
|
||||||
.seh_stackalloc 8
|
.seh_stackalloc 24
|
||||||
.seh_endprologue
|
.seh_endprologue
|
||||||
addq $8, %rsp
|
.seh_handler __C_specific_handler, @except
|
||||||
|
addq $24, %rsp
|
||||||
ret
|
ret
|
||||||
.seh_endproc
|
.seh_endproc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user