Files
revng-revng/include/revng/Lift/SelfReferencingDbgAnnotationWriter.h
Alessandro Di Federico f8bd4c3bac Move around some files in preparation for libtcg
* Make the following private headers public:
  * Lift/CPUStateAccessAnalysisPass.h
  * Lift/CSVOffsets.h
  * Lift/PTCDump.h
  * Lift/VariableManager.h
* Move from revngSupport to revngLift:
  * IRAnnotators.{h,cpp}
  * SelfReferencingDbgAnnotationWriter.{h,cpp}
* Move from revngSupport to revngModel:
  * FunctionTags.{h,cpp}
  * ProgramCounterHandler.{h,cpp}
* Move from revngSupport to revngRecompile:
  * OriginalAssemblyAnnotationWriter.{h,cpp}
2025-10-24 15:34:11 +02:00

55 lines
1.7 KiB
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/IR/AssemblyAnnotationWriter.h"
#include "llvm/IR/LLVMContext.h"
/// Annotate all instructions with self-referencing debug information
class SelfReferencingDbgAnnotationWriter
: public llvm::AssemblyAnnotationWriter {
public:
SelfReferencingDbgAnnotationWriter(llvm::LLVMContext &Context,
llvm::AssemblyAnnotationWriter *InnerAAW) :
Context(Context), InnerAAW(InnerAAW), DbgKind(Context.getMDKindID("dbg")) {}
~SelfReferencingDbgAnnotationWriter() override = default;
virtual void emitFunctionAnnot(const llvm::Function *F,
llvm::formatted_raw_ostream &Output) override {
if (InnerAAW != nullptr)
InnerAAW->emitFunctionAnnot(F, Output);
}
virtual void
emitBasicBlockStartAnnot(const llvm::BasicBlock *BB,
llvm::formatted_raw_ostream &Output) override {
if (InnerAAW != nullptr)
InnerAAW->emitBasicBlockStartAnnot(BB, Output);
}
virtual void
emitBasicBlockEndAnnot(const llvm::BasicBlock *BB,
llvm::formatted_raw_ostream &Output) override {
if (InnerAAW != nullptr)
InnerAAW->emitBasicBlockStartAnnot(BB, Output);
}
virtual void
emitInstructionAnnot(const llvm::Instruction *O,
llvm::formatted_raw_ostream &Output) override;
virtual void printInfoComment(const llvm::Value &V,
llvm::formatted_raw_ostream &Output) override {
if (InnerAAW != nullptr)
InnerAAW->printInfoComment(V, Output);
}
private:
llvm::LLVMContext &Context;
llvm::AssemblyAnnotationWriter *InnerAAW;
unsigned DbgKind;
};