[P4TC] Align key components to the nearest 8-bit size #5024
+3,232
−397
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As of now, whenever there is a key component that is a bit-type which doesn't correspond to primitive C type (u8, u16, u32, ...),
the compiler generates it as using the closest primitive C type that is larger then X in bit
For example -
dest_op here is converted into u32 like below -
This won't work, because the P4TC side is expecting the bit<24> (
dest_op
) to be contained in3 bytes
and not 4. All key components are expected to be 8-bit aligned. The new declaration for 'dest_op' would be -For all operations, compiler will call function 'getPrimitiveXX()' which will convert u8[] into primitive type (u32 or u64).
For reverse assignment operations compiler calls 'storePrimitiveXX()' which converts primitive types to u8 [ ] array.
@vbnogueira @jhsmt