The first .as file is read and compiled correctly. (Though it wastes too
[jitcs.git] / src / jitcs_int_cfg_analysis.h
blob9c494c8d4dd6f81ca4d5069b23a47a83dbd76cd5
1 //===-- evm/bblock.h - a single basic block --*- C++ -*-===//
2 //
3 // A basic block contains a list of instructions.
4 //
5 //===----------------------------------------------------------------------===//
7 #ifndef _JITCS_INT_CFGANALYSIS_H_
8 #define _JITCS_INT_CFGANALYSIS_H_
10 #include "jitcs_base.h"
11 #include "jitcs_int_adt_array.h"
12 #include "jitcs_int_adt_bitmap.h"
13 #include "jitcs_adt_range.h"
14 #include "jitcs_int_bblock_impl.h"
16 namespace jitcs {
17 class FunctionImpl;
18 class IDumper;
20 class CFGAnalysis {
21 public:
22 enum AMode {
23 SIMPLE,
24 DEPTH_ANALYSIS
26 public:
27 CFGAnalysis();
28 CFGAnalysis(const CFGAnalysis &) = delete;
29 CFGAnalysis& operator=(const CFGAnalysis &) = delete;
31 public:
32 void init(FunctionImpl& f, AMode);
33 void clear();
34 void dump(IDumper&) const;
36 bool checkIntegrity() const;
38 public:
40 size_t getMaxBBlockDepth() const { return _maxDepth; }
41 size_t getBlockCount() const { return _order.size(); }
42 Ref<BasicBlockImpl> getOrderedBlock(size_t pos) const { return _order[pos]; }
43 Ref<const BasicBlockImpl> cgetOrderedBlock(size_t pos) const { return _order[pos]; }
44 size_t getDepth(Ref<BasicBlockImpl> bb) const { return _bblocks[bb->id()].depth; }
45 // size_t getOrder(BBlock* bb) const { return _bblocks[bb->id().id].order; }
47 private:
48 struct BBlockInfo {
49 BasicBlockImpl* bb;
50 size_t depth;
52 private:
53 size_t _calcDepth(size_t depth, size_t headbb,
54 BitmapRef handled, BitmapRef candidates,
55 ArrayRef<size_t> worklist, BitmapRef inworklist);
57 private:
58 ArrayRef<BasicBlockImpl*> _order;
59 ArrayRef<BBlockInfo> _bblocks;
60 size_t _maxDepth;
63 } // end of namespace jitcs
65 #endif
66 // _JITCS_INT_CFGANALYSIS_H_