LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tree::Cjump Class Reference

Conditional branching. More...

#include <cjump.hh>

Inheritance diagram for tree::Cjump:
Collaboration diagram for tree::Cjump:

Public Types

enum  Relop {
  eq, ne, lt, gt,
  le, ge, ult, ule,
  ugt, uge
}
 Comparison of the condition. More...
Kinds of Tree nodes.
enum  kind_tree_type {
  const_kind, name_kind, temp_kind, binop_kind,
  mem_kind, call_kind, eseq_kind, move_kind,
  sxp_kind, jump_kind, cjump_kind, seq_kind,
  label_kind
}
 The kinds of Tree instuctions. More...

Public Member Functions

 Cjump (Relop relop, const rExp &left, const rExp &right, const rName &iftrue, const rName &iffalse)
 Construct a conditional jump.
void flip ()
 Flip the test/destinations of this CJump.
const Reloprelop_get () const
 Comparison operator.
void child_push_back (const rTree &tree)
tree_list_typechildren_get ()
const tree_list_typechildren_get () const
rTree & child_get (int nth)
rTree child_get (int nth) const
rTree & left_get ()
rTree & right_get ()
void parent_get_assert () const
Treeparent_get ()
const Treeparent_get () const
void parent_set (Tree *parent)
void replace_by (const rTree &tree)
virtual std::ostream & dump (std::ostream &o) const
 Report this instruction on o.
temp::Tempasm_get ()
void asm_set (const temp::Temp &temp)
void * state_get () const
void *& state_get ()
bool reducible_get () const
void reducible_set (bool b)
Accessors.
rExp left_get () const
 Left operand.
rExp right_get () const
 Right operand.
temp::Label label_true_get () const
 Destination label in case of positive test.
temp::Label label_false_get () const
 Destination label in case of negative test.
void label_false_set (const temp::Label &false_label)
 Destination label in case of negative test.
temp::label_list_type labels_get () const
 List of destination labels.
virtual kind_tree_type kind_get () const override
 cjump_kind.
Printing.
virtual std::ostream & tag_print (std::ostream &ostr) const override
 Report on o the kind of this instruction.

Protected Attributes

tree_list_type children_
 The arguments.
Treeparent_ = nullptr
 The Tree instruction this is a child from.
temp::Temptemp_ = nullptr
 The Temp for asm output.
void * state_ = nullptr
 The state for asm output.
bool reducible_ = true
 Tell if the tree is reducible.

Private Attributes

Relop relop_
 The comparison operator.

Detailed Description

Conditional branching.

Member Enumeration Documentation

The kinds of Tree instuctions.

These flags are used to facilitate the pattern matching during instruction selection. This method is not very clean nevertheless this way is cleaner and more efficient than the use of dynamic_cast<>().

Enumerator:
const_kind 
name_kind 
temp_kind 
binop_kind 
mem_kind 
call_kind 
eseq_kind 
move_kind 
sxp_kind 
jump_kind 
cjump_kind 
seq_kind 
label_kind 

Comparison of the condition.

Enumerator:
eq 
ne 
lt 
gt 
le 
ge 
ult 
ule 
ugt 
uge 

Constructor & Destructor Documentation

tree::Cjump::Cjump ( Relop  relop,
const rExp &  left,
const rExp &  right,
const rName &  iftrue,
const rName &  iffalse 
)
inline

Construct a conditional jump.

Parameters
relopComparison operator
leftLeft operand
rightRight operand
iftrueDestination label in case of positive test
iffalseDestination label in case of negative test

References tree::Tree::child_push_back().

Member Function Documentation

temp::Temp & tree::Tree::asm_get ( )
inlineinherited

References tree::Tree::temp_.

void tree::Tree::asm_set ( const temp::Temp temp)
inlineinherited

References tree::Tree::temp_.

rTree tree::Tree::child_get ( int  nth) const
inlineinherited
void tree::Tree::child_push_back ( const rTree &  tree)
inlineinherited
tree_list_type & tree::Tree::children_get ( )
inlineinherited
const tree_list_type & tree::Tree::children_get ( ) const
inlineinherited

References tree::Tree::children_.

std::ostream & tree::Tree::dump ( std::ostream &  o) const
virtualinherited

Report this instruction on o.

Reimplemented in tree::Seq, tree::Eseq, and tree::Call.

References tree::Tree::children_, misc::decindent(), misc::incendl(), and tree::Tree::tag_print().

Referenced by tree::operator<<().

void tree::Cjump::flip ( )
inline

Flip the test/destinations of this CJump.

References tree::Tree::child_get(), tree::Tree::children_, eq, ge, gt, le, lt, ne, precondition, relop_, uge, ugt, ule, and ult.

Tree::kind_tree_type tree::Cjump::kind_get ( ) const
overridevirtual

cjump_kind.

Implements tree::Tree.

References tree::Tree::cjump_kind.

temp::Label tree::Cjump::label_false_get ( ) const
inline

Destination label in case of negative test.

References tree::Tree::child_get(), and tree::Name::label_get().

Referenced by labels_get().

void tree::Cjump::label_false_set ( const temp::Label false_label)
inline

Destination label in case of negative test.

References tree::Tree::children_.

temp::Label tree::Cjump::label_true_get ( ) const
inline

Destination label in case of positive test.

References tree::Tree::child_get(), and tree::Name::label_get().

Referenced by labels_get().

temp::label_list_type tree::Cjump::labels_get ( ) const
inline

List of destination labels.

References label_false_get(), and label_true_get().

Referenced by canon::BasicBlock::labels_out_get().

rExp tree::Cjump::left_get ( ) const
inline

Left operand.

References tree::Tree::child_get().

rTree & tree::Tree::left_get ( )
inlineinherited
Tree * tree::Tree::parent_get ( )
inlineinherited

References tree::Tree::parent_.

const Tree * tree::Tree::parent_get ( ) const
inlineinherited

References tree::Tree::parent_.

void tree::Tree::parent_get_assert ( ) const
inherited
void tree::Tree::parent_set ( Tree parent)
inlineinherited

References tree::Tree::parent_.

bool tree::Tree::reducible_get ( ) const
inlineinherited
void tree::Tree::reducible_set ( bool  b)
inlineinherited
const Cjump::Relop & tree::Cjump::relop_get ( ) const
inline

Comparison operator.

References relop_.

void tree::Tree::replace_by ( const rTree &  tree)
inherited
rExp tree::Cjump::right_get ( ) const
inline

Right operand.

References tree::Tree::child_get().

rTree & tree::Tree::right_get ( )
inlineinherited
void * tree::Tree::state_get ( ) const
inlineinherited

References tree::Tree::state_.

void *& tree::Tree::state_get ( )
inlineinherited

References tree::Tree::state_.

std::ostream & tree::Cjump::tag_print ( std::ostream &  o) const
overridevirtual

Report on o the kind of this instruction.

Implements tree::Tree.

References relop_.

Member Data Documentation

Tree* tree::Tree::parent_ = nullptr
protectedinherited
bool tree::Tree::reducible_ = true
protectedinherited

Tell if the tree is reducible.

Referenced by tree::Tree::reducible_get(), and tree::Tree::reducible_set().

Relop tree::Cjump::relop_
private

The comparison operator.

Referenced by flip(), relop_get(), and tag_print().

void* tree::Tree::state_ = nullptr
protectedinherited

The state for asm output.

Referenced by tree::Tree::state_get().

temp::Temp* tree::Tree::temp_ = nullptr
protectedinherited

The Temp for asm output.

Referenced by tree::Tree::asm_get(), tree::Tree::asm_set(), and tree::Tree::~Tree().


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