Jlm
basic-block.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2013 2014 2015 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #ifndef JLM_LLVM_IR_BASIC_BLOCK_HPP
7 #define JLM_LLVM_IR_BASIC_BLOCK_HPP
8 
10 #include <jlm/llvm/ir/cfg.hpp>
11 #include <jlm/llvm/ir/tac.hpp>
12 
13 namespace jlm::llvm
14 {
15 
16 class BasicBlock final : public ControlFlowGraphNode
17 {
18 public:
19  ~BasicBlock() noexcept override;
20 
21 private:
24  {}
25 
26  BasicBlock(const BasicBlock &) = delete;
27 
28  BasicBlock(BasicBlock &&) = delete;
29 
30  BasicBlock &
31  operator=(const BasicBlock &) = delete;
32 
33  BasicBlock &
34  operator=(BasicBlock &&) = delete;
35 
36 public:
37  const ThreeAddressCodeList &
38  tacs() const noexcept
39  {
40  return tacs_;
41  }
42 
44  tacs() noexcept
45  {
46  return tacs_;
47  }
48 
50  begin() const noexcept
51  {
52  return tacs_.begin();
53  }
54 
56  rbegin() const noexcept
57  {
58  return tacs_.rbegin();
59  }
60 
62  end() const noexcept
63  {
64  return tacs_.end();
65  }
66 
68  rend() const noexcept
69  {
70  return tacs_.rend();
71  }
72 
73  inline size_t
74  ntacs() const noexcept
75  {
76  return tacs_.ntacs();
77  }
78 
79  [[nodiscard]] ThreeAddressCode *
80  first() const noexcept
81  {
82  return tacs_.first();
83  }
84 
85  [[nodiscard]] ThreeAddressCode *
86  last() const noexcept
87  {
88  return tacs_.last();
89  }
90 
91  inline void
93  {
94  tacs_.drop_first();
95  }
96 
97  inline void
99  {
100  tacs_.drop_last();
101  }
102 
104  append_first(std::unique_ptr<llvm::ThreeAddressCode> tac)
105  {
106  tacs_.append_first(std::move(tac));
107  return tacs_.first();
108  }
109 
110  void
112  {
113  for (auto it = tacs.rbegin(); it != tacs.rend(); it++)
114  append_first(std::move(*it));
115  tacs.clear();
116  }
117 
118  void
120  {
121  tacs_.append_first(tl);
122  }
123 
125  append_last(std::unique_ptr<llvm::ThreeAddressCode> tac)
126  {
127  tacs_.append_last(std::move(tac));
128  return tacs_.last();
129  }
130 
131  void
133  {
134  for (auto & tac : tacs)
135  append_last(std::move(tac));
136  tacs.clear();
137  }
138 
142  std::unique_ptr<llvm::ThreeAddressCode> tac)
143  {
144  return tacs_.insert_before(it, std::move(tac));
145  }
146 
147  void
149  {
150  for (auto & tac : tv)
151  tacs_.insert_before(it, std::move(tac));
152  tv.clear();
153  }
154 
161  bool
162  HasSsaPhiOperation() const;
163 
165  insert_before_branch(std::unique_ptr<llvm::ThreeAddressCode> tac);
166 
167  void
169 
170  static BasicBlock *
172 
173 private:
175 };
176 
177 }
178 
179 #endif
BasicBlock(const BasicBlock &)=delete
void append_first(tacsvector_t &tacs)
ThreeAddressCodeList::const_reverse_iterator rend() const noexcept
Definition: basic-block.hpp:68
ThreeAddressCodeList::const_iterator end() const noexcept
Definition: basic-block.hpp:62
BasicBlock & operator=(const BasicBlock &)=delete
ThreeAddressCodeList tacs_
~BasicBlock() noexcept override
BasicBlock & operator=(BasicBlock &&)=delete
ThreeAddressCode * last() const noexcept
Definition: basic-block.hpp:86
size_t ntacs() const noexcept
Definition: basic-block.hpp:74
void append_last(tacsvector_t &tacs)
const ThreeAddressCodeList & tacs() const noexcept
Definition: basic-block.hpp:38
void insert_before(const ThreeAddressCodeList::const_iterator &it, tacsvector_t &tv)
ThreeAddressCodeList & tacs() noexcept
Definition: basic-block.hpp:44
llvm::ThreeAddressCode * insert_before_branch(std::unique_ptr< llvm::ThreeAddressCode > tac)
Definition: basic-block.cpp:23
llvm::ThreeAddressCode * append_first(std::unique_ptr< llvm::ThreeAddressCode > tac)
bool HasSsaPhiOperation() const
Definition: basic-block.cpp:17
void append_first(ThreeAddressCodeList &tl)
ThreeAddressCode * first() const noexcept
Definition: basic-block.hpp:80
llvm::ThreeAddressCode * insert_before(const ThreeAddressCodeList::const_iterator &it, std::unique_ptr< llvm::ThreeAddressCode > tac)
BasicBlock(BasicBlock &&)=delete
static BasicBlock * create(ControlFlowGraph &cfg)
Definition: basic-block.cpp:37
llvm::ThreeAddressCode * append_last(std::unique_ptr< llvm::ThreeAddressCode > tac)
ThreeAddressCodeList::const_iterator begin() const noexcept
Definition: basic-block.hpp:50
ThreeAddressCodeList::const_reverse_iterator rbegin() const noexcept
Definition: basic-block.hpp:56
ControlFlowGraph & cfg() const noexcept
Definition: cfg-node.hpp:106
const_iterator end() const noexcept
Definition: tac.hpp:251
const_iterator begin() const noexcept
Definition: tac.hpp:239
ThreeAddressCode * first() const noexcept
Definition: tac.hpp:300
void append_first(std::unique_ptr< llvm::ThreeAddressCode > tac)
Definition: tac.hpp:281
const_reverse_iterator rbegin() const noexcept
Definition: tac.hpp:245
std::list< ThreeAddressCode * >::const_reverse_iterator const_reverse_iterator
Definition: tac.hpp:208
ThreeAddressCode * last() const noexcept
Definition: tac.hpp:306
ThreeAddressCode * insert_before(const const_iterator &it, std::unique_ptr< llvm::ThreeAddressCode > tac)
Definition: tac.hpp:263
std::list< ThreeAddressCode * >::const_iterator const_iterator
Definition: tac.hpp:207
size_t ntacs() const noexcept
Definition: tac.hpp:294
void append_last(std::unique_ptr< llvm::ThreeAddressCode > tac)
Definition: tac.hpp:275
const_reverse_iterator rend() const noexcept
Definition: tac.hpp:257
Global memory state passed between functions.
std::vector< std::unique_ptr< llvm::ThreeAddressCode > > tacsvector_t
Definition: tac.hpp:202