diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-02-09 11:21:39 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-02-09 18:00:00 +0000 |
commit | c598bbbcc1eadb178e74d908ce917b7cf4f556c1 (patch) | |
tree | 46d8ef5483a0acc2ee585c8fe176ae7438a5e800 /gcc/rust/backend/rust-compile-item.h | |
parent | 6d1ff568084ed86e6cf14e709fe6892256be824a (diff) | |
download | gcc-c598bbbcc1eadb178e74d908ce917b7cf4f556c1.zip gcc-c598bbbcc1eadb178e74d908ce917b7cf4f556c1.tar.gz gcc-c598bbbcc1eadb178e74d908ce917b7cf4f556c1.tar.bz2 |
Support inline attribute by marking as DECL_DECLARED_INLINE_P
This does a refactor by removing more flags for the fndecl construction
from the rust-gcc wrapper code in favour of using the tree api directly.
The ABI option attributes have also been refactored from the backend
interface in favour of their own package.
The gccgo wrapper tried to mark inline fns as extern inline but this
refactor allows us to control the inline options specificly for the
rust semantics.
Fixes #857
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 73f6967..70b5415 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -144,9 +144,9 @@ public: NULL, constant.get_locus ()); tree fndecl - = ctx->get_backend ()->function (compiled_fn_type, ident, "", - Backend::function_read_only, + = ctx->get_backend ()->function (compiled_fn_type, ident, "", 0, constant.get_locus ()); + TREE_READONLY (fndecl) = 1; tree enclosing_scope = NULL_TREE; HIR::BlockExpr *function_body @@ -255,18 +255,6 @@ public: tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); - unsigned int flags = 0; - bool is_main_fn = function.get_function_name ().compare ("main") == 0; - - // if its the main fn or pub visibility mark its as DECL_PUBLIC - // please see https://github.com/Rust-GCC/gccrs/pull/137 - if (is_main_fn || function.has_visibility ()) - flags |= Backend::function_is_visible; - - // is it a const function? - if (function.get_qualifiers ().is_const ()) - flags |= Backend::function_read_only; - const Resolver::CanonicalPath *canonical_path = nullptr; bool ok = ctx->get_mappings ()->lookup_canonical_path ( function.get_mappings ().get_crate_num (), @@ -275,19 +263,25 @@ public: std::string ir_symbol_name = canonical_path->get () + fntype->subst_as_string (); - std::string asm_name = function.get_function_name (); // we don't mangle the main fn since we haven't implemented the main shim // yet + bool is_main_fn = function.get_function_name ().compare ("main") == 0; if (!is_main_fn) { asm_name = ctx->mangle_item (fntype, *canonical_path); } + unsigned int flags = 0; tree fndecl = ctx->get_backend ()->function (compiled_fn_type, ir_symbol_name, asm_name, flags, function.get_locus ()); + setup_attributes_on_fndecl (fndecl, is_main_fn, function.has_visibility (), + function.get_qualifiers (), + function.get_outer_attrs ()); + + // insert into the context ctx->insert_function_decl (fntype, fndecl); // setup the params |