[llvm-commits] [llvm] r131623 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCStreamer.cpp

Charles Davis cdavis at mines.edu
Wed May 18 19:49:00 PDT 2011


Author: cdavis
Date: Wed May 18 21:49:00 2011
New Revision: 131623

URL: http://llvm.org/viewvc/llvm-project?rev=131623&view=rev
Log:
Implement the StartProc and EndProc Win64 EH methods on the base MCStreamer.

Based largely on Rafael Espindola's work on CFI. Other methods soon to follow.

Modified:
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/lib/MC/MCStreamer.cpp

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=131623&r1=131622&r2=131623&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Wed May 18 21:49:00 2011
@@ -18,6 +18,7 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/MC/MCDirectives.h"
 #include "llvm/MC/MCDwarf.h"
+#include "llvm/MC/MCWin64EH.h"
 
 namespace llvm {
   class MCAsmInfo;
@@ -57,6 +58,10 @@
     MCDwarfFrameInfo *getCurrentFrameInfo();
     void EnsureValidFrame();
 
+    std::vector<MCWin64EHUnwindInfo> W64UnwindInfos;
+    MCWin64EHUnwindInfo *getCurrentW64UnwindInfo();
+    void EnsureValidW64UnwindInfo();
+
     const MCSymbol* LastNonPrivate;
 
     /// SectionStack - This is stack of current and previous section

Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131623&r1=131622&r2=131623&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Wed May 18 21:49:00 2011
@@ -310,16 +310,37 @@
   CurFrame->Instructions.push_back(Instruction);
 }
 
-void MCStreamer::EmitWin64EHStartProc(MCSymbol *Symbol, MCSymbol *EHandler)
-{
-  errs() << "Not implemented yet\n";
-  abort();
-}
-
-void MCStreamer::EmitWin64EHEndProc()
-{
-  errs() << "Not implemented yet\n";
-  abort();
+MCWin64EHUnwindInfo *MCStreamer::getCurrentW64UnwindInfo() {
+  if (W64UnwindInfos.empty())
+    return NULL;
+  return &W64UnwindInfos.back();
+}
+
+void MCStreamer::EnsureValidW64UnwindInfo() {
+  MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
+  if (!CurFrame || CurFrame->End)
+    report_fatal_error("No open Win64 EH frame function!");
+}
+
+void MCStreamer::EmitWin64EHStartProc(MCSymbol *Symbol, MCSymbol *EHandler) {
+  MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
+  if (CurFrame && !CurFrame->End)
+    report_fatal_error("Starting a function before ending the previous one!");
+  MCWin64EHUnwindInfo Frame;
+  Frame.Begin = getContext().CreateTempSymbol();
+  Frame.Function = Symbol;
+  Frame.ExceptionHandler = EHandler;
+  EmitLabel(Frame.Begin);
+  W64UnwindInfos.push_back(Frame);
+}
+
+void MCStreamer::EmitWin64EHEndProc() {
+  EnsureValidW64UnwindInfo();
+  MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
+  if (CurFrame->Chained)
+    report_fatal_error("Not all chained regions terminated!");
+  CurFrame->End = getContext().CreateTempSymbol();
+  EmitLabel(CurFrame->End);
 }
 
 void MCStreamer::EmitWin64EHStartChained()





More information about the llvm-commits mailing list