MC: adjust text section flags for WoA
[oota-llvm.git] / include / llvm / MC / MCWin64EH.h
index de1e24767a1515d7d8470510f43e9eb8f17e21b5..d21e7620263f822f86bcf32efdd62f6608849bbf 100644 (file)
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file contains the declaration of the MCDwarfFile to support the dwarf
-// .file directive and the .loc directive.
+// This file contains declarations to support the Win64 Exception Handling
+// scheme in MC.
 //
 //===----------------------------------------------------------------------===//
 
 #define LLVM_MC_MCWIN64EH_H
 
 #include "llvm/Support/Win64EH.h"
+#include <cassert>
 #include <vector>
 
 namespace llvm {
+  class StringRef;
   class MCStreamer;
   class MCSymbol;
 
@@ -27,30 +29,31 @@ namespace llvm {
     typedef Win64EH::UnwindOpcodes OpType;
   private:
     OpType Operation;
+    MCSymbol *Label;
     unsigned Offset;
     unsigned Register;
   public:
-    MCWin64EHInstruction(OpType Op, unsigned Reg)
-      : Operation(Op), Offset(0), Register(Reg) {
-      assert(Op == Win64EH::UOP_PushNonVol);
+    MCWin64EHInstruction(OpType Op, MCSymbol *L, unsigned Reg)
+      : Operation(Op), Label(L), Offset(0), Register(Reg) {
+     assert(Op == Win64EH::UOP_PushNonVol);
     }
-    MCWin64EHInstruction(unsigned Size)
+    MCWin64EHInstruction(MCSymbol *L, unsigned Size)
       : Operation(Size>128 ? Win64EH::UOP_AllocLarge : Win64EH::UOP_AllocSmall),
-        Offset(Size) { }
-    MCWin64EHInstruction(OpType Op, unsigned Reg,
-                         unsigned Off)
-      : Operation(Op), Offset(Off), Register(Reg) {
+        Label(L), Offset(Size) { }
+    MCWin64EHInstruction(OpType Op, MCSymbol *L, unsigned Reg, unsigned Off)
+      : Operation(Op), Label(L), Offset(Off), Register(Reg) {
       assert(Op == Win64EH::UOP_SetFPReg ||
              Op == Win64EH::UOP_SaveNonVol ||
              Op == Win64EH::UOP_SaveNonVolBig ||
              Op == Win64EH::UOP_SaveXMM128 ||
              Op == Win64EH::UOP_SaveXMM128Big);
     }
-    MCWin64EHInstruction(OpType Op, bool Code)
-      : Operation(Op), Offset(Code ? 1 : 0) {
+    MCWin64EHInstruction(OpType Op, MCSymbol *L, bool Code)
+      : Operation(Op), Label(L), Offset(Code ? 1 : 0) {
       assert(Op == Win64EH::UOP_PushMachFrame);
     }
     OpType getOperation() const { return Operation; }
+    MCSymbol *getLabel() const { return Label; }
     unsigned getOffset() const { return Offset; }
     unsigned getSize() const { return Offset; }
     unsigned getRegister() const { return Register; }
@@ -58,16 +61,19 @@ namespace llvm {
   };
 
   struct MCWin64EHUnwindInfo {
-    MCWin64EHUnwindInfo() : Begin(0), End(0), ExceptionHandler(0),
-                            Function(0), PrologEnd(0), UnwindOnly(false),
-                            LastFrameInst(-1), ChainedParent(0),
-                            Instructions() {}
+    MCWin64EHUnwindInfo()
+      : Begin(nullptr), End(nullptr),ExceptionHandler(nullptr),
+        Function(nullptr), PrologEnd(nullptr), Symbol(nullptr),
+        HandlesUnwind(false), HandlesExceptions(false), LastFrameInst(-1),
+        ChainedParent(nullptr), Instructions() {}
     MCSymbol *Begin;
     MCSymbol *End;
     const MCSymbol *ExceptionHandler;
     const MCSymbol *Function;
     MCSymbol *PrologEnd;
-    bool UnwindOnly;
+    MCSymbol *Symbol;
+    bool HandlesUnwind;
+    bool HandlesExceptions;
     int LastFrameInst;
     MCWin64EHUnwindInfo *ChainedParent;
     std::vector<MCWin64EHInstruction> Instructions;
@@ -75,10 +81,12 @@ namespace llvm {
 
   class MCWin64EHUnwindEmitter {
   public:
+    static StringRef GetSectionSuffix(const MCSymbol *func);
     //
-    // This emits the unwind info section (.xdata in PE/COFF).
+    // This emits the unwind info sections (.pdata and .xdata in PE/COFF).
     //
     static void Emit(MCStreamer &streamer);
+    static void EmitUnwindInfo(MCStreamer &streamer, MCWin64EHUnwindInfo *info);
   };
 } // end namespace llvm