aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-gcc.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-02-09 11:21:39 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-02-09 18:00:00 +0000
commitc598bbbcc1eadb178e74d908ce917b7cf4f556c1 (patch)
tree46d8ef5483a0acc2ee585c8fe176ae7438a5e800 /gcc/rust/rust-gcc.cc
parent6d1ff568084ed86e6cf14e709fe6892256be824a (diff)
downloadgcc-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/rust-gcc.cc')
-rw-r--r--gcc/rust/rust-gcc.cc61
1 files changed, 1 insertions, 60 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 13cfe23..62c9d80 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -160,10 +160,6 @@ public:
tree immutable_type (tree);
- tree specify_abi_attribute (tree, Rust::ABI);
-
- tree insert_type_attribute (tree, const std::string &);
-
tree function_type (const typed_identifier &,
const std::vector<typed_identifier> &,
const std::vector<typed_identifier> &, tree,
@@ -769,52 +765,6 @@ Gcc_backend::immutable_type (tree base)
return constified;
}
-// ABI
-
-tree
-Gcc_backend::specify_abi_attribute (tree type, Rust::ABI abi)
-{
- std::string abi_string;
- switch (abi)
- {
- case Rust::ABI::UNKNOWN:
- return error_type ();
-
- case Rust::ABI::RUST:
- case Rust::ABI::INTRINSIC:
- case Rust::ABI::C:
- case Rust::ABI::CDECL:
- abi_string = "cdecl";
- break;
-
- case Rust::ABI::STDCALL:
- abi_string = "stdcall";
- break;
- case Rust::ABI::FASTCALL:
- abi_string = "fastcall";
- break;
- }
-
- return insert_type_attribute (type, abi_string);
-}
-
-tree
-Gcc_backend::insert_type_attribute (tree type, const std::string &attrname)
-{
- tree ident = get_identifier (attrname.c_str ());
-
- tree attribs = NULL_TREE;
- tree old_attrs = TYPE_ATTRIBUTES (type);
- if (old_attrs)
- attribs = merge_type_attributes (old_attrs,
- tree_cons (ident, NULL_TREE, NULL_TREE));
- else
- attribs = tree_cons (ident, NULL_TREE, NULL_TREE);
-
- tree res = build_type_attribute_variant (type, attribs);
- return res;
-}
-
// Make a function type.
tree
@@ -2965,8 +2915,7 @@ Gcc_backend::function (tree functype, const std::string &name,
= build_decl (location.gcc_location (), FUNCTION_DECL, id, functype);
if (!asm_name.empty ())
SET_DECL_ASSEMBLER_NAME (decl, get_identifier_from_string (asm_name));
- if ((flags & function_is_visible) != 0)
- TREE_PUBLIC (decl) = 1;
+
if ((flags & function_is_declaration) != 0)
DECL_EXTERNAL (decl) = 1;
else
@@ -2985,14 +2934,6 @@ Gcc_backend::function (tree functype, const std::string &name,
TREE_THIS_VOLATILE (decl) = 1;
if ((flags & function_in_unique_section) != 0)
resolve_unique_section (decl, 0, 1);
- if ((flags & function_only_inline) != 0)
- {
- TREE_PUBLIC (decl) = 1;
- DECL_EXTERNAL (decl) = 1;
- DECL_DECLARED_INLINE_P (decl) = 1;
- }
- if ((flags & function_read_only) != 0)
- TREE_READONLY (decl) = 1;
rust_preserve_from_gc (decl);
return decl;