GCC Middle and Back End API Reference
ipcp_bits_lattice Class Reference

#include <ipa-cp.h>

Collaboration diagram for ipcp_bits_lattice:

Public Member Functions

bool bottom_p () const
 
bool top_p () const
 
bool constant_p () const
 
bool set_to_bottom ()
 
bool set_to_constant (widest_int, widest_int)
 
bool known_nonzero_p () const
 
widest_int get_value () const
 
widest_int get_mask () const
 
bool meet_with (ipcp_bits_lattice &other, unsigned, signop, enum tree_code, tree, bool)
 
bool meet_with (widest_int, widest_int, unsigned)
 
void print (FILE *)
 

Private Types

enum  { IPA_BITS_UNDEFINED , IPA_BITS_CONSTANT , IPA_BITS_VARYING }
 

Private Member Functions

bool meet_with_1 (widest_int, widest_int, unsigned, bool)
 
void get_value_and_mask (tree, widest_int *, widest_int *)
 

Private Attributes

enum ipcp_bits_lattice:: { ... }  m_lattice_val = IPA_BITS_UNDEFINED
 
widest_int m_value
 
widest_int m_mask
 

Detailed Description

Lattice of known bits, only capable of holding one value.
Bitwise constant propagation propagates which bits of a
value are constant.
For eg:
int f(int x)
{
  return some_op (x);
}

int f1(int y)
{
  if (cond)
   return f (y & 0xff);
  else
   return f (y & 0xf);
}

In the above case, the param 'x' will always have all
the bits (except the bits in lsb) set to 0.
Hence the mask of 'x' would be 0xff. The mask
reflects that the bits in lsb are unknown.
The actual propagated value is given by m_value & ~m_mask.   

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
IPA_BITS_UNDEFINED 
IPA_BITS_CONSTANT 
IPA_BITS_VARYING 

Member Function Documentation

◆ bottom_p()

bool ipcp_bits_lattice::bottom_p ( ) const
inline

◆ constant_p()

bool ipcp_bits_lattice::constant_p ( ) const
inline

References IPA_BITS_CONSTANT, and m_lattice_val.

Referenced by known_nonzero_p(), and meet_with_1().

◆ get_mask()

widest_int ipcp_bits_lattice::get_mask ( ) const
inline

References m_mask.

Referenced by ipcp_store_vr_results(), meet_with(), and print().

◆ get_value()

widest_int ipcp_bits_lattice::get_value ( ) const
inline

References m_value.

Referenced by ipcp_store_vr_results(), meet_with(), and print().

◆ get_value_and_mask()

void ipcp_bits_lattice::get_value_and_mask ( tree operand,
widest_int * valuep,
widest_int * maskp )
private
Convert operand to value, mask form.   

References get_nonzero_bits(), ggc_alloc(), wi::to_widest(), and TREE_CODE.

Referenced by meet_with().

◆ known_nonzero_p()

bool ipcp_bits_lattice::known_nonzero_p ( ) const
Return true if any of the known bits are non-zero.   

References wi::bit_and(), wi::bit_not(), constant_p(), m_mask, m_value, and wi::ne_p().

◆ meet_with() [1/2]

bool ipcp_bits_lattice::meet_with ( ipcp_bits_lattice & other,
unsigned precision,
signop sgn,
enum tree_code code,
tree operand,
bool drop_all_ones )
Meet bits lattice with the result of bit_value_binop (other, operand)
if code is binary operation or bit_value_unop (other) if code is unary op.
In the case when code is nop_expr, no adjustment is required.  If
DROP_ALL_ONES, mask out any known bits with value one afterwards.   

References bit_value_binop(), bit_value_unop(), bottom_p(), get_mask(), get_value(), get_value_and_mask(), ggc_alloc(), meet_with_1(), set_to_bottom(), set_to_constant(), wi::sext(), tcc_binary, tcc_unary, top_p(), TREE_CODE_CLASS, TREE_TYPE, TYPE_PRECISION, and TYPE_SIGN.

◆ meet_with() [2/2]

bool ipcp_bits_lattice::meet_with ( widest_int value,
widest_int mask,
unsigned precision )
Meet the bits lattice with operand
described by <value, mask, sgn, precision.   

References bottom_p(), meet_with_1(), set_to_bottom(), set_to_constant(), wi::sext(), and top_p().

◆ meet_with_1()

bool ipcp_bits_lattice::meet_with_1 ( widest_int value,
widest_int mask,
unsigned precision,
bool drop_all_ones )
private
Meet operation, similar to ccp_lattice_meet, we xor values
if this->value, value have different values at same bit positions, we want
to drop that bit to varying. Return true if mask is changed.
This function assumes that the lattice value is in CONSTANT state.  If
DROP_ALL_ONES, mask out any known bits with value one afterwards.   

References constant_p(), gcc_assert, ggc_alloc(), m_mask, m_value, set_to_bottom(), and wi::sext().

Referenced by meet_with(), and meet_with().

◆ print()

void ipcp_bits_lattice::print ( FILE * f)

◆ set_to_bottom()

bool ipcp_bits_lattice::set_to_bottom ( )
Set lattice value to bottom, if it already isn't the case.   

References bottom_p(), IPA_BITS_VARYING, m_lattice_val, m_mask, and m_value.

Referenced by meet_with(), meet_with(), and meet_with_1().

◆ set_to_constant()

bool ipcp_bits_lattice::set_to_constant ( widest_int value,
widest_int mask )
Set to constant if it isn't already. Only meant to be called
when switching state from TOP.   

References wi::bit_and(), wi::bit_not(), gcc_assert, IPA_BITS_CONSTANT, m_lattice_val, m_mask, m_value, and top_p().

Referenced by meet_with(), and meet_with().

◆ top_p()

bool ipcp_bits_lattice::top_p ( ) const
inline

Field Documentation

◆ []

enum { ... } ipcp_bits_lattice::m_lattice_val

◆ m_mask

widest_int ipcp_bits_lattice::m_mask
private

◆ m_value

widest_int ipcp_bits_lattice::m_value
private

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