From 0e30f02f44185b43d279b7b3ef8b3356f2b5c7cb Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Wed, 18 May 2011 04:58:05 +0000 Subject: [PATCH] Implement the Win64 EH directive methods for the assembly language streamer. GAS has no such directives (not even mingw-w64 GAS has them), so I took creative license with their names in assembly. I prefixed them all with "w64_" to avoid namespace collisions, for example. If I discover that GAS has taken a different approach, I'll change ours to match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131525 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCAsmStreamer.cpp | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index ee68a377e31..41a821dbb9d 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -208,6 +208,15 @@ public: virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset); virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment); + virtual void EmitWin64EHStartProc(MCSymbol *Symbol, MCSymbol *EHandler = 0); + virtual void EmitWin64EHEndProc(); + virtual void EmitWin64EHPushReg(int64_t Register); + virtual void EmitWin64EHSetFrame(int64_t Register, int64_t Offset); + virtual void EmitWin64EHAllocStack(int64_t Size); + virtual void EmitWin64EHSaveReg(int64_t Register, int64_t Offset); + virtual void EmitWin64EHPushFrame(bool Code); + virtual void EmitWin64EHEndProlog(); + virtual void EmitFnStart(); virtual void EmitFnEnd(); virtual void EmitCantUnwind(); @@ -915,6 +924,74 @@ void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) { EmitEOL(); } +void MCAsmStreamer::EmitWin64EHStartProc(MCSymbol *Symbol, MCSymbol *EHandler) +{ + //MCStreamer::EmitWin64EHStartProc(Symbol, EHandler); + + OS << ".w64_startproc " << *Symbol; + if (EHandler) + OS << ", " << *EHandler; + EmitEOL(); +} + +void MCAsmStreamer::EmitWin64EHEndProc() +{ + //MCStreamer::EmitWin64EHEndProc(); + + OS << "\t.w64_endproc"; + EmitEOL(); +} + +void MCAsmStreamer::EmitWin64EHPushReg(int64_t Register) +{ + //MCStreamer::EmitWin64EHPushReg(Register); + + OS << "\t.w64_pushreg " << Register; + EmitEOL(); +} + +void MCAsmStreamer::EmitWin64EHSetFrame(int64_t Register, int64_t Offset) +{ + //MCStreamer::EmitWin64EHSetFrame(Register, Offset); + + OS << "\t.w64_setframe " << Register << ", " << Offset; + EmitEOL(); +} + +void MCAsmStreamer::EmitWin64EHAllocStack(int64_t Size) +{ + //MCStremaer::EmitWin64EHAllocStack(Size); + + OS << "\t.w64_allocstack " << Size; + EmitEOL(); +} + +void MCAsmStreamer::EmitWin64EHSaveReg(int64_t Register, int64_t Offset) +{ + //MCStreamer::EmitWin64EHSaveReg(Register, Offset) + + OS << "\t.w64_savereg " << Register << ", " << Offset; + EmitEOL(); +} + +void MCAsmStreamer::EmitWin64EHPushFrame(bool Code) +{ + //MCStreamer::EmitWin64EHPushFrame(Code); + + OS << "\t.w64_pushframe"; + if (Code) + OS << " " << "code"; + EmitEOL(); +} + +void MCAsmStreamer::EmitWin64EHEndProlog(void) +{ + //MCStreamer::EmitWin64EHEndProlog(); + + OS << "\t.w64_endprolog"; + EmitEOL(); +} + void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) { raw_ostream &OS = GetCommentOS(); SmallString<256> Code;