1 //===- X86AsmInstrumentation.h - Instrument X86 inline assembly -*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_LIB_TARGET_X86_ASMPARSER_X86ASMINSTRUMENTATION_H 11 #define LLVM_LIB_TARGET_X86_ASMPARSER_X86ASMINSTRUMENTATION_H 12 13 #include "llvm/ADT/SmallVector.h" 14 #include <memory> 15 16 namespace llvm { 17 18 class MCContext; 19 class MCInst; 20 class MCInstrInfo; 21 class MCParsedAsmOperand; 22 class MCStreamer; 23 class MCSubtargetInfo; 24 class MCTargetOptions; 25 class X86AsmInstrumentation; 26 27 X86AsmInstrumentation * 28 CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions, 29 const MCContext &Ctx, 30 const MCSubtargetInfo *&STI); 31 32 class X86AsmInstrumentation { 33 public: 34 virtual ~X86AsmInstrumentation(); 35 36 // Sets frame register corresponding to a current frame. SetInitialFrameRegister(unsigned RegNo)37 void SetInitialFrameRegister(unsigned RegNo) { 38 InitialFrameReg = RegNo; 39 } 40 41 // Tries to instrument and emit instruction. 42 virtual void InstrumentAndEmitInstruction( 43 const MCInst &Inst, 44 SmallVectorImpl<std::unique_ptr<MCParsedAsmOperand>> &Operands, 45 MCContext &Ctx, const MCInstrInfo &MII, MCStreamer &Out, 46 bool PrintSchedInfoEnabled); 47 48 protected: 49 friend X86AsmInstrumentation * 50 CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions, 51 const MCContext &Ctx, 52 const MCSubtargetInfo *&STI); 53 54 X86AsmInstrumentation(const MCSubtargetInfo *&STI); 55 56 unsigned GetFrameRegGeneric(const MCContext &Ctx, MCStreamer &Out); 57 58 void EmitInstruction(MCStreamer &Out, const MCInst &Inst, 59 bool PrintSchedInfoEnabled = false); 60 61 const MCSubtargetInfo *&STI; 62 63 unsigned InitialFrameReg = 0; 64 }; 65 66 } // end namespace llvm 67 68 #endif // LLVM_LIB_TARGET_X86_ASMPARSER_X86ASMINSTRUMENTATION_H 69