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

Contains utility functions for eliminating saturating arithmetic. More...

#include <saturationElim.h>

Static Public Member Functions

static const IR::Mux * eliminate (const IR::Operation_Binary *binary)
 
static bool isSaturationOperation (const IR::Expression *expr)
 

Detailed Description

Contains utility functions for eliminating saturating arithmetic.

Member Function Documentation

◆ eliminate()

const IR::Mux * P4::SaturationElim::eliminate ( const IR::Operation_Binary * binary)
static

Eliminates saturating arithmetic by rewriting the given binary expression into a conditional ternary expression. The two operands in the given expression are assumed to be pure expressions (i.e., they have no side effects), and may be evaluated multiple times in the resulting expression. No checks are made to determine whether this assumption holds.

◆ isSaturationOperation()

bool P4::SaturationElim::isSaturationOperation ( const IR::Expression * expr)
static
Returns
true when the given expression is a saturating addition or a saturating subtraction. Otherwise, returns false.