diff options
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r-- | gcc/rust/rust-gcc.cc | 221 |
1 files changed, 0 insertions, 221 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index d83dd4d..22a1df6 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -321,24 +321,6 @@ public: Bvariable *temporary_variable (tree, tree, tree, tree, bool, Location, tree *); - Bvariable *implicit_variable (const std::string &, const std::string &, tree, - bool, bool, bool, int64_t); - - void implicit_variable_set_init (Bvariable *, const std::string &, tree, bool, - bool, bool, tree); - - Bvariable *implicit_variable_reference (const std::string &, - const std::string &, tree); - - Bvariable *immutable_struct (const std::string &, const std::string &, bool, - bool, tree, Location); - - void immutable_struct_set_init (Bvariable *, const std::string &, bool, bool, - tree, Location, tree); - - Bvariable *immutable_struct_reference (const std::string &, - const std::string &, tree, Location); - // Labels. tree label (tree, const std::string &name, Location); @@ -2620,209 +2602,6 @@ Gcc_backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree, return new Bvariable (var); } -// Create an implicit variable that is compiler-defined. This is used when -// generating GC root variables and storing the values of a slice initializer. - -Bvariable * -Gcc_backend::implicit_variable (const std::string &name, - const std::string &asm_name, tree type_tree, - bool is_hidden, bool is_constant, - bool is_common, int64_t alignment) -{ - if (type_tree == error_mark_node) - return this->error_variable (); - - tree decl = build_decl (BUILTINS_LOCATION, VAR_DECL, - get_identifier_from_string (name), type_tree); - DECL_EXTERNAL (decl) = 0; - TREE_PUBLIC (decl) = !is_hidden; - TREE_STATIC (decl) = 1; - TREE_USED (decl) = 1; - DECL_ARTIFICIAL (decl) = 1; - if (is_common) - { - DECL_COMMON (decl) = 1; - - // When the initializer for one implicit_variable refers to another, - // it needs to know the visibility of the referenced struct so that - // compute_reloc_for_constant will return the right value. On many - // systems calling make_decl_one_only will mark the decl as weak, - // which will change the return value of compute_reloc_for_constant. - // We can't reliably call make_decl_one_only yet, because we don't - // yet know the initializer. This issue doesn't arise in C because - // Rust initializers, unlike C initializers, can be indirectly - // recursive. To ensure that compute_reloc_for_constant computes - // the right value if some other initializer refers to this one, we - // mark this symbol as weak here. We undo that below in - // immutable_struct_set_init before calling mark_decl_one_only. - DECL_WEAK (decl) = 1; - } - if (is_constant) - { - TREE_READONLY (decl) = 1; - TREE_CONSTANT (decl) = 1; - } - if (alignment != 0) - { - SET_DECL_ALIGN (decl, alignment * BITS_PER_UNIT); - DECL_USER_ALIGN (decl) = 1; - } - if (!asm_name.empty ()) - SET_DECL_ASSEMBLER_NAME (decl, get_identifier_from_string (asm_name)); - - rust_preserve_from_gc (decl); - return new Bvariable (decl); -} - -// Set the initalizer for a variable created by implicit_variable. -// This is where we finish compiling the variable. - -void -Gcc_backend::implicit_variable_set_init (Bvariable *var, const std::string &, - tree, bool, bool, bool is_common, - tree init_tree) -{ - tree decl = var->get_decl (); - if (decl == error_mark_node || init_tree == error_mark_node) - return; - - DECL_INITIAL (decl) = init_tree; - - // Now that DECL_INITIAL is set, we can't call make_decl_one_only. - // See the comment where DECL_WEAK is set in implicit_variable. - if (is_common) - { - DECL_WEAK (decl) = 0; - make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); - } - - resolve_unique_section (decl, 2, 1); - - rest_of_decl_compilation (decl, 1, 0); -} - -// Return a reference to an implicit variable defined in another package. - -Bvariable * -Gcc_backend::implicit_variable_reference (const std::string &name, - const std::string &asm_name, - tree type_tree) -{ - if (type_tree == error_mark_node) - return this->error_variable (); - - tree decl = build_decl (BUILTINS_LOCATION, VAR_DECL, - get_identifier_from_string (name), type_tree); - DECL_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - TREE_STATIC (decl) = 0; - DECL_ARTIFICIAL (decl) = 1; - if (!asm_name.empty ()) - SET_DECL_ASSEMBLER_NAME (decl, get_identifier_from_string (asm_name)); - rust_preserve_from_gc (decl); - return new Bvariable (decl); -} - -// Create a named immutable initialized data structure. - -Bvariable * -Gcc_backend::immutable_struct (const std::string &name, - const std::string &asm_name, bool is_hidden, - bool is_common, tree type_tree, - Location location) -{ - if (type_tree == error_mark_node) - return this->error_variable (); - gcc_assert (TREE_CODE (type_tree) == RECORD_TYPE); - tree decl = build_decl (location.gcc_location (), VAR_DECL, - get_identifier_from_string (name), - build_qualified_type (type_tree, TYPE_QUAL_CONST)); - TREE_STATIC (decl) = 1; - TREE_USED (decl) = 1; - TREE_READONLY (decl) = 1; - TREE_CONSTANT (decl) = 1; - DECL_ARTIFICIAL (decl) = 1; - if (!is_hidden) - TREE_PUBLIC (decl) = 1; - if (!asm_name.empty ()) - SET_DECL_ASSEMBLER_NAME (decl, get_identifier_from_string (asm_name)); - - // When the initializer for one immutable_struct refers to another, - // it needs to know the visibility of the referenced struct so that - // compute_reloc_for_constant will return the right value. On many - // systems calling make_decl_one_only will mark the decl as weak, - // which will change the return value of compute_reloc_for_constant. - // We can't reliably call make_decl_one_only yet, because we don't - // yet know the initializer. This issue doesn't arise in C because - // Rust initializers, unlike C initializers, can be indirectly - // recursive. To ensure that compute_reloc_for_constant computes - // the right value if some other initializer refers to this one, we - // mark this symbol as weak here. We undo that below in - // immutable_struct_set_init before calling mark_decl_one_only. - if (is_common) - DECL_WEAK (decl) = 1; - - // We don't call rest_of_decl_compilation until we have the - // initializer. - - rust_preserve_from_gc (decl); - return new Bvariable (decl); -} - -// Set the initializer for a variable created by immutable_struct. -// This is where we finish compiling the variable. - -void -Gcc_backend::immutable_struct_set_init (Bvariable *var, const std::string &, - bool, bool is_common, tree, Location, - tree init_tree) -{ - tree decl = var->get_decl (); - if (decl == error_mark_node || init_tree == error_mark_node) - return; - - DECL_INITIAL (decl) = init_tree; - - // Now that DECL_INITIAL is set, we can't call make_decl_one_only. - // See the comment where DECL_WEAK is set in immutable_struct. - if (is_common) - { - DECL_WEAK (decl) = 0; - make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); - } - - // These variables are often unneeded in the final program, so put - // them in their own section so that linker GC can discard them. - resolve_unique_section (decl, compute_reloc_for_constant (init_tree), 1); - - rest_of_decl_compilation (decl, 1, 0); -} - -// Return a reference to an immutable initialized data structure -// defined in another package. - -Bvariable * -Gcc_backend::immutable_struct_reference (const std::string &name, - const std::string &asm_name, - tree type_tree, Location location) -{ - if (type_tree == error_mark_node) - return this->error_variable (); - gcc_assert (TREE_CODE (type_tree) == RECORD_TYPE); - tree decl = build_decl (location.gcc_location (), VAR_DECL, - get_identifier_from_string (name), - build_qualified_type (type_tree, TYPE_QUAL_CONST)); - TREE_READONLY (decl) = 1; - TREE_CONSTANT (decl) = 1; - DECL_ARTIFICIAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - DECL_EXTERNAL (decl) = 1; - if (!asm_name.empty ()) - SET_DECL_ASSEMBLER_NAME (decl, get_identifier_from_string (asm_name)); - rust_preserve_from_gc (decl); - return new Bvariable (decl); -} - // Make a label. tree |