P4C
The P4 Compiler
|
Normalize field lists in hashing expression (Hash.get primitive) More...
#include <normalize_hash_list.h>
Public Member Functions | |
NormalizeHashList (::P4::ReferenceMap *ref_map_, ::P4::TypeMap *type_map_, ::P4::TypeChecking *type_checking_) | |
NormalizeHashList & | operator= (NormalizeHashList &&)=delete |
Static Public Member Functions | |
static bool | isHasher (const IR::MethodCallExpression *mc) |
Check whether a method call is the hasher call. | |
Normalize field lists in hashing expression (Hash.get primitive)
This visitor replaces complex expressions in hashing field lists by temporary variables. The variable is placed in the scope of current control and its initialization is moved just before the statement in the apply block, which invokes the action the hash calculation belongs to (both direct invocation and table application are supported).
The temporary variable is needed as the hashing engine takes inputs from the PHV crossbar. There are some exceptions:
This pass expects that the local copy propagation has been finished (the P4::LocalCopyPropagation pass) and that all local variables are moved into the control scope (the P4::MoveDeclarations pass). Otherwise, the initialization code placed into the apply block could contain some local variables out of the scope.
Example:
is transformed to: