From 39aa96ce9382f455bc071a3aa36f866fef760af1 Mon Sep 17 00:00:00 2001 From: Yap Zhi Heng Date: Thu, 17 Jul 2025 22:13:32 +0800 Subject: gccrs: Implement compilation for SlicePattern matching against ArrayType scrutinee Example GIMPLE output from compiling testsuite/rust/compile/match-pattern-array.rs: ... a[0] = 0; a[1] = 1; RUSTTMP.3 = a; _1 = RUSTTMP.3[0]; _2 = _1 == 0; _3 = RUSTTMP.3[1]; _4 = _3 == 1; _5 = _2 & _4; if (_5 != 0) goto ; else goto ; : { { } } goto ; } : ... gcc/rust/ChangeLog: * rust-backend.h: New size_constant_expression function. * rust-gcc.cc: Implementation of size_constant_expression function to generate tree node for array access. * backend/rust-compile-pattern.h: Remove empty visits for SlicePattern. * backend/rust-compile-pattern.cc: Implement SlicePattern check expression & binding compilation against ArrayType scrutinee. Signed-off-by: Yap Zhi Heng --- gcc/rust/rust-gcc.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/rust/rust-gcc.cc') diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 42cdc6c..c5fda5c 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -818,6 +818,12 @@ char_constant_expression (char c) return build_int_cst (char_type_node, c); } +tree +size_constant_expression (size_t val) +{ + return size_int (val); +} + // Make a constant boolean expression. tree -- cgit v1.1