intrinsic: Add min_align_of#4582
Conversation
CohenArthur
left a comment
There was a problem hiding this comment.
Looks good to me, @philberty if you have the time can you take a look? Note that we have https://forge.sourceware.org/gcc/gcc-TEST/pulls/161 going on at the same time so you might need to be careful with merge conflicts
| // { dg-final { scan-tree-dump {D\.[0-9]+ = 2;} "gimple" } } | ||
| // { dg-final { scan-tree-dump {D\.[0-9]+ = 4;} "gimple" } } |
There was a problem hiding this comment.
What you can do here instead is make it an execution test, add the two alignments and then make the main function return the substraction of the sum of the alignments and the expected sum:
fn main() -> i32 {
let align_u16 = get_u16_align();
let align_u32 = get_u32_align();
align_u16 + align_u32 - 6
}There was a problem hiding this comment.
Thanks for the good tip!
330263a to
8c2b270
Compare
| min_align_of_handler (Context *ctx, TyTy::FnType *fntype) | ||
| { | ||
| // min_align_of has _zero_ parameters its parameter is the generic one | ||
| rust_assert (fntype->get_params ().size () == 0); |
There was a problem hiding this comment.
We should probably have a step earlier that throws an error as well as a test to highlight that behavior.
There was a problem hiding this comment.
I followed the existing pattern from size_of. I'm not yet familiar with where intrinsic signatures are verified during type checking, but I will investigate it.
This patch implements the 'min_align_of' compiler intrinsic. It resolves the minimum alignment of a given compile-time sized type and returns it as a size_type_node integer constant expression. gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (generic_intrinsics): Add min_align_of to map. * backend/rust-intrinsic-handlers.cc (min_align_of_handler): New function. * backend/rust-intrinsic-handlers.h (min_align_of_handler): New declaration. gcc/testsuite/ChangeLog: * rust/execute/min_align_of.rs: New test. Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch implements the 'min_align_of' compiler intrinsic. It resolves the minimum alignment of a given compile-time sized type and returns it as a size_type_node integer constant expression.
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: