The check to see if an item was already on the heap was randomly hitting.
[jitcs.git] / include / jitcs_dumper.h
blobc2d69f2f12b827baa8d53c939bb463d8d4c4179a
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_adt_refcounter.h"
11 #include "jitcs_base.h"
12 #include "jitcs_ids.h"
13 #include <memory>
14 #include <stdarg.h>
16 namespace jitcs {
17 struct Instruction;
18 struct MemoryReference;
19 struct VirtualRegister;
20 class IMachineInfo;
22 class IDumper {
23 protected:
24 IDumper() = default;
25 private:
26 IDumper(const IDumper&) = delete;
27 IDumper& operator =(const IDumper&) = delete;
28 public:
29 void write(const char*);
30 void writef(const char*, ...);
31 virtual void writev(const char*, va_list) = 0;
33 class PrintFDumper : public IDumper {
34 public:
35 PrintFDumper() = default;
36 private:
37 PrintFDumper(const PrintFDumper&) = delete;
38 PrintFDumper& operator =(const PrintFDumper&) = delete;
39 public:
40 /*[[override]]*/ virtual void writev(const char*, va_list);
42 class StringDumper : public IDumper {
43 public:
44 StringDumper() = default;
45 private:
46 StringDumper(const StringDumper&) = delete;
47 StringDumper& operator =(const StringDumper&) = delete;
48 public:
49 /*[[override]]*/ virtual void writev(const char*, va_list);
50 public:
51 std::string takeResult();
52 private:
53 std::string _accumulator;
56 class IMachineDumper {
57 public:
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 {
67 public:
68 MachineDumper(IDumper&, const IMachineInfo&);
69 private:
70 MachineDumper() = delete;
71 MachineDumper(const MachineDumper&) = delete;
72 MachineDumper& operator =(const MachineDumper&) = delete;
73 public:
74 using IDumper::write;
75 void write(Ref<const Instruction>);
76 void write(Ref<const VirtualRegister>);
78 void write(InsId);
80 /*[[override]]*/ virtual void writev(const char*, va_list);
81 private:
82 IDumper& _out;
83 std::unique_ptr<IMachineDumper> _md;
86 } // end namespace jitcs
88 #endif
89 // _JITCS_DUMPER_H_