summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/callgraph/tasks.cc
blob: e4d003bdf8ffdbdfe20f44f27cc2b4943482bc71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 ** \file callgraph/tasks.cc
 ** \brief Callgraph module related tasks' implementation.
 */

#include <ostream>

#include <ast/libast.hh>
#include <ast/tasks.hh>
#define DEFINE_TASKS 1
#include <callgraph/tasks.hh>
#undef DEFINE_TASKS
#include <callgraph/libcallgraph.hh>

namespace callgraph::tasks
{
  /*------------.
  | CallGraph.  |
  `------------*/

  static std::unique_ptr<CallGraph> callgraph;

  void callgraph_compute()
  {
    callgraph.reset(::callgraph::callgraph_compute(*ast::tasks::the_program));
  }

  void callgraph_dump()
  {
    precondition(callgraph.get());
    callgraph->print("call");
  }

  /*--------------.
  | ParentGraph.  |
  `--------------*/

  static std::unique_ptr<ParentGraph> parentgraph;

  void parentgraph_compute()
  {
    parentgraph.reset(
      ::callgraph::parentgraph_compute(*ast::tasks::the_program));
  }

  void parentgraph_dump()
  {
    precondition(parentgraph.get());
    parentgraph->print("parent");
  }

} // namespace callgraph::tasks