]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Create canonical process of compiling constant items
authorPhilip Herron <philip.herron@embecosm.com>
Thu, 25 Aug 2022 13:46:32 +0000 (14:46 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 31 Jan 2023 13:16:50 +0000 (14:16 +0100)
commitffa16a4590ad47e3f4ba098e2090c3a53dccd5c7
treeecccc37166c3d8b9d3d408f80ccdd29226bfdee7
parent1eabeb5aecc954d2c237f5997605a73a37dd1c12
gccrs: Create canonical process of compiling constant items

In order to compile a block expression constant, the simplest way for us
was to reuse what code we have and to generate an artifical function which
does not get added to the translation unit. The constant then becomes
a CALL_EXPR to this artifical function which we can pass to the constexpr
evaluator to resolve the result of this artifical 'CALL_EXPR'.

Before this patch we seperated the difference between block expressions
and non block expressions in constants. So for non block expressions we
simply compiled them as if it was a simple constant but this is not
guaranteed to be the case in rust, for example coercion sites can generate
temporaries during autoderef which we let the constant evaluator resolve
for us. This makes all constants handled in the same way to simplify the
logic here.

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc: Improve compilation pipeline and simplify
function.
gcc/rust/backend/rust-compile-base.cc