1 //===- MCWin64EH.h - Machine Code Win64 EH support --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the MCDwarfFile to support the dwarf
11 // .file directive and the .loc directive.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_MC_MCWIN64EH_H
16 #define LLVM_MC_MCWIN64EH_H
18 #include "llvm/CodeGen/MachineLocation.h" // FIXME
19 #include "llvm/Support/Win64EH.h"
26 class MCWin64EHInstruction {
28 typedef Win64EH::UnwindOpcodes OpType;
32 MachineLocation Destination;
33 MachineLocation Source;
35 MCWin64EHInstruction(OpType Op, unsigned Register)
36 : Operation(Op), Offset(0), Destination(0), Source(S) {
37 assert(Op == Win64EH::UOP_PushNonVol);
39 MCWin64EHInstruction(unsigned Size)
40 : Operation(Size>128 ? Win64EH::UOP_AllocLarge : Win64EH::UOP_AllocSmall),
42 MCWin64EHInstruction(unsigned Register, unsigned Off)
43 : Operation(Win64EH::UOP_SetFPReg), Offset(Off), Destination(Register) { }
44 MCWin64EHInstruction(OpType Op, const MachineLocation &D,
46 : Operation(Op), Destination(D), Source(S) {
47 assert(Op == Win64EH::UOP_SaveNonVol ||
48 Op == Win64EH::UOP_SaveNonVolBig ||
49 Op == Win64EH::UOP_SaveXMM128 ||
50 Op == Win64EH::UOP_SaveXMM128Big);
52 MCWin64EHInstruction(OpType Op, bool Code)
53 : Operation(Op), Offset(Code ? 1 : 0) {
54 assert(Op == Win64EH::UOP_PushMachFrame);
56 OpType getOperation() const { return Operation; }
57 unsigned getOffset() const { return Offset; }
58 unsigned getSize() const { return Offset; }
59 bool isPushCodeFrame() const { return Offset == 1; }
60 const MachineLocation &getDestination() const { return Destination; }
61 const MachineLocation &getSource() const { return Source; }
64 struct MCWin64EHUnwindInfo {
65 MCWin64EHUnwindInfo() : Begin(0), End(0), ExceptionHandler(0), Lsda(0),
66 Function(0), UnwindOnly(false), LsdaSize(0),
67 PrologSize(0), LastFrameInst(-1), Chained(false)
71 const MCSymbol *ExceptionHandler;
73 const MCSymbol *Function;
79 std::vector<MCWin64EHInstruction> Instructions;
82 class MCWin64EHUnwindEmitter {
85 // This emits the unwind info section (.xdata in PE/COFF).
87 static void Emit(MCStreamer &streamer);
89 } // end namespace llvm