1 //===-- jitcs_bblock.h - a representation of a basic block ------*- C++ -*-===//
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
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"
22 // this should make it impossible to actually create an object of type
25 BasicBlock() = delete;
26 ~BasicBlock() = delete;
27 BasicBlock(const BasicBlock
&) = delete;
28 void operator=(const BasicBlock
&) = delete;
32 RefOrNull
<BasicBlock
> getFallThruFrom() const;
33 RefOrNull
<BasicBlock
> getFallThruTo() const;
35 ConstEnumerator
<BasicBlock
> predecessors();
36 ConstEnumerator
<BasicBlock
> successors();
37 ConstEnumerator
<Instruction
> instructions();
39 void dump(IDumper
&) const;
42 // append one or more instructions contained within the passed instruction stream
43 // the passed stream must be writable and available for the entire life time of the basic block.
44 // global memory should not be passed in if it contains virtual register references or similar,
45 // as instructions might be modified in place for certain optimizations.
46 // the same holds for memory references inside instructions.
47 // returns the number of detected instructions, or 0 if an error occurred.
48 size_t append(iptr
* p
, size_t N
);
49 template<unsigned N
> inline size_t append(iptr p
[N
]) { return append(p
, N
); }
50 // same as append, but copy the data to storage available for the life time of the basic
51 // block. this can be used to pass in instruction generated on stack, or stored in global
53 // returns the number of detected instructions, or 0 if an error occurred.
54 // caution: this will NOT create copies of memory references inside instructions.
55 size_t append_copy(iptr
*p
, size_t N
);
56 template<unsigned N
> inline size_t append_copy(iptr
const p
[N
]) { return append_copy(p
, N
); }
59 } // end of namespace jitcs