llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
Classes | Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
Block Class Referencefinal

#include <core/block.h>

Inheritance diagram for Block:
Inheritance graph
[legend]
Collaboration diagram for Block:
Collaboration graph
[legend]

Classes

class  PhiIterator
 Iterator over PHI nodes. More...
 
class  PredIterator
 Iterator over the predecessors of a block. More...
 

Public Types

using InstListType = llvm::ilist< Inst >
 
using iterator = InstListType::iterator
 
using reverse_iterator = InstListType::reverse_iterator
 
using const_iterator = InstListType::const_iterator
 
using const_reverse_iterator = InstListType::const_reverse_iterator
 
template<typename T >
using iter_fwd = std::iterator< std::forward_iterator_tag, T, ptrdiff_t, T *, T * >
 
using succ_iterator = llvm::SuccIterator< TerminatorInst, Block >
 
using const_succ_iterator = llvm::SuccIterator< const TerminatorInst, const Block >
 
using pred_iterator = PredIterator< Block, Value::user_iterator >
 
using const_pred_iterator = PredIterator< const Block, Value::const_user_iterator >
 
template<typename It , typename T >
using facade_fwd = llvm::iterator_facade_base< It, std::forward_iterator_tag, T >
 
using phi_iterator = PhiIterator< PhiInst, iterator >
 
using const_phi_iterator = PhiIterator< const PhiInst, const_iterator >
 
- Public Types inherited from Global
enum  Kind { EXTERN, FUNC, BLOCK, ATOM }
 Enumeration of global kinds.
 
- Public Types inherited from User
using op_iterator = Use *
 
using const_op_iterator = const Use *
 
using op_range = llvm::iterator_range< op_iterator >
 
using const_op_range = llvm::iterator_range< const_op_iterator >
 
using value_op_range = llvm::iterator_range< value_op_iterator >
 
using const_value_op_range = llvm::iterator_range< const_value_op_iterator >
 
template<typename T >
using conv_op_range = llvm::iterator_range< conv_op_iterator< T > >
 
template<typename T >
using const_conv_op_range = llvm::iterator_range< const_conv_op_iterator< T > >
 
template<typename T >
using unref_range = llvm::iterator_range< unref_iterator< T > >
 
template<typename T >
using const_unref_range = llvm::iterator_range< const_unref_iterator< T > >
 
- Public Types inherited from Value
enum  Kind { INST, GLOBAL, EXPR, CONST }
 Enumeration of value types.
 
template<typename T >
using forward_it = std::iterator< std::forward_iterator_tag, T >
 
using use_iterator = use_iterator_impl< Use >
 
using const_use_iterator = use_iterator_impl< const Use >
 
using user_iterator = user_iterator_impl< User >
 
using const_user_iterator = user_iterator_impl< const User >
 

Public Member Functions

 Block (const std::string_view name, Visibility visibility=Visibility::LOCAL)
 
 ~Block ()
 
void removeFromParent () override
 Removes the global from the parent container.
 
void eraseFromParent () override
 Removes a block from the parent.
 
void AddInst (Inst *inst, Inst *before=nullptr)
 Adds an instruction to the basic block.
 
void AddPhi (PhiInst *phi)
 Adds a PHI instruction to the basic block.
 
FuncgetParent () const
 Returns a pointer to the parent block.
 
TerminatorInst * GetTerminator ()
 Returns the terminator of the block.
 
const TerminatorInst * GetTerminator () const
 
std::optional< llvm::Align > GetAlignment () const override
 Blocks have no known alignment.
 
bool HasAddressTaken () const
 Checks if the address of the block is taken.
 
bool IsLandingPad () const
 Checks if the block is an exception landing pad.
 
bool IsTrap () const
 Checks if the block is a single trap.
 
void insert (Inst *inst, iterator it)
 Add an instruction to the block.
 
void insertAfter (Inst *inst, iterator it)
 Add an instruction after another in the block.
 
void remove (iterator it)
 Removes an instruction.
 
void erase (iterator it)
 Erases an instruction.
 
void erase (iterator first, iterator last)
 Erases a range of instructions.
 
void clear ()
 Clears all blocks.
 
bool empty () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
size_t size () const
 Returns the size of the block.
 
succ_iterator succ_begin ()
 
succ_iterator succ_end ()
 
llvm::iterator_range< succ_iterator > successors ()
 
const_succ_iterator succ_begin () const
 
const_succ_iterator succ_end () const
 
llvm::iterator_range< const_succ_iterator > successors () const
 
unsigned succ_size () const
 
bool succ_empty () const
 
bool pred_empty () const
 
unsigned pred_size () const
 
pred_iterator pred_begin ()
 
pred_iterator pred_end ()
 
const_pred_iterator pred_begin () const
 
const_pred_iterator pred_end () const
 
llvm::iterator_range< pred_iteratorpredecessors ()
 
llvm::iterator_range< const_pred_iteratorpredecessors () const
 
bool phi_empty () const
 
llvm::iterator_range< const_phi_iteratorphis () const
 
llvm::iterator_range< phi_iteratorphis ()
 
iterator first_non_phi ()
 Iterator to the first non-phi instruction.
 
BlocksplitBlock (iterator I)
 Split the block at the given iterator.
 
void printAsOperand (llvm::raw_ostream &O, bool PrintType=true) const
 
ProggetProg () override
 Returns the program to which the extern belongs.
 
void dump (llvm::raw_ostream &os=llvm::errs()) const
 Dumps the textual representation of the instruction.
 
- Public Member Functions inherited from Global
 Global (Kind kind, const std::string_view name, Visibility visibility=Visibility::LOCAL, unsigned numOps=0)
 
Kind GetKind () const
 Returns the kind of the global.
 
bool Is (Kind kind) const
 Checks if the global is of a specific kind.
 
const std::string_view GetName () const
 Returns the name of the global.
 
llvm::StringRef getName () const
 Returns the name of the basic block for LLVM.
 
void SetVisibility (Visibility visibility)
 Sets the visibilty of the global.
 
Visibility GetVisibility () const
 Returns the visibilty of a global.
 
bool IsRoot () const
 Checks if the symbol can be externally referenced.
 
bool IsLocal () const
 Checks if the global is hidden in the compilation unit.
 
bool IsWeak () const
 Checks if a symbol is weak.
 
- Public Member Functions inherited from User
 User (Kind kind, unsigned numOps)
 Creates a new user.
 
virtual ~User ()
 Cleans up after the use.
 
size_t size () const
 
op_iterator op_begin ()
 
op_iterator op_end ()
 
op_range operands ()
 
const_op_iterator op_begin () const
 
const_op_iterator op_end () const
 
const_op_range operands () const
 
value_op_iterator value_op_begin ()
 
value_op_iterator value_op_end ()
 
value_op_range operand_values ()
 
const_value_op_iterator value_op_begin () const
 
const_value_op_iterator value_op_end () const
 
const_value_op_range operand_values () const
 
- Public Member Functions inherited from Value
 Value (Kind kind)
 Constructs a new value.
 
 Value (const Value &)=delete
 Do not allow copying.
 
 Value (Value &&)=delete
 Do not allow moving.
 
virtual ~Value ()
 Destroy the value.
 
Kind GetKind () const
 Returns the value kind.
 
bool Is (Kind kind) const
 Checks if the value is of a specific kind.
 
bool IsConstant () const
 Checks whether the value is a compile-time constant.
 
virtual void replaceAllUsesWith (Value *v)
 Replaces all uses of this value.
 
virtual void replaceAllUsesWith (Ref< Value > v)
 Replaces all uses of this with a refernce.
 
size_t use_size () const
 
bool use_empty () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
llvm::iterator_range< use_iteratoruses ()
 
llvm::iterator_range< const_use_iteratoruses () const
 
bool user_empty () const
 
user_iterator user_begin ()
 
const_user_iterator user_begin () const
 
user_iterator user_end ()
 
const_user_iterator user_end () const
 
llvm::iterator_range< user_iteratorusers ()
 
llvm::iterator_range< const_user_iteratorusers () const
 
void operator= (const Value &)=delete
 Do not allow assignments.
 
void operator= (Value &&)=delete
 Do not allow move assignments.
 

Static Public Attributes

static constexpr Global::Kind kGlobalKind = Global::Kind::BLOCK
 Kind of the global.
 
- Static Public Attributes inherited from Global
static constexpr Value::Kind kValueKind = Value::Kind::GLOBAL
 Kind of the global.
 

Friends

struct llvm::ilist_traits< Inst >
 
struct SymbolTableListTraits< Block >
 

Additional Inherited Members

- Protected Member Functions inherited from User
template<int I>
void Set (Ref< Value > val)
 Setter for an operand.
 
void Set (int i, Ref< Value > val)
 Setter for an operand.
 
template<int I>
Ref< ValueGet ()
 Accessor for an operand.
 
Ref< ValueGet (int i)
 Accessor for an operand.
 
template<int I>
ConstRef< ValueGet () const
 Accessor for an operand.
 
ConstRef< ValueGet (int i) const
 Accessor for an operand.
 
void resizeUses (unsigned n)
 Grows the operand list.
 
- Protected Attributes inherited from User
unsigned numOps_
 Number of operands.
 
Useuses_
 Head of the use list.
 

Detailed Description

Basic block.

Constructor & Destructor Documentation

◆ Block()

Block::Block ( const std::string_view  name,
Visibility  visibility = Visibility::LOCAL 
)

Creates a new basic block.

Parameters
parentParent function.
visibilityVisibility attribute of the global symbol.

◆ ~Block()

Block::~Block ( )

Erases a basic block.


The documentation for this class was generated from the following files: