The check to see if an item was already on the heap was randomly hitting.
[jitcs.git] / include / jitcs_bblock.h
blob745b67e9580ac7f3737f7168c178c38a505c4ba4
1 //===-- jitcs_bblock.h - a representation of a basic block ------*- C++ -*-===//
2 //
3 // The BasicBlock class is an interface to the actual basic block used inside
4 // the library. All implementation details are hidden from outside users.
5 // Enumeration of predecessors, successors and instructions is possible, but
6 // slow.
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _JITCS_BBLOCK_H_
11 #define _JITCS_BBLOCK_H_
13 #include "jitcs_adt_enumerator.h"
14 #include "jitcs_base.h"
15 #include "jitcs_ids.h"
17 namespace jitcs {
18 class MachineDumper;
19 struct Instruction;
21 class BasicBlock {
22 // this should make it impossible to actually create an object of type
23 // BasicBlock.
24 private:
25 BasicBlock() = delete;
26 ~BasicBlock() = delete;
27 BasicBlock(const BasicBlock &) = delete;
28 void operator=(const BasicBlock &) = delete;
30 public:
31 BBId id() const;
33 Enumerator<const BasicBlock> predecessors();
34 Enumerator<const BasicBlock> successors();
35 Enumerator<const Instruction> instructions();
37 void dump(MachineDumper&) const;
39 public:
40 // append one or more instructions contained within the passed instruction stream
41 // the passed stream must be writable and available for the entire life time of the basic block.
42 // global memory should not be passed in if it contains virtual register references or similar,
43 // as instructions might be modified in place for certain optimizations.
44 // the same holds for memory references inside instructions.
45 // returns the number of detected instructions, or 0 if an error occurred.
46 size_t append(iptr* p, size_t N);
47 template<unsigned N> inline size_t append(iptr p[N]) { return append(p, N); }
48 // same as append, but copy the data to storage available for the life time of the basic
49 // block. this can be used to pass in instruction generated on stack, or stored in global
50 // memory.
51 // returns the number of detected instructions, or 0 if an error occurred.
52 // caution: this will NOT create copies of memory references inside instructions.
53 size_t append_copy(iptr const *p, size_t N);
54 template<unsigned N> inline size_t append_copy(iptr const p[N]) { return append_copy(p, N); }
57 } // end of namespace jitcs
59 #endif
60 // _JITCS_BBLOCK_H_