mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
Add tests for .seh_setframe and .seh_handlerdata parsing. Fix issues with
them. I had to add a special SwitchSectionNoChange method to MCStreamer just for .seh_handlerdata. If this isn't OK, please let me know, and I'll find some other way to fix .seh_handlerdata streaming. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -195,6 +195,17 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// SwitchSectionNoChange - Set the current section where code is being
|
||||||
|
/// emitted to @p Section. This is required to update CurSection. This
|
||||||
|
/// version does not call ChangeSection.
|
||||||
|
void SwitchSectionNoChange(const MCSection *Section) {
|
||||||
|
assert(Section && "Cannot switch to a null section!");
|
||||||
|
const MCSection *curSection = SectionStack.back().first;
|
||||||
|
SectionStack.back().second = curSection;
|
||||||
|
if (Section != curSection)
|
||||||
|
SectionStack.back().first = Section;
|
||||||
|
}
|
||||||
|
|
||||||
/// InitSections - Create the default sections and set the initial one.
|
/// InitSections - Create the default sections and set the initial one.
|
||||||
virtual void InitSections() = 0;
|
virtual void InitSections() = 0;
|
||||||
|
|
||||||
|
@@ -973,6 +973,15 @@ void MCAsmStreamer::EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
|
|||||||
void MCAsmStreamer::EmitWin64EHHandlerData() {
|
void MCAsmStreamer::EmitWin64EHHandlerData() {
|
||||||
MCStreamer::EmitWin64EHHandlerData();
|
MCStreamer::EmitWin64EHHandlerData();
|
||||||
|
|
||||||
|
// Switch sections. Don't call SwitchSection directly, because that will
|
||||||
|
// cause the section switch to be visible in the emitted assembly.
|
||||||
|
// We only do this so the section switch that terminates the handler
|
||||||
|
// data block is visible.
|
||||||
|
const MCSection *xdataSect =
|
||||||
|
getContext().getTargetAsmInfo().getWin64EHTableSection();
|
||||||
|
if (xdataSect)
|
||||||
|
SwitchSectionNoChange(xdataSect);
|
||||||
|
|
||||||
OS << "\t.seh_handlerdata";
|
OS << "\t.seh_handlerdata";
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
@@ -266,6 +266,10 @@ bool COFFAsmParser::ParseSEHDirectiveSetFrame(StringRef, SMLoc L) {
|
|||||||
int64_t Off;
|
int64_t Off;
|
||||||
if (ParseSEHRegisterNumber(Reg))
|
if (ParseSEHRegisterNumber(Reg))
|
||||||
return true;
|
return true;
|
||||||
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
|
return TokError("you must specify a stack pointer offset");
|
||||||
|
|
||||||
|
Lex();
|
||||||
SMLoc startLoc = getLexer().getLoc();
|
SMLoc startLoc = getLexer().getLoc();
|
||||||
if (getParser().ParseAbsoluteExpression(Off))
|
if (getParser().ParseAbsoluteExpression(Off))
|
||||||
return true;
|
return true;
|
||||||
@@ -304,7 +308,7 @@ bool COFFAsmParser::ParseSEHDirectiveSaveReg(StringRef, SMLoc L) {
|
|||||||
if (ParseSEHRegisterNumber(Reg))
|
if (ParseSEHRegisterNumber(Reg))
|
||||||
return true;
|
return true;
|
||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("expected comma");
|
return TokError("you must specify an offset on the stack");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
SMLoc startLoc = getLexer().getLoc();
|
SMLoc startLoc = getLexer().getLoc();
|
||||||
@@ -331,7 +335,7 @@ bool COFFAsmParser::ParseSEHDirectiveSaveXMM(StringRef, SMLoc L) {
|
|||||||
if (ParseSEHRegisterNumber(Reg))
|
if (ParseSEHRegisterNumber(Reg))
|
||||||
return true;
|
return true;
|
||||||
if (getLexer().isNot(AsmToken::Comma))
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
return TokError("expected comma");
|
return TokError("you must specify an offset on the stack");
|
||||||
|
|
||||||
Lex();
|
Lex();
|
||||||
SMLoc startLoc = getLexer().getLoc();
|
SMLoc startLoc = getLexer().getLoc();
|
||||||
|
@@ -5,8 +5,13 @@
|
|||||||
# CHECK: .seh_stackalloc 24
|
# CHECK: .seh_stackalloc 24
|
||||||
# CHECK: .seh_savereg 6, 16
|
# CHECK: .seh_savereg 6, 16
|
||||||
# CHECK: .seh_savexmm 8, 0
|
# CHECK: .seh_savexmm 8, 0
|
||||||
|
# CHECK: .seh_pushreg 3
|
||||||
|
# CHECK: .seh_setframe 3, 0
|
||||||
# CHECK: .seh_endprologue
|
# CHECK: .seh_endprologue
|
||||||
# CHECK: .seh_handler __C_specific_handler, @except
|
# CHECK: .seh_handler __C_specific_handler, @except
|
||||||
|
# CHECK-NOT: .section{{.*}}.xdata
|
||||||
|
# CHECK: .seh_handlerdata
|
||||||
|
# CHECK: .text
|
||||||
# CHECK: .seh_endproc
|
# CHECK: .seh_endproc
|
||||||
|
|
||||||
.text
|
.text
|
||||||
@@ -21,8 +26,17 @@ func:
|
|||||||
.seh_savereg %rsi, 16
|
.seh_savereg %rsi, 16
|
||||||
movups %xmm8, (%rsp)
|
movups %xmm8, (%rsp)
|
||||||
.seh_savexmm %xmm8, 0
|
.seh_savexmm %xmm8, 0
|
||||||
|
pushq %rbx
|
||||||
|
.seh_pushreg 3
|
||||||
|
mov %rsp, %rbx
|
||||||
|
.seh_setframe 3, 0
|
||||||
.seh_endprologue
|
.seh_endprologue
|
||||||
.seh_handler __C_specific_handler, @except
|
.seh_handler __C_specific_handler, @except
|
||||||
|
.seh_handlerdata
|
||||||
|
.long 0
|
||||||
|
.text
|
||||||
|
lea (%rbx), %rsp
|
||||||
|
pop %rbx
|
||||||
addq $24, %rsp
|
addq $24, %rsp
|
||||||
ret
|
ret
|
||||||
.seh_endproc
|
.seh_endproc
|
||||||
|
Reference in New Issue
Block a user