First effort to revive BasicBlock and Function classes and
[jitcs.git] / include / jitcs_dumper.h
blob80db2b8e7ee7b88a06e16534e4b3226f9b2dae85
1 //===-- jitcs_dumper.h - ----------------------------------------*- C++ -*-===//
2 //
3 //
4 //===----------------------------------------------------------------------===//
6 #ifndef _JITCS_DUMPER_H_
7 #define _JITCS_DUMPER_H_
9 #include "jitcs_adt_ref.h"
10 #include "jitcs_base.h"
11 #include <memory>
12 #include <stdarg.h>
14 namespace jitcs {
15 struct Instruction;
16 struct VirtualRegister;
18 class IDumper {
19 protected:
20 IDumper() = default;
21 private:
22 IDumper(const IDumper&) = delete;
23 IDumper& operator =(const IDumper&) = delete;
24 public:
25 void write(const char*);
26 void writef(const char*, ...);
27 virtual void writev(const char*, va_list) = 0;
29 class PrintFDumper : public IDumper {
30 public:
31 PrintFDumper() = default;
32 private:
33 PrintFDumper(const PrintFDumper&) = delete;
34 PrintFDumper& operator =(const PrintFDumper&) = delete;
35 public:
36 /*[[override]]*/ virtual void writev(const char*, va_list);
39 class IMachineDumper : public IDumper {
40 protected:
41 IMachineDumper(std::unique_ptr<IDumper> &&);
42 private:
43 IMachineDumper() = delete;
44 IMachineDumper(const IMachineDumper&) = delete;
45 IMachineDumper& operator =(const IMachineDumper&) = delete;
46 public:
47 using IDumper::write;
48 virtual void write(Ref<Instruction>) = 0;
49 virtual void write(Ref<VirtualRegister>) = 0;
51 /*[[override]]*/ virtual void writev(const char*, va_list);
52 private:
53 std::unique_ptr<IDumper> _out;
56 } // end namespace jitcs
58 #endif
59 // _JITCS_DUMPER_H_