1 //===-- jitcs_dumper.h - ----------------------------------------*- C++ -*-===//
4 //===----------------------------------------------------------------------===//
6 #ifndef _JITCS_DUMPER_H_
7 #define _JITCS_DUMPER_H_
9 #include "jitcs_adt_ref.h"
10 #include "jitcs_adt_refcounter.h"
11 #include "jitcs_base.h"
12 #include "jitcs_ids.h"
18 struct MemoryReference
;
19 struct VirtualRegister
;
26 IDumper(const IDumper
&) = delete;
27 IDumper
& operator =(const IDumper
&) = delete;
29 void write(const char*);
30 void writef(const char*, ...);
31 virtual void writev(const char*, va_list) = 0;
33 class PrintFDumper
: public IDumper
{
35 PrintFDumper() = default;
37 PrintFDumper(const PrintFDumper
&) = delete;
38 PrintFDumper
& operator =(const PrintFDumper
&) = delete;
40 /*[[override]]*/ virtual void writev(const char*, va_list);
42 class StringDumper
: public IDumper
{
44 StringDumper() = default;
46 StringDumper(const StringDumper
&) = delete;
47 StringDumper
& operator =(const StringDumper
&) = delete;
49 /*[[override]]*/ virtual void writev(const char*, va_list);
51 std::string
takeResult();
53 std::string _accumulator
;
56 class IMachineDumper
{
58 virtual void write(IDumper
&, Ref
<const Instruction
>) const;
59 virtual void write(IDumper
&, Ref
<const VirtualRegister
>) const;
61 virtual void write(IDumper
&, InsId
) const;
63 void write(IDumper
&, Ref
<const MemoryReference
>, bool vsib
) const;
66 class MachineDumper
: public IDumper
{
68 MachineDumper(IDumper
&, const IMachineInfo
&);
70 MachineDumper() = delete;
71 MachineDumper(const MachineDumper
&) = delete;
72 MachineDumper
& operator =(const MachineDumper
&) = delete;
75 void write(Ref
<const Instruction
>);
76 void write(Ref
<const VirtualRegister
>);
80 /*[[override]]*/ virtual void writev(const char*, va_list);
83 std::unique_ptr
<IMachineDumper
> _md
;
86 } // end namespace jitcs