public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] gccrs const folding port: continue porting potential_constant_expression_1() Date: Mon, 29 Aug 2022 15:32:38 +0000 (GMT) [thread overview] Message-ID: <20220829153238.CF370385AC20@sourceware.org> (raw) https://gcc.gnu.org/g:b394fe4571f6c6207c1135da1297bf44f750bbf4 commit b394fe4571f6c6207c1135da1297bf44f750bbf4 Author: Faisal Abbas <90.abbasfaisal@gmail.com> Date: Sun Jul 10 12:38:12 2022 +0100 gccrs const folding port: continue porting potential_constant_expression_1() Following functions are ported in this changeset: - get_fileinfo - cxx_make_type - build_min_array_type - identifier_p Following structs are ported in this changeset: - c_fileinfo Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com> Diff: --- gcc/rust/backend/rust-tree.cc | 62 ++++++++++++++++++++++++++++++ gcc/rust/backend/rust-tree.h | 89 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 150 insertions(+), 1 deletion(-) diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc index 4359c3de987..73c50a4cc2c 100644 --- a/gcc/rust/backend/rust-tree.cc +++ b/gcc/rust/backend/rust-tree.cc @@ -21,6 +21,7 @@ #include "stringpool.h" #include "attribs.h" #include "escaped_string.h" +#include "libiberty.h" namespace Rust { @@ -1463,4 +1464,65 @@ maybe_add_lang_type_raw (tree t) return true; } +// forked from gcc/c-family/c-lex.cc get_fileinfo + +static splay_tree file_info_tree; + +struct c_fileinfo * +get_fileinfo (const char *name) +{ + splay_tree_node n; + struct c_fileinfo *fi; + + if (!file_info_tree) + file_info_tree = splay_tree_new (splay_tree_compare_strings, 0, + splay_tree_delete_pointers); + + n = splay_tree_lookup (file_info_tree, (splay_tree_key) name); + if (n) + return (struct c_fileinfo *) n->value; + + fi = XNEW (struct c_fileinfo); + fi->time = 0; + fi->interface_only = 0; + fi->interface_unknown = 1; + splay_tree_insert (file_info_tree, (splay_tree_key) name, + (splay_tree_value) fi); + return fi; +} + +// forked from gcc/cp/lex.cc cxx_make_type + +tree +cxx_make_type (enum tree_code code MEM_STAT_DECL) +{ + tree t = make_node (code PASS_MEM_STAT); + + if (maybe_add_lang_type_raw (t)) + { + /* Set up some flags that give proper default behavior. */ + struct c_fileinfo *finfo = get_fileinfo (LOCATION_FILE (input_location)); + SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, finfo->interface_unknown); + CLASSTYPE_INTERFACE_ONLY (t) = finfo->interface_only; + } + + if (code == RECORD_TYPE || code == UNION_TYPE) + TYPE_CXX_ODR_P (t) = 1; + + return t; +} + +// forked from gcc/cp/tree.cc build_min_array_type + +/* Build an ARRAY_TYPE without laying it out. */ + +static tree +build_min_array_type (tree elt_type, tree index_type) +{ + tree t = cxx_make_type (ARRAY_TYPE); + TREE_TYPE (t) = elt_type; + TYPE_DOMAIN (t) = index_type; + return t; +} + } // namespace Rust diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h index 99ec33c640d..e3522683372 100644 --- a/gcc/rust/backend/rust-tree.h +++ b/gcc/rust/backend/rust-tree.h @@ -23,6 +23,7 @@ #include "coretypes.h" #include "tree.h" #include "cpplib.h" +#include "splay-tree.h" /* Returns true if NODE is a pointer. */ #define TYPE_PTR_P(NODE) (TREE_CODE (NODE) == POINTER_TYPE) @@ -677,7 +678,7 @@ extern GTY (()) tree cp_global_trees[CPTI_MAX]; pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true, before using this macro. */ #define TYPE_PTRMEMFUNC_FN_TYPE(NODE) \ - (cp_build_qualified_type (TREE_TYPE (TYPE_FIELDS (NODE)), \ + (rs_build_qualified_type (TREE_TYPE (TYPE_FIELDS (NODE)), \ rs_type_quals (NODE))) /* As above, but can be used in places that want an lvalue at the expense @@ -733,6 +734,17 @@ extern GTY (()) tree cp_global_trees[CPTI_MAX]; /* The expression in question for a DECLTYPE_TYPE. */ #define DECLTYPE_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (DECLTYPE_TYPE_CHECK (NODE))) +#define SET_CLASSTYPE_INTERFACE_UNKNOWN_X(NODE, X) \ + (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = !!(X)) + +/* Nonzero if this class is included from a header file which employs + `#pragma interface', and it is not included in its implementation file. */ +#define CLASSTYPE_INTERFACE_ONLY(NODE) \ + (LANG_TYPE_CLASS_CHECK (NODE)->interface_only) + +#define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE))) +#define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE))) + // Below macros are copied from gcc/c-family/c-common.h /* In a FIELD_DECL, nonzero if the decl was originally a bitfield. */ @@ -798,6 +810,24 @@ extern GTY (()) tree cp_global_trees[CPTI_MAX]; // Above macros are copied from gcc/cp/name-lookup.cc +// forked from gcc/c-family/c-common.h c_fileinfo + +/* Information recorded about each file examined during compilation. */ + +struct c_fileinfo +{ + int time; /* Time spent in the file. */ + + /* Flags used only by C++. + INTERFACE_ONLY nonzero means that we are in an "interface" section + of the compiler. INTERFACE_UNKNOWN nonzero means we cannot trust + the value of INTERFACE_ONLY. If INTERFACE_UNKNOWN is zero and + INTERFACE_ONLY is zero, it means that we are responsible for + exporting definitions that others might need. */ + short interface_only; + short interface_unknown; +}; + // forked from gcc/cp/name-lookup.h /* Datatype that represents binding established by a declaration between @@ -1286,6 +1316,50 @@ inline tree ovl_first (tree) ATTRIBUTE_PURE; inline bool type_unknown_p (const_tree); +extern tree +lookup_add (tree fns, tree lookup); + +extern tree +ovl_make (tree fn, tree next = NULL_TREE); + +extern int is_overloaded_fn (tree) ATTRIBUTE_PURE; + +extern bool maybe_add_lang_type_raw (tree); + +extern rs_ref_qualifier type_memfn_rqual (const_tree); + +extern bool builtin_pack_fn_p (tree); + +extern tree make_conv_op_name (tree); + +extern int type_memfn_quals (const_tree); + +struct c_fileinfo * +get_fileinfo (const char *); + +extern tree +cxx_make_type (enum tree_code CXX_MEM_STAT_INFO); + +extern tree +build_cplus_array_type (tree, tree, int is_dep = -1); + +extern bool is_byte_access_type (tree); + +// forked from gcc/cp/cp-tree.h + +enum +{ + ce_derived, + ce_type, + ce_normal, + ce_exact +}; + +extern tree +rs_build_qualified_type_real (tree, int, tsubst_flags_t); +#define rs_build_qualified_type(TYPE, QUALS) \ + rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error) + extern tree rs_walk_subtrees (tree *, int *, walk_tree_fn, void *, hash_set<tree> *); #define rs_walk_tree(tp, func, data, pset) \ @@ -1354,6 +1428,19 @@ class_of_this_parm (const_tree fntype) { return TREE_TYPE (type_of_this_parm (fntype)); } + +// forked from gcc/cp/cp-tree.h identifier_p + +/* Return a typed pointer version of T if it designates a + C++ front-end identifier. */ +inline lang_identifier * +identifier_p (tree t) +{ + if (TREE_CODE (t) == IDENTIFIER_NODE) + return (lang_identifier *) t; + return NULL; +} + } // namespace Rust #endif // RUST_TREE
next reply other threads:[~2022-08-29 15:32 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-29 15:32 Thomas Schwinge [this message] -- strict thread matches above, loose matches on Subject: below -- 2022-08-29 15:33 Thomas Schwinge 2022-08-29 15:33 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-08-29 15:32 Thomas Schwinge 2022-06-30 18:50 Thomas Schwinge
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220829153238.CF370385AC20@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).