P4C
The P4 Compiler
Loading...
Searching...
No Matches
PHV::LiveRangeInfo Class Reference

Public Types

enum class  OpInfo {
  DEAD , READ , WRITE , READ_WRITE ,
  LIVE
}
 

Public Member Functions

bool can_overlay (const LiveRangeInfo &other) const
 
OpInfo & deparser ()
 
const OpInfo & deparser () const
 
std::vector< LiveRangedisjoint_ranges () const
 
OpInfo & parser ()
 
const OpInfo & parser () const
 
OpInfo & stage (int i)
 
const OpInfo & stage (int i) const
 
const safe_vector< OpInfo > & vec () const
 

Static Public Member Functions

static std::vector< LiveRangemerge_invalid_ranges (const std::vector< LiveRange > &ranges)
 
static void set_num_table_stages (int stage)
 

Member Function Documentation

◆ can_overlay()

bool PHV::LiveRangeInfo::can_overlay ( const LiveRangeInfo & other) const
Returns
true when this and other can be overlaid, defined as: (1) For any stage s, at least one of OpInfo at s of this or other is dead. (2) Except for the write-after-read case that: For example P 0 1 2 3 4 D A W L L R D D D B D D D W L L R A and B can be overlaid because the Write at stage 2 of B actually happens after the Read of A at stage 2, i.e., for write, we require Dead in the next stage, instead of the corresponding stage. Note that, we cannot overlay in this case: P 0 1 2 3 4 D A W L L R D D D B D D W RW L L R TODO: we do not need to use this function during PHV allocation because AllocSlices already have the presice live range info already. This function is kept here for future overlay analysis before PHV allocation.

◆ disjoint_ranges()

std::vector< LiveRange > PHV::LiveRangeInfo::disjoint_ranges ( ) const
Returns
a vector of disjoint live ranges. For example P 0 1 2 3 4 ... D Foo W R D W L L L R Foo.disjoint_ranges() = [(-1W, 0R), (2W, 12R)] // if tofino stage of parse is -1, mau stages starts from 0 and deparser is device::max_stage(). Uninitialized reads, that are not caught by parser implicit init or when auto-init-metadata are not enabled, will have a short live range [xR, xR]. These short live ranges should be treated as overlayable to any other live ranges. contract: for every paired def and use, all stages in between are marked as LIVE. NOTE: Even if IDs of units seem to be using the same schema as min-stage-based StageAndAccess, they are not. The previous StageAndAccess use max_min_stage + 1 as deparser, which was very error-prone because dependency graph can be changed.

◆ merge_invalid_ranges()

std::vector< LiveRange > PHV::LiveRangeInfo::merge_invalid_ranges ( const std::vector< LiveRange > & ranges)
static
Returns
a new vector of live ranges that consecutive invalid live ranges will be merged into one. For example, {(1R, 1R), (2R, 2R), (5R, 5R), (6W, 10R)} => {(1R, 5R), (6W, 10R)} {(1R, 1W), (2W, 2W), (3W, 3W)} => {(1R, 1W), (2W, 3W)} premise: ranges must be disjoint and sorted in increasing order of LiveRange. a compiler BUG will be thrown if not satisfied.

◆ set_num_table_stages()

static void PHV::LiveRangeInfo::set_num_table_stages ( int stage)
inlinestatic

Record the number of table stages in use

Minimum size is Device::numStages()

◆ vec()

const safe_vector< OpInfo > & PHV::LiveRangeInfo::vec ( ) const
inline
Returns
live info in a vector: [Parser 0 1 ... max_stage Deparser]