First effort to revive BasicBlock and Function classes and
[jitcs.git] / include / jitcs_function.h
blob0834ce726f26e6d2c16b1435c93abfc90d0c6fb1
1 //===-- jitcs_function.h - a representation of a function -------*- C++ -*-===//
2 //
3 // The Function class is an interface to the actual function provided by the
4 // library. All implementation details are hidden from outside users.
5 // Enumeration of basic blocks and virtual registers is possible, but slow.
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef _JITCS_FUNCTION_H_
10 #define _JITCS_FUNCTION_H_
12 #include "jitcs_adt_enumerator.h"
13 #include "jitcs_adt_ref.h"
14 #include "jitcs_base.h"
15 #include "jitcs_ids.h"
16 #include "jitcs_memmgr.h"
18 namespace jitcs {
19 class BasicBlock;
20 class CallingConvention;
21 class IMachineDumper;
22 struct VirtualRegister;
23 class TempAllocator;
25 class Function {
26 public:
27 enum Strategy {
28 One_Pass_Linear_Scan,
29 Two_Pass_Linear_Scan,
31 public:
32 // factory method to hide implementation detail
33 //static std::unique_ptr<Function> Create(TempAllocator& ins, const std::shared_ptr<const CallingConvention>& cc);
35 public:
36 ~Function();
37 // this should make it impossible to actually create an object of type
38 // Function.
39 Function() = delete;
40 Function(const Function &) = delete;
41 void operator=(const Function &) = delete;
43 public:
44 Enumerator<const BasicBlock> enumerateBasicBlocks();
45 //Enumerator<const VirtualRegister> enumerateVirtualRegisters();
46 std::shared_ptr<const CallingConvention> getCallingConvention() const;
47 //RefOrNull<VirtualRegister> getArgumentRegister(uint n);
48 //RefOrNull<VirtualRegister> getResultRegister(uint n);
50 public:
51 //void check();
52 //void clean();
53 void dump(IMachineDumper&) const;
55 Ref<BasicBlock> getStartBlock();
56 Ref<BasicBlock> createBasicBlock();
58 //Ref<VirtualRegister> createVirtualRegister(RegClassId regclass, int sz = 0);
59 //Ref<VirtualRegister> allocateTemporary(Ref<VirtualRegister> compatibleTo);
60 //void deallocateTemporary(Ref<VirtualRegister> id);
62 public:
63 //MemMgr::CodeAndData generate(MemMgr&, Strategy, RefOrNull<IMachineDumper>);
66 } // End jitcs namespace
68 #endif
69 // _JITCS_FUNCTION_H_