diff options
author | David Faust <david.faust@oracle.com> | 2021-11-15 11:27:35 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2021-11-16 13:00:32 -0800 |
commit | 97c98deec7d4c698d7b8ee8a4e56888d5d85b8bd (patch) | |
tree | ae5b3ebbe82642c8f9398505c61e64ca387adbe5 /gcc | |
parent | 5514d9cec51d5ec7cc30dd6cdbfadfdddbe0aab3 (diff) | |
download | gcc-97c98deec7d4c698d7b8ee8a4e56888d5d85b8bd.zip gcc-97c98deec7d4c698d7b8ee8a4e56888d5d85b8bd.tar.gz gcc-97c98deec7d4c698d7b8ee8a4e56888d5d85b8bd.tar.bz2 |
rust-backend.h: remove unused function prototypes
These functions are holdovers from the original port from the Go
frontend for Rust. They aren't used anywhere, so delete them from
rust-backend.h and rust-gcc.cc.
(set_)placeholder_xxx_type ()
(is_)circular_pointer_type ()
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/rust-backend.h | 83 | ||||
-rw-r--r-- | gcc/rust/rust-gcc.cc | 165 |
2 files changed, 0 insertions, 248 deletions
diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h index 705f7dc..340284f 100644 --- a/gcc/rust/rust-backend.h +++ b/gcc/rust/rust-backend.h @@ -229,66 +229,6 @@ public: // Get an array type. virtual Btype *array_type (Btype *element_type, Bexpression *length) = 0; - // Create a placeholder pointer type. This is used for a named - // pointer type, since in Go a pointer type may refer to itself. - // NAME is the name of the type, and the location is where the named - // type is defined. This function is also used for unnamed function - // types with multiple results, in which case the type has no name - // and NAME will be empty. FOR_FUNCTION is true if this is for a C - // pointer to function type. A Go func type is represented as a - // pointer to a struct, and the first field of the struct is a C - // pointer to function. The return value will later be passed as - // the first parameter to set_placeholder_pointer_type or - // set_placeholder_function_type. - virtual Btype *placeholder_pointer_type (const std::string &name, Location, - bool for_function) - = 0; - - // Fill in a placeholder pointer type as a pointer. This takes a - // type returned by placeholder_pointer_type and arranges for it to - // point to the type that TO_TYPE points to (that is, PLACEHOLDER - // becomes the same type as TO_TYPE). Returns true on success, - // false on failure. - virtual bool set_placeholder_pointer_type (Btype *placeholder, Btype *to_type) - = 0; - - // Fill in a placeholder pointer type as a function. This takes a - // type returned by placeholder_pointer_type and arranges for it to - // become a real Go function type (which corresponds to a C/C++ - // pointer to function type). FT will be something returned by the - // function_type method. Returns true on success, false on failure. - virtual bool set_placeholder_function_type (Btype *placeholder, Btype *ft) - = 0; - - // Create a placeholder struct type. This is used for a named - // struct type, as with placeholder_pointer_type. It is also used - // for interface types, in which case NAME will be the empty string. - virtual Btype *placeholder_struct_type (const std::string &name, Location) - = 0; - - // Fill in a placeholder struct type. This takes a type returned by - // placeholder_struct_type and arranges for it to become a real - // struct type. The parameter is as for struct_type. Returns true - // on success, false on failure. - virtual bool - set_placeholder_struct_type (Btype *placeholder, - const std::vector<Btyped_identifier> &fields) - = 0; - - // Create a placeholder array type. This is used for a named array - // type, as with placeholder_pointer_type, to handle cases like - // type A []*A. - virtual Btype *placeholder_array_type (const std::string &name, Location) = 0; - - // Fill in a placeholder array type. This takes a type returned by - // placeholder_array_type and arranges for it to become a real array - // type. The parameters are as for array_type. Returns true on - // success, false on failure. - virtual bool set_placeholder_array_type (Btype *placeholder, - Btype *element_type, - Bexpression *length) - = 0; - // Return a named version of a type. The location is the location // of the type definition. This will not be called for a type // created via placeholder_pointer_type, placeholder_struct_type, or @@ -296,29 +236,6 @@ public: // struct, or array type in a case like "type P *byte; type Q P".) virtual Btype *named_type (const std::string &name, Btype *, Location) = 0; - // Create a marker for a circular pointer type. Go pointer and - // function types can refer to themselves in ways that are not - // permitted in C/C++. When a circular type is found, this function - // is called for the circular reference. This permits the backend - // to decide how to handle such a type. PLACEHOLDER is the - // placeholder type which has already been created; if the backend - // is prepared to handle a circular pointer type, it may simply - // return PLACEHOLDER. FOR_FUNCTION is true if this is for a - // function type. - // - // For "type P *P" the sequence of calls will be - // bt1 = placeholder_pointer_type(); - // bt2 = circular_pointer_type(bt1, false); - // set_placeholder_pointer_type(bt1, bt2); - virtual Btype *circular_pointer_type (Btype *placeholder, bool for_function) - = 0; - - // Return whether the argument could be a special type created by - // circular_pointer_type. This is used to introduce explicit type - // conversions where needed. If circular_pointer_type returns its - // PLACEHOLDER parameter, this may safely always return false. - virtual bool is_circular_pointer_type (Btype *) = 0; - // Return the size of a type. virtual int64_t type_size (Btype *) = 0; diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index efc7823..65fc1f3 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -274,27 +274,8 @@ public: Btype *array_type (Btype *, Bexpression *); - Btype *placeholder_pointer_type (const std::string &, Location, bool); - - bool set_placeholder_pointer_type (Btype *, Btype *); - - bool set_placeholder_function_type (Btype *, Btype *); - - Btype *placeholder_struct_type (const std::string &, Location); - - bool set_placeholder_struct_type (Btype *placeholder, - const std::vector<Btyped_identifier> &); - - Btype *placeholder_array_type (const std::string &, Location); - - bool set_placeholder_array_type (Btype *, Btype *, Bexpression *); - Btype *named_type (const std::string &, Btype *, Location); - Btype *circular_pointer_type (Btype *, bool); - - bool is_circular_pointer_type (Btype *); - int64_t type_size (Btype *); int64_t type_alignment (Btype *); @@ -1222,136 +1203,6 @@ Gcc_backend::fill_in_array (Btype *fill, Btype *element_type, return fill; } -// Create a placeholder for a pointer type. - -Btype * -Gcc_backend::placeholder_pointer_type (const std::string &name, - Location location, bool) -{ - tree ret = build_distinct_type_copy (ptr_type_node); - if (!name.empty ()) - { - tree decl = build_decl (location.gcc_location (), TYPE_DECL, - get_identifier_from_string (name), ret); - TYPE_NAME (ret) = decl; - } - return this->make_type (ret); -} - -// Set the real target type for a placeholder pointer type. - -bool -Gcc_backend::set_placeholder_pointer_type (Btype *placeholder, Btype *to_type) -{ - tree pt = placeholder->get_tree (); - if (pt == error_mark_node) - return false; - gcc_assert (TREE_CODE (pt) == POINTER_TYPE); - tree tt = to_type->get_tree (); - if (tt == error_mark_node) - { - placeholder->set_tree (error_mark_node); - return false; - } - gcc_assert (TREE_CODE (tt) == POINTER_TYPE); - TREE_TYPE (pt) = TREE_TYPE (tt); - TYPE_CANONICAL (pt) = TYPE_CANONICAL (tt); - if (TYPE_NAME (pt) != NULL_TREE) - { - // Build the data structure gcc wants to see for a typedef. - tree copy = build_variant_type_copy (pt); - TYPE_NAME (copy) = NULL_TREE; - DECL_ORIGINAL_TYPE (TYPE_NAME (pt)) = copy; - } - return true; -} - -// Set the real values for a placeholder function type. - -bool -Gcc_backend::set_placeholder_function_type (Btype *placeholder, Btype *ft) -{ - return this->set_placeholder_pointer_type (placeholder, ft); -} - -// Create a placeholder for a struct type. - -Btype * -Gcc_backend::placeholder_struct_type (const std::string &name, - Location location) -{ - tree ret = make_node (RECORD_TYPE); - if (!name.empty ()) - { - tree decl = build_decl (location.gcc_location (), TYPE_DECL, - get_identifier_from_string (name), ret); - TYPE_NAME (ret) = decl; - - // The struct type that eventually replaces this placeholder will require - // structural equality. The placeholder must too, so that the requirement - // for structural equality propagates to references that are constructed - // before the replacement occurs. - SET_TYPE_STRUCTURAL_EQUALITY (ret); - } - return this->make_type (ret); -} - -// Fill in the fields of a placeholder struct type. - -bool -Gcc_backend::set_placeholder_struct_type ( - Btype *placeholder, const std::vector<Btyped_identifier> &fields) -{ - tree t = placeholder->get_tree (); - gcc_assert (TREE_CODE (t) == RECORD_TYPE && TYPE_FIELDS (t) == NULL_TREE); - Btype *r = this->fill_in_fields (placeholder, fields); - - if (TYPE_NAME (t) != NULL_TREE) - { - // Build the data structure gcc wants to see for a typedef. - tree copy = build_distinct_type_copy (t); - TYPE_NAME (copy) = NULL_TREE; - DECL_ORIGINAL_TYPE (TYPE_NAME (t)) = copy; - TYPE_SIZE (copy) = NULL_TREE; - Btype *bc = this->make_type (copy); - this->fill_in_fields (bc, fields); - delete bc; - } - - return r->get_tree () != error_mark_node; -} - -// Create a placeholder for an array type. - -Btype * -Gcc_backend::placeholder_array_type (const std::string &name, Location location) -{ - tree ret = make_node (ARRAY_TYPE); - tree decl = build_decl (location.gcc_location (), TYPE_DECL, - get_identifier_from_string (name), ret); - TYPE_NAME (ret) = decl; - return this->make_type (ret); -} - -// Fill in the fields of a placeholder array type. - -bool -Gcc_backend::set_placeholder_array_type (Btype *placeholder, - Btype *element_btype, - Bexpression *length) -{ - tree t = placeholder->get_tree (); - gcc_assert (TREE_CODE (t) == ARRAY_TYPE && TREE_TYPE (t) == NULL_TREE); - Btype *r = this->fill_in_array (placeholder, element_btype, length); - - // Build the data structure gcc wants to see for a typedef. - tree copy = build_distinct_type_copy (t); - TYPE_NAME (copy) = NULL_TREE; - DECL_ORIGINAL_TYPE (TYPE_NAME (t)) = copy; - - return r->get_tree () != error_mark_node; -} - // Return a named version of a type. Btype * @@ -1385,22 +1236,6 @@ Gcc_backend::named_type (const std::string &name, Btype *btype, return this->make_type (copy); } -// Return a pointer type used as a marker for a circular type. - -Btype * -Gcc_backend::circular_pointer_type (Btype *, bool) -{ - return this->make_type (ptr_type_node); -} - -// Return whether we might be looking at a circular type. - -bool -Gcc_backend::is_circular_pointer_type (Btype *btype) -{ - return btype->get_tree () == ptr_type_node; -} - // Return the size of a type. int64_t |