P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::DoSimplifySelectCases Class Reference
Inheritance diagram for P4::DoSimplifySelectCases:

Public Member Functions

 DoSimplifySelectCases (const TypeMap *typeMap, bool requireConstants)
 
const IR::Node * preorder (IR::SelectExpression *expression) override
 

Detailed Description

This pass analyzes reachability of select cases.

  • If there is just one case label, the select statement is eliminated.
  • If a case label appears after the default label, the case is unreachable and therefore eliminated.

If requireConstants is true this pass requires that all select labels evaluate to constants.

Precondition
Assumes that there are no side-effects in the evaluation of select labels.
Postcondition
Unreachable case labels are removed. Case statement with a single label is replaced with a direct transition