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 15#include <memory> 16 17namespace llvm { 18 19class MCContext; 20class MCInst; 21class MCInstrInfo; 22class MCParsedAsmOperand; 23class MCStreamer; 24class MCSubtargetInfo; 25class MCTargetOptions; 26 27class X86AsmInstrumentation; 28 29X86AsmInstrumentation * 30CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions, 31 const MCContext &Ctx, 32 const MCSubtargetInfo *&STI); 33 34class X86AsmInstrumentation { 35public: 36 virtual ~X86AsmInstrumentation(); 37 38 // Sets frame register corresponding to a current frame. 39 void SetInitialFrameRegister(unsigned RegNo) { 40 InitialFrameReg = RegNo; 41 } 42 43 // Tries to instrument and emit instruction. 44 virtual void InstrumentAndEmitInstruction( 45 const MCInst &Inst, 46 SmallVectorImpl<std::unique_ptr<MCParsedAsmOperand> > &Operands, 47 MCContext &Ctx, const MCInstrInfo &MII, MCStreamer &Out); 48 49protected: 50 friend X86AsmInstrumentation * 51 CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions, 52 const MCContext &Ctx, 53 const MCSubtargetInfo *&STI); 54 55 X86AsmInstrumentation(const MCSubtargetInfo *&STI); 56 57 unsigned GetFrameRegGeneric(const MCContext &Ctx, MCStreamer &Out); 58 59 void EmitInstruction(MCStreamer &Out, const MCInst &Inst); 60 61 const MCSubtargetInfo *&STI; 62 63 unsigned InitialFrameReg; 64}; 65 66} // End llvm namespace 67 68#endif 69