P4C
The P4 Compiler
Loading...
Searching...
No Matches
solver::ActionSolverBase Class Referenceabstract

ActionSolverBase contains basic methods and states for all solvers. More...

#include <action_constraint_solver.h>

Inheritance diagram for solver::ActionSolverBase:
[legend]

Public Member Functions

virtual void add_assign (const Operand &dst, Operand src)
 add an assignment from the action.
 
virtual void add_src_unallocated_assign (const ContainerID &c, const le_bitrange &range)
 
virtual void clear ()
 clear all states and will reset enable_bitmasked_set to true.
 
void enable_bitmasked_set (bool enable)
 set true to enable bitmasked_set set, otherwise disable. default: enable.
 
virtual void set_container_spec (ContainerID id, int size, bitvec live)
 set_container_spec will update the container spec.
 
virtual Result solve ()=0
 return solve result.
 

Protected Member Functions

std::optional< Errorcheck_whole_container_set_with_none_source_allocated () const
 
Result try_container_set (const ContainerID dest, const RotateClassifiedAssigns &offset_assigns) const
 
std::optional< Errorvalidate_input () const
 

Protected Attributes

ordered_map< ContainerID, RotateClassifiedAssignsdest_assigns_i
 destination-clustered assignments.
 
bool enable_bitmasked_set_i = true
 
ordered_map< ContainerID, ContainerSpecspecs_i
 
ordered_map< ContainerID, bitvecsrc_unallocated_bits
 bits that will be written in this action but their sources have not been allcoated.
 

Detailed Description

ActionSolverBase contains basic methods and states for all solvers.

Member Function Documentation

◆ add_src_unallocated_assign()

void solver::ActionSolverBase::add_src_unallocated_assign ( const ContainerID & c,
const le_bitrange & range )
virtual

setrange on c of src_unallocated_bits by range. contract: DO NOT add unallocated assignment if the source can be perfectly overlaid with the destination! Example: f2<3> = f1<3>, f2 is allocated to W[0:2], and f1 is unallocated. If their liveranges are: f1: [0w, 3r], f2: [3w, 4r]. if we allocate (overlay) f2 to W[0:2], this assignment can be eliminated.

◆ check_whole_container_set_with_none_source_allocated()

std::optional< Error > solver::ActionSolverBase::check_whole_container_set_with_none_source_allocated ( ) const
protected

For all destination container c in src_unallocated_bits, that if dest_assigns_i do not have records of c, i.e., none of the sources have been allocated, check if whole container set will corrupt other live bits.

◆ solve()

virtual Result solver::ActionSolverBase::solve ( )
pure virtual

◆ try_container_set()

Result solver::ActionSolverBase::try_container_set ( const ContainerID dest,
const RotateClassifiedAssigns & offset_assigns ) const
protected

try to use container set to synthesize all assignments to dest, either (1) sources are all constants: can be merge into one constant or action data, or (2) sources are of one container: all aligned, or (3) sources are all action data. Also, We need to ensure that other allocated bits in the container will not be corrupted, i.e., all other bits of dest that are not set in this action need to be not live.

◆ validate_input()

std::optional< Error > solver::ActionSolverBase::validate_input ( ) const
protected

validate_input run misc basic checks on input, see comments in function body for details.