![]() |
P4C
The P4 Compiler
|
#include <action_analysis.h>
Public Member Functions | |
| unsigned | build_constant () |
| unsigned | build_shiftable_constant () |
| unsigned | valid_instruction_constant (int container_size) const |
Public Attributes | |
| TotalAlignment | alignment |
| unsigned | constant_value |
| int | container_size = -1 |
| bool | initialized = false |
| safe_vector< ConstantPosition > | positions |
| bool | signExtend = false |
Information on all constants within a single container instruction
| unsigned ActionAnalysis::ConstantInfo::build_shiftable_constant | ( | ) |
Shifts a constant to the lower read bits point to determine if the constant can be used within a deposit-field
| unsigned ActionAnalysis::ConstantInfo::valid_instruction_constant | ( | int | container_size | ) | const |
Because the assembly only recognizes constants between -8..7 or their corresponding container size complement, this function converts all container constants (post-shifted) to a pre-shift value between -8 and 7. If the value is used in a deposit-field instruction, the value is the post-rotation result, implicitly encoding the required rotation (no longer between -8 and 7). The assembler will need to undo this rotation, so it can recreate the pre-rotational value of between -8 and 7, along with its rotation parameter.