- class MCWin64EHInstruction {
- public:
- typedef Win64EH::UnwindOpcodes OpType;
- private:
- OpType Operation;
- unsigned Offset;
- MachineLocation Destination;
- MachineLocation Source;
- public:
- MCWin64EHInstruction(OpType Op, unsigned Register)
- : Operation(Op), Offset(0), Destination(0), Source(Register) {
- assert(Op == Win64EH::UOP_PushNonVol);
- }
- MCWin64EHInstruction(unsigned Size)
- : Operation(Size>128 ? Win64EH::UOP_AllocLarge : Win64EH::UOP_AllocSmall),
- Offset(Size) { }
- MCWin64EHInstruction(unsigned Register, unsigned Off)
- : Operation(Win64EH::UOP_SetFPReg), Offset(Off), Destination(Register) { }
- MCWin64EHInstruction(OpType Op, const MachineLocation &D,
- unsigned S)
- : Operation(Op), Destination(D), Source(S) {
- assert(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) {
- assert(Op == Win64EH::UOP_PushMachFrame);
- }
- OpType getOperation() const { return Operation; }
- unsigned getOffset() const { return Offset; }
- unsigned getSize() const { return Offset; }
- bool isPushCodeFrame() const { return Offset == 1; }
- const MachineLocation &getDestination() const { return Destination; }
- const MachineLocation &getSource() const { return Source; }
- };
+namespace Win64EH {
+struct Instruction {
+ static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg) {
+ return WinEH::Instruction(Win64EH::UOP_PushNonVol, L, Reg, -1);
+ }
+ static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size) {
+ return WinEH::Instruction(Size > 128 ? UOP_AllocLarge : UOP_AllocSmall, L,
+ -1, Size);
+ }
+ static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code) {
+ return WinEH::Instruction(UOP_PushMachFrame, L, -1, Code ? 1 : 0);
+ }
+ static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg,
+ unsigned Offset) {
+ return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveNonVolBig
+ : UOP_SaveNonVol,
+ L, Reg, Offset);
+ }
+ static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg,
+ unsigned Offset) {
+ return WinEH::Instruction(Offset > 512 * 1024 - 8 ? UOP_SaveXMM128Big
+ : UOP_SaveXMM128,
+ L, Reg, Offset);
+ }
+ static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off) {
+ return WinEH::Instruction(UOP_SetFPReg, L, Reg, Off);
+ }
+};