diff options
author | Yap Zhi Heng <yapzhhg@gmail.com> | 2025-07-17 22:13:32 +0800 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-08-05 16:36:56 +0200 |
commit | 39aa96ce9382f455bc071a3aa36f866fef760af1 (patch) | |
tree | 30e475314e6b223876c19d2d69aaec48f36d88ae /gcc/rust/rust-gcc.cc | |
parent | 72eb21fdf97da9613693dfcebe7b3270b133b7f0 (diff) | |
download | gcc-39aa96ce9382f455bc071a3aa36f866fef760af1.zip gcc-39aa96ce9382f455bc071a3aa36f866fef760af1.tar.gz gcc-39aa96ce9382f455bc071a3aa36f866fef760af1.tar.bz2 |
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 <D.122>; else goto <D.123>;
<D.122>:
{
{
}
}
goto <D.117>;
}
<D.123>:
...
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 <yapzhhg@gmail.com>
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r-- | gcc/rust/rust-gcc.cc | 6 |
1 files changed, 6 insertions, 0 deletions
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 |