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;
33 Enumerator
<const BasicBlock
> predecessors();
34 Enumerator
<const BasicBlock
> successors();
35 Enumerator
<const Instruction
> instructions();
37 void dump(MachineDumper
&) const;
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
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