aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-12-04 19:14:59 +0000
committerGitHub <noreply@github.com>2022-12-04 19:14:59 +0000
commit22329b03a6e0a3381d907745205012cf290b3c2a (patch)
treef6c9616a3c3ab3c69c5d5be7a020934162fb05e7 /gcc/rust/backend
parent402118688f56d88d213572ee55a4245eec83b25f (diff)
parent071e8b001c7834c38dc4db697dd10d26eba67149 (diff)
downloadgcc-22329b03a6e0a3381d907745205012cf290b3c2a.zip
gcc-22329b03a6e0a3381d907745205012cf290b3c2a.tar.gz
gcc-22329b03a6e0a3381d907745205012cf290b3c2a.tar.bz2
Merge #1676
1676: Fix regressions in 32 bit mode and gcc4.8 builds r=CohenArthur a=philberty This reverts commit 9657c328d0cdda49b7985c3ee727781a387e128b. This reverts commit fc59d137491ce393797dfec1d8cd5251a41b5f67. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-builtins.cc350
-rw-r--r--gcc/rust/backend/rust-builtins.h118
-rw-r--r--gcc/rust/backend/rust-compile-base.cc4
-rw-r--r--gcc/rust/backend/rust-compile-base.h6
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc61
-rw-r--r--gcc/rust/backend/rust-compile-expr.h13
-rw-r--r--gcc/rust/backend/rust-compile-fnparam.cc2
-rw-r--r--gcc/rust/backend/rust-compile-implitem.h2
-rw-r--r--gcc/rust/backend/rust-compile-intrinsic.cc43
-rw-r--r--gcc/rust/backend/rust-compile-pattern.cc2
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.cc12
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.h3
-rw-r--r--gcc/rust/backend/rust-compile-type.cc8
-rw-r--r--gcc/rust/backend/rust-compile.cc12
-rw-r--r--gcc/rust/backend/rust-constexpr.cc6
-rw-r--r--gcc/rust/backend/rust-tree.cc38
16 files changed, 233 insertions, 447 deletions
diff --git a/gcc/rust/backend/rust-builtins.cc b/gcc/rust/backend/rust-builtins.cc
index ec65026..66b3bec 100644
--- a/gcc/rust/backend/rust-builtins.cc
+++ b/gcc/rust/backend/rust-builtins.cc
@@ -14,13 +14,8 @@
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-#include "rust-diagnostics.h"
-#include "rust-system.h"
#include "rust-builtins.h"
-#include "target.h"
-#include "stringpool.h"
-
namespace Rust {
namespace Compile {
@@ -38,275 +33,154 @@ BuiltinsContext::get ()
bool
BuiltinsContext::lookup_simple_builtin (const std::string &name, tree *builtin)
{
- auto *to_search = &name;
-
auto it = rust_intrinsic_to_gcc_builtin.find (name);
- if (it != rust_intrinsic_to_gcc_builtin.end ())
- to_search = &it->second;
+ if (it == rust_intrinsic_to_gcc_builtin.end ())
+ return false;
- return lookup_gcc_builtin (*to_search, builtin);
+ return lookup_gcc_builtin (it->second, builtin);
}
BuiltinsContext::BuiltinsContext () { setup (); }
-/**
- * Define a function type according to `builtin-types.def`
- *
- * *Heavily* inspired by the D frontend's `def_fn_type` function
- */
void
-BuiltinsContext::define_function_type (Type def_idx, Type ret_idx,
- bool is_variadic, size_t n, ...)
+BuiltinsContext::setup_overflow_fns ()
{
- va_list list;
- va_start (list, n);
-
- auto args = std::vector<tree> ();
-
- for (size_t i = 0; i < n; i++)
- {
- auto arg_idx = va_arg (list, size_t);
- auto arg_type = builtin_types[arg_idx];
-
- args.emplace_back (arg_type);
- }
-
- auto return_type = builtin_types[ret_idx];
- if (return_type == error_mark_node)
- {
- va_end (list);
- return;
- }
-
- auto fn_type = NULL_TREE;
- if (is_variadic)
- fn_type = build_varargs_function_type_array (return_type, n, args.data ());
- else
- fn_type = build_function_type_array (return_type, n, args.data ());
-
- builtin_types[def_idx] = fn_type;
- va_end (list);
+ tree overflow_type
+ = build_varargs_function_type_list (boolean_type_node, NULL_TREE);
+
+ define_builtin ("add_overflow", BUILT_IN_ADD_OVERFLOW,
+ "__builtin_add_overflow", "add_overflow", overflow_type, 0);
+ define_builtin ("sub_overflow", BUILT_IN_SUB_OVERFLOW,
+ "__builtin_sub_overflow", "sub_overflow", overflow_type, 0);
+ define_builtin ("mul_overflow", BUILT_IN_MUL_OVERFLOW,
+ "__builtin_mul_overflow", "mul_overflow", overflow_type, 0);
}
-// Taken directly from the D frontend
-static void
-build_c_type_nodes (void)
+void
+BuiltinsContext::setup_math_fns ()
{
- string_type_node = build_pointer_type (char_type_node);
- const_string_type_node = build_pointer_type (
- build_qualified_type (char_type_node, TYPE_QUAL_CONST));
-
- if (strcmp (UINTMAX_TYPE, "unsigned int") == 0)
- {
- intmax_type_node = integer_type_node;
- uintmax_type_node = unsigned_type_node;
- }
- else if (strcmp (UINTMAX_TYPE, "long unsigned int") == 0)
- {
- intmax_type_node = long_integer_type_node;
- uintmax_type_node = long_unsigned_type_node;
- }
- else if (strcmp (UINTMAX_TYPE, "long long unsigned int") == 0)
- {
- intmax_type_node = long_long_integer_type_node;
- uintmax_type_node = long_long_unsigned_type_node;
- }
- else
- gcc_unreachable ();
+ tree math_function_type_f32
+ = build_function_type_list (float_type_node, float_type_node, NULL_TREE);
- signed_size_type_node = signed_type_for (size_type_node);
- wint_type_node = unsigned_type_node;
- pid_type_node = integer_type_node;
+ define_builtin ("sinf32", BUILT_IN_SINF, "__builtin_sinf", "sinf",
+ math_function_type_f32, builtin_const);
+ define_builtin ("sqrtf32", BUILT_IN_SQRTF, "__builtin_sqrtf", "sqrtf",
+ math_function_type_f32, builtin_const);
}
-/**
- * Define all builtin types in the `builtin_types` array
- */
void
-BuiltinsContext::define_builtin_types ()
+BuiltinsContext::setup_atomic_fns ()
{
- // This is taken directly from the D frontend's handling of builtins
- auto va_list_ref_type_node = build_reference_type (va_list_type_node);
- auto va_list_arg_type_node = va_list_type_node;
-
- build_c_type_nodes ();
-
- auto builtin_type_for_size = [] (int size, bool unsignedp) {
- tree type = lang_hooks.types.type_for_size (size, unsignedp);
- return type ? type : error_mark_node;
+ auto atomic_store_type
+ = build_varargs_function_type_list (void_type_node, NULL_TREE);
+ auto atomic_load_type = [] (tree ret_type_node) {
+ return build_function_type_list (ret_type_node,
+ ptr_type_node, // const_ptr_type_node?
+ integer_type_node, NULL_TREE);
};
-#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) builtin_types[ENUM] = VALUE;
-#define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
- define_function_type (ENUM, RETURN, 0, 0);
-#define DEF_FUNCTION_TYPE_1(ENUM, RETURN, A1) \
- define_function_type (ENUM, RETURN, 0, 1, A1);
-#define DEF_FUNCTION_TYPE_2(ENUM, RETURN, A1, A2) \
- define_function_type (ENUM, RETURN, 0, 2, A1, A2);
-#define DEF_FUNCTION_TYPE_3(ENUM, RETURN, A1, A2, A3) \
- define_function_type (ENUM, RETURN, 0, 3, A1, A2, A3);
-#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, A1, A2, A3, A4) \
- define_function_type (ENUM, RETURN, 0, 4, A1, A2, A3, A4);
-#define DEF_FUNCTION_TYPE_5(ENUM, RETURN, A1, A2, A3, A4, A5) \
- define_function_type (ENUM, RETURN, 0, 5, A1, A2, A3, A4, A5);
-#define DEF_FUNCTION_TYPE_6(ENUM, RETURN, A1, A2, A3, A4, A5, A6) \
- define_function_type (ENUM, RETURN, 0, 6, A1, A2, A3, A4, A5, A6);
-#define DEF_FUNCTION_TYPE_7(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7) \
- define_function_type (ENUM, RETURN, 0, 7, A1, A2, A3, A4, A5, A6, A7);
-#define DEF_FUNCTION_TYPE_8(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8) \
- define_function_type (ENUM, RETURN, 0, 8, A1, A2, A3, A4, A5, A6, A7, A8);
-#define DEF_FUNCTION_TYPE_9(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, A9) \
- define_function_type (ENUM, RETURN, 0, 9, A1, A2, A3, A4, A5, A6, A7, A8, A9);
-#define DEF_FUNCTION_TYPE_10(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, A9, \
- A10) \
- define_function_type (ENUM, RETURN, 0, 10, A1, A2, A3, A4, A5, A6, A7, A8, \
- A9, A10);
-#define DEF_FUNCTION_TYPE_11(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, A9, \
- A10, A11) \
- define_function_type (ENUM, RETURN, 0, 11, A1, A2, A3, A4, A5, A6, A7, A8, \
- A9, A10, A11);
-#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
- define_function_type (ENUM, RETURN, 1, 0);
-#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, A1) \
- define_function_type (ENUM, RETURN, 1, 1, A1);
-#define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, A1, A2) \
- define_function_type (ENUM, RETURN, 1, 2, A1, A2);
-#define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, A1, A2, A3) \
- define_function_type (ENUM, RETURN, 1, 3, A1, A2, A3);
-#define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, A1, A2, A3, A4) \
- define_function_type (ENUM, RETURN, 1, 4, A1, A2, A3, A4);
-#define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, A1, A2, A3, A4, A5) \
- define_function_type (ENUM, RETURN, 1, 5, A1, A2, A3, A4, A5);
-#define DEF_FUNCTION_TYPE_VAR_6(ENUM, RETURN, A1, A2, A3, A4, A5, A6) \
- define_function_type (ENUM, RETURN, 1, 6, A1, A2, A3, A4, A5, A6);
-#define DEF_FUNCTION_TYPE_VAR_7(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7) \
- define_function_type (ENUM, RETURN, 1, 7, A1, A2, A3, A4, A5, A6, A7);
-#define DEF_FUNCTION_TYPE_VAR_11(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, \
- A9, A10, A11) \
- define_function_type (ENUM, RETURN, 1, 11, A1, A2, A3, A4, A5, A6, A7, A8, \
- A9, A10, A11);
-#define DEF_POINTER_TYPE(ENUM, TYPE) \
- builtin_types[ENUM] = build_pointer_type (builtin_types[TYPE]);
-
-#include "builtin-types.def"
-
-#undef DEF_PRIMITIVE_TYPE
-#undef DEF_FUNCTION_TYPE_1
-#undef DEF_FUNCTION_TYPE_2
-#undef DEF_FUNCTION_TYPE_3
-#undef DEF_FUNCTION_TYPE_4
-#undef DEF_FUNCTION_TYPE_5
-#undef DEF_FUNCTION_TYPE_6
-#undef DEF_FUNCTION_TYPE_7
-#undef DEF_FUNCTION_TYPE_8
-#undef DEF_FUNCTION_TYPE_9
-#undef DEF_FUNCTION_TYPE_10
-#undef DEF_FUNCTION_TYPE_11
-#undef DEF_FUNCTION_TYPE_VAR_0
-#undef DEF_FUNCTION_TYPE_VAR_1
-#undef DEF_FUNCTION_TYPE_VAR_2
-#undef DEF_FUNCTION_TYPE_VAR_3
-#undef DEF_FUNCTION_TYPE_VAR_4
-#undef DEF_FUNCTION_TYPE_VAR_5
-#undef DEF_FUNCTION_TYPE_VAR_6
-#undef DEF_FUNCTION_TYPE_VAR_7
-#undef DEF_FUNCTION_TYPE_VAR_11
-#undef DEF_POINTER_TYPE
-
- builtin_types[Type::BT_LAST] = NULL_TREE;
+ // FIXME: These should be the definition for the generic version of the
+ // atomic_store builtins, but I cannot get them to work properly. Revisit
+ // later. define_builtin ("atomic_store", BUILT_IN_ATOMIC_STORE,
+ // "__atomic_store", NULL,
+ // atomic_store_type, 0);
+ // define_builtin ("atomic_store_n", BUILT_IN_ATOMIC_STORE_N,
+ // "__atomic_store_n",
+ // NULL, atomic_store_type, 0);
+
+ define_builtin ("atomic_store_1", BUILT_IN_ATOMIC_STORE_1, "__atomic_store_1",
+ NULL, atomic_store_type, 0);
+ define_builtin ("atomic_store_2", BUILT_IN_ATOMIC_STORE_2, "__atomic_store_2",
+ NULL, atomic_store_type, 0);
+ define_builtin ("atomic_store_4", BUILT_IN_ATOMIC_STORE_4, "__atomic_store_4",
+ NULL, atomic_store_type, 0);
+ define_builtin ("atomic_store_8", BUILT_IN_ATOMIC_STORE_8, "__atomic_store_8",
+ NULL, atomic_store_type, 0);
+ define_builtin ("atomic_store_16", BUILT_IN_ATOMIC_STORE_16,
+ "__atomic_store_16", NULL, atomic_store_type, 0);
+
+ define_builtin ("atomic_load_1", BUILT_IN_ATOMIC_LOAD_1, "__atomic_load_1",
+ NULL, atomic_load_type (integer_type_node), 0);
+ define_builtin ("atomic_load_2", BUILT_IN_ATOMIC_LOAD_2, "__atomic_load_2",
+ NULL, atomic_load_type (integer_type_node), 0);
+ define_builtin ("atomic_load_4", BUILT_IN_ATOMIC_LOAD_4, "__atomic_load_4",
+ NULL, atomic_load_type (integer_type_node), 0);
+ define_builtin ("atomic_load_8", BUILT_IN_ATOMIC_LOAD_8, "__atomic_load_8",
+ NULL, atomic_load_type (integer_type_node), 0);
}
-/**
- * Define all builtin attributes in the `builtin_types` array
- */
void
-BuiltinsContext::define_builtin_attributes ()
-
+BuiltinsContext::setup ()
{
- auto *built_in_attributes = builtin_attributes;
-
-#define DEF_ATTR_NULL_TREE(ENUM) built_in_attributes[(int) ENUM] = NULL_TREE;
-#define DEF_ATTR_INT(ENUM, VALUE) \
- built_in_attributes[ENUM] = build_int_cst (NULL_TREE, VALUE);
-#define DEF_ATTR_STRING(ENUM, VALUE) \
- built_in_attributes[ENUM] = build_string (strlen (VALUE), VALUE);
-#define DEF_ATTR_IDENT(ENUM, STRING) \
- built_in_attributes[ENUM] = get_identifier (STRING);
-#define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
- built_in_attributes[ENUM] \
- = tree_cons (built_in_attributes[PURPOSE], built_in_attributes[VALUE], \
- built_in_attributes[CHAIN]);
-#include "builtin-attrs.def"
-#undef DEF_ATTR_NULL_TREE
-#undef DEF_ATTR_INT
-#undef DEF_ATTR_STRING
-#undef DEF_ATTR_IDENT
-#undef DEF_ATTR_TREE_LIST
+ setup_math_fns ();
+ setup_overflow_fns ();
+ setup_atomic_fns ();
+
+ define_builtin ("unreachable", BUILT_IN_UNREACHABLE, "__builtin_unreachable",
+ NULL, build_function_type (void_type_node, void_list_node),
+ builtin_const | builtin_noreturn);
+
+ define_builtin ("abort", BUILT_IN_ABORT, "__builtin_abort", "abort",
+ build_function_type (void_type_node, void_list_node),
+ builtin_const | builtin_noreturn);
+
+ define_builtin ("breakpoint", BUILT_IN_TRAP, "__builtin_trap", "breakpoint",
+ build_function_type (void_type_node, void_list_node),
+ builtin_const | builtin_noreturn);
+
+ define_builtin ("memcpy", BUILT_IN_MEMCPY, "__builtin_memcpy", "memcpy",
+ build_function_type_list (build_pointer_type (void_type_node),
+ build_pointer_type (void_type_node),
+ build_pointer_type (void_type_node),
+ size_type_node, NULL_TREE),
+ 0);
+
+ define_builtin ("prefetch", BUILT_IN_PREFETCH, "__builtin_prefetch",
+ "prefetch",
+ build_varargs_function_type_list (
+ build_pointer_type (const_ptr_type_node), NULL_TREE),
+ builtin_const);
}
-/**
- * Define all builtin functions during the first initialization of the
- * `BuiltinsContext`.
- */
-void
-BuiltinsContext::define_builtins ()
+static void
+handle_flags (tree decl, int flags)
{
- auto *built_in_attributes = builtin_attributes;
- auto build_builtin = [this] (built_in_function fn_code, const char *fn_name,
- built_in_class fn_class, tree fn_type,
- bool fallback, tree attributes, bool implicit) {
- if (fn_type == error_mark_node)
- return;
-
- static auto to_skip = strlen ("__builtin_");
-
- auto libname = fn_name + to_skip;
- auto decl = add_builtin_function (fn_name, fn_type, fn_code, fn_class,
- fallback ? libname : NULL, attributes);
-
- set_builtin_decl (fn_code, decl, implicit);
-
- builtin_functions.insert ({std::string (fn_name), decl});
- };
-
-#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \
- NONANSI_P, ATTRS, IMPLICIT, COND) \
- if (NAME && COND) \
- build_builtin (ENUM, NAME, CLASS, builtin_types[TYPE], FALLBACK_P, \
- built_in_attributes[ATTRS], IMPLICIT);
-#include "builtins.def"
-#undef DEF_BUILTIN
+ if (flags & builtin_const)
+ TREE_READONLY (decl) = 1;
+ if (flags & builtin_noreturn)
+ TREE_READONLY (decl) = 1;
+ if (flags & builtin_novops)
+ DECL_IS_NOVOPS (decl) = 1;
}
-/**
- * Register direct mappings between Rust functions and GCC builtins
- */
void
-BuiltinsContext::register_rust_mappings ()
+BuiltinsContext::define_builtin (const std::string rust_name,
+ built_in_function bcode, const char *name,
+ const char *libname, tree fntype, int flags)
{
- rust_intrinsic_to_gcc_builtin = {
- {"sinf32", "__builtin_sinf"},
- {"sqrtf32", "__builtin_sqrtf"},
- {"unreachable", "__builtin_unreachable"},
- {"abort", "__builtin_abort"},
- };
-}
+ tree decl = add_builtin_function (name, fntype, bcode, BUILT_IN_NORMAL,
+ libname, NULL_TREE);
+ handle_flags (decl, flags);
+ set_builtin_decl (bcode, decl, true);
-void
-BuiltinsContext::setup ()
-{
- define_builtin_types ();
- define_builtin_attributes ();
- define_builtins ();
+ this->builtin_functions_[name] = decl;
+ if (libname != NULL)
+ {
+ decl = add_builtin_function (libname, fntype, bcode, BUILT_IN_NORMAL,
+ NULL, NULL_TREE);
+ handle_flags (decl, flags);
+
+ this->builtin_functions_[libname] = decl;
+ }
- register_rust_mappings ();
+ rust_intrinsic_to_gcc_builtin[rust_name] = name;
}
bool
BuiltinsContext::lookup_gcc_builtin (const std::string &name, tree *builtin)
{
- auto it = builtin_functions.find (name);
- if (it == builtin_functions.end ())
+ auto it = builtin_functions_.find (name);
+ if (it == builtin_functions_.end ())
return false;
*builtin = it->second;
diff --git a/gcc/rust/backend/rust-builtins.h b/gcc/rust/backend/rust-builtins.h
index 5052eda..c282510 100644
--- a/gcc/rust/backend/rust-builtins.h
+++ b/gcc/rust/backend/rust-builtins.h
@@ -21,7 +21,6 @@
#include "rust-tree.h"
#include "langhooks.h"
#include "tree.h"
-#include "selftest.h"
namespace Rust {
namespace Compile {
@@ -76,7 +75,6 @@ namespace Compile {
// _ => return None,
// };
// Some(cx.get_intrinsic(&llvm_name))
-
class BuiltinsContext
{
public:
@@ -85,110 +83,6 @@ public:
bool lookup_simple_builtin (const std::string &name, tree *builtin);
private:
- enum Type
- {
-#define DEF_PRIMITIVE_TYPE(NAME, V) NAME,
-#define DEF_FUNCTION_TYPE_0(NAME, R) NAME,
-#define DEF_FUNCTION_TYPE_1(NAME, R, A1) NAME,
-#define DEF_FUNCTION_TYPE_2(NAME, R, A1, A2) NAME,
-#define DEF_FUNCTION_TYPE_3(NAME, R, A1, A2, A3) NAME,
-#define DEF_FUNCTION_TYPE_4(NAME, R, A1, A2, A3, A4) NAME,
-#define DEF_FUNCTION_TYPE_5(NAME, R, A1, A2, A3, A4, A5) NAME,
-#define DEF_FUNCTION_TYPE_6(NAME, R, A1, A2, A3, A4, A5, A6) NAME,
-#define DEF_FUNCTION_TYPE_7(NAME, R, A1, A2, A3, A4, A5, A6, A7) NAME,
-#define DEF_FUNCTION_TYPE_8(NAME, R, A1, A2, A3, A4, A5, A6, A7, A8) NAME,
-#define DEF_FUNCTION_TYPE_9(NAME, R, A1, A2, A3, A4, A5, A6, A7, A8, A9) NAME,
-#define DEF_FUNCTION_TYPE_10(NAME, R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \
- NAME,
-#define DEF_FUNCTION_TYPE_11(NAME, R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, \
- A11) \
- NAME,
-#define DEF_FUNCTION_TYPE_VAR_0(NAME, R) NAME,
-#define DEF_FUNCTION_TYPE_VAR_1(NAME, R, A1) NAME,
-#define DEF_FUNCTION_TYPE_VAR_2(NAME, R, A1, A2) NAME,
-#define DEF_FUNCTION_TYPE_VAR_3(NAME, R, A1, A2, A3) NAME,
-#define DEF_FUNCTION_TYPE_VAR_4(NAME, R, A1, A2, A3, A4) NAME,
-#define DEF_FUNCTION_TYPE_VAR_5(NAME, R, A1, A2, A3, A4, A5) NAME,
-#define DEF_FUNCTION_TYPE_VAR_6(NAME, R, A1, A2, A3, A4, A5, A6) NAME,
-#define DEF_FUNCTION_TYPE_VAR_7(NAME, R, A1, A2, A3, A4, A5, A6, A7) NAME,
-#define DEF_FUNCTION_TYPE_VAR_11(NAME, R, A1, A2, A3, A4, A5, A6, A7, A8, A9, \
- A10, A11) \
- NAME,
-#define DEF_POINTER_TYPE(NAME, TYPE) NAME,
-
-#include "builtin-types.def"
-
-#undef DEF_PRIMITIVE_TYPE
-#undef DEF_FUNCTION_TYPE_0
-#undef DEF_FUNCTION_TYPE_1
-#undef DEF_FUNCTION_TYPE_2
-#undef DEF_FUNCTION_TYPE_3
-#undef DEF_FUNCTION_TYPE_4
-#undef DEF_FUNCTION_TYPE_5
-#undef DEF_FUNCTION_TYPE_6
-#undef DEF_FUNCTION_TYPE_7
-#undef DEF_FUNCTION_TYPE_8
-#undef DEF_FUNCTION_TYPE_9
-#undef DEF_FUNCTION_TYPE_10
-#undef DEF_FUNCTION_TYPE_11
-#undef DEF_FUNCTION_TYPE_VAR_0
-#undef DEF_FUNCTION_TYPE_VAR_1
-#undef DEF_FUNCTION_TYPE_VAR_2
-#undef DEF_FUNCTION_TYPE_VAR_3
-#undef DEF_FUNCTION_TYPE_VAR_4
-#undef DEF_FUNCTION_TYPE_VAR_5
-#undef DEF_FUNCTION_TYPE_VAR_6
-#undef DEF_FUNCTION_TYPE_VAR_7
-#undef DEF_FUNCTION_TYPE_VAR_11
-#undef DEF_POINTER_TYPE
-
- BT_LAST,
- };
-
- enum Attr
- {
-#define DEF_ATTR_NULL_TREE(ENUM) ENUM,
-#define DEF_ATTR_INT(ENUM, VALUE) ENUM,
-#define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
-#define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
-#define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
-
-#include "builtin-attrs.def"
-
-#undef DEF_ATTR_NULL_TREE
-#undef DEF_ATTR_INT
-#undef DEF_ATTR_STRING
-#undef DEF_ATTR_IDENT
-#undef DEF_ATTR_TREE_LIST
-
- ATTR_LAST,
- };
-
- /**
- * All builtin types, as defined in `builtin-types.def`
- *
- * This array is filled by the `define_builtin_types` method, during the first
- * initialization of the `BuiltinsContext`
- */
- tree builtin_types[Type::BT_LAST + 1];
-
- /**
- * Similarly, this array contains all builtin attributes, as defined in
- * `builtin-attr.def`
- *
- * This array is filled by the `define_builtin_attributes` method, during the
- * first initialization of the `BuiltinsContext`
- */
- tree builtin_attributes[Attr::ATTR_LAST + 1];
-
- void define_function_type (Type def, Type ret, bool is_variadic, size_t n,
- ...);
- void define_builtin_types ();
- void define_builtin_attributes ();
- void define_builtins ();
-
- void register_rust_mappings ();
-
BuiltinsContext ();
void setup_overflow_fns ();
@@ -197,10 +91,20 @@ private:
void setup ();
+ // Define a builtin function. BCODE is the builtin function code
+ // defined by builtins.def. NAME is the name of the builtin function.
+ // LIBNAME is the name of the corresponding library function, and is
+ // NULL if there isn't one. FNTYPE is the type of the function.
+ // CONST_P is true if the function has the const attribute.
+ // NORETURN_P is true if the function has the noreturn attribute.
+ void define_builtin (const std::string rust_name, built_in_function bcode,
+ const char *name, const char *libname, tree fntype,
+ int flags);
+
bool lookup_gcc_builtin (const std::string &name, tree *builtin);
// A mapping of the GCC built-ins exposed to GCC Rust.
- std::map<std::string, tree> builtin_functions;
+ std::map<std::string, tree> builtin_functions_;
std::map<std::string, std::string> rust_intrinsic_to_gcc_builtin;
};
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc
index 54f7a7d..a5643d2 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -354,7 +354,7 @@ HIRCompileBase::setup_abi_options (tree fndecl, ABI abi)
// it is fine to use ARRAY_REFs for vector subscripts on vector
// register variables.
bool
-HIRCompileBase::mark_addressable (tree exp)
+HIRCompileBase::mark_addressable (tree exp, Location locus)
{
tree x = exp;
@@ -418,7 +418,7 @@ HIRCompileBase::address_expression (tree expr, Location location)
if (expr == error_mark_node)
return error_mark_node;
- if (!mark_addressable (expr))
+ if (!mark_addressable (expr, location))
return error_mark_node;
return build_fold_addr_expr_loc (location.gcc_location (), expr);
diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h
index 0dd2549..4c20933 100644
--- a/gcc/rust/backend/rust-compile-base.h
+++ b/gcc/rust/backend/rust-compile-base.h
@@ -55,7 +55,7 @@ protected:
const TyTy::TypeBoundPredicate *predicate,
std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>>
&receiver_bounds,
- const TyTy::BaseType *root, Location locus);
+ const TyTy::BaseType *receiver, const TyTy::BaseType *root, Location locus);
bool verify_array_capacities (tree ltype, tree rtype, Location ltype_locus,
Location rtype_locus);
@@ -63,7 +63,7 @@ protected:
tree query_compile (HirId ref, TyTy::BaseType *lookup,
const HIR::PathIdentSegment &final_segment,
const Analysis::NodeMapping &mappings,
- Location expr_locus);
+ Location expr_locus, bool is_qualified_path);
tree resolve_adjustements (std::vector<Resolver::Adjustment> &adjustments,
tree expression, Location locus);
@@ -113,7 +113,7 @@ protected:
static tree indirect_expression (tree expr, Location locus);
- static bool mark_addressable (tree);
+ static bool mark_addressable (tree, Location);
static std::vector<Bvariable *>
compile_locals_for_block (Context *ctx, Resolver::Rib &rib, tree fndecl);
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 87794cd..b077a12 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1814,15 +1814,17 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
fn_expr
= get_fn_addr_from_dyn (dyn, receiver, fntype, self, expr.get_locus ());
- self = get_receiver_from_dyn (receiver, self, expr.get_locus ());
+ self = get_receiver_from_dyn (dyn, receiver, fntype, self,
+ expr.get_locus ());
}
else
{
// lookup compiled functions since it may have already been compiled
HIR::PathExprSegment method_name = expr.get_method_name ();
HIR::PathIdentSegment segment_name = method_name.get_segment ();
- fn_expr = resolve_method_address (fntype, ref, receiver, segment_name,
- expr.get_locus ());
+ fn_expr
+ = resolve_method_address (fntype, ref, receiver, segment_name,
+ expr.get_mappings (), expr.get_locus ());
}
// lookup the autoderef mappings
@@ -1923,7 +1925,9 @@ CompileExpr::get_fn_addr_from_dyn (const TyTy::DynamicObjectType *dyn,
}
tree
-CompileExpr::get_receiver_from_dyn (TyTy::BaseType *receiver, tree receiver_ref,
+CompileExpr::get_receiver_from_dyn (const TyTy::DynamicObjectType *dyn,
+ TyTy::BaseType *receiver,
+ TyTy::FnType *fntype, tree receiver_ref,
Location expr_locus)
{
// get any indirection sorted out
@@ -1942,6 +1946,7 @@ tree
CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref,
TyTy::BaseType *receiver,
HIR::PathIdentSegment &segment,
+ Analysis::NodeMapping expr_mappings,
Location expr_locus)
{
// lookup compiled functions since it may have already been compiled
@@ -2011,7 +2016,7 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref,
// implementation and we should just return error_mark_node
rust_assert (candidates.size () == 1);
- auto candidate = *candidates.begin ();
+ auto &candidate = *candidates.begin ();
rust_assert (candidate.is_impl_candidate ());
rust_assert (candidate.ty->get_kind () == TyTy::TypeKind::FNDEF);
TyTy::FnType *candidate_call = static_cast<TyTy::FnType *> (candidate.ty);
@@ -2035,8 +2040,7 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref,
tree
CompileExpr::resolve_operator_overload (
Analysis::RustLangItem::ItemType lang_item_type, HIR::OperatorExprMeta expr,
- tree lhs, tree rhs, HIR::Expr *lhs_expr,
- HIR::Expr * /* rhs_expr // FIXME: Reuse when needed */)
+ tree lhs, tree rhs, HIR::Expr *lhs_expr, HIR::Expr *rhs_expr)
{
TyTy::FnType *fntype;
bool is_op_overload = ctx->get_tyctx ()->lookup_operator_overload (
@@ -2069,8 +2073,9 @@ CompileExpr::resolve_operator_overload (
// lookup compiled functions since it may have already been compiled
HIR::PathIdentSegment segment_name (
Analysis::RustLangItem::ToString (lang_item_type));
- tree fn_expr = resolve_method_address (fntype, ref, receiver, segment_name,
- expr.get_locus ());
+ tree fn_expr
+ = resolve_method_address (fntype, ref, receiver, segment_name,
+ expr.get_mappings (), expr.get_locus ());
// lookup the autoderef mappings
std::vector<Resolver::Adjustment> *adjustments = nullptr;
@@ -2091,9 +2096,8 @@ CompileExpr::resolve_operator_overload (
}
tree
-CompileExpr::compile_bool_literal (
- const HIR::LiteralExpr &expr,
- const TyTy::BaseType * /* tyty FIXME: Reuse when needed */)
+CompileExpr::compile_bool_literal (const HIR::LiteralExpr &expr,
+ const TyTy::BaseType *tyty)
{
rust_assert (expr.get_lit_type () == HIR::Literal::BOOL);
@@ -2175,9 +2179,8 @@ CompileExpr::compile_float_literal (const HIR::LiteralExpr &expr,
}
tree
-CompileExpr::compile_char_literal (
- const HIR::LiteralExpr &expr,
- const TyTy::BaseType * /* tyty FIXME: Reuse when needed */)
+CompileExpr::compile_char_literal (const HIR::LiteralExpr &expr,
+ const TyTy::BaseType *tyty)
{
rust_assert (expr.get_lit_type () == HIR::Literal::CHAR);
const auto literal_value = expr.get_literal ();
@@ -2356,6 +2359,8 @@ CompileExpr::visit (HIR::ArrayExpr &expr)
}
rust_assert (tyty->get_kind () == TyTy::TypeKind::ARRAY);
+ const TyTy::ArrayType &array_tyty
+ = static_cast<const TyTy::ArrayType &> (*tyty);
HIR::ArrayElems &elements = *expr.get_internal_elements ();
switch (elements.get_array_expr_type ())
@@ -2363,20 +2368,23 @@ CompileExpr::visit (HIR::ArrayExpr &expr)
case HIR::ArrayElems::ArrayExprType::VALUES: {
HIR::ArrayElemsValues &elems
= static_cast<HIR::ArrayElemsValues &> (elements);
- translated = array_value_expr (expr.get_locus (), array_type, elems);
+ translated
+ = array_value_expr (expr.get_locus (), array_tyty, array_type, elems);
}
return;
case HIR::ArrayElems::ArrayExprType::COPIED:
HIR::ArrayElemsCopied &elems
= static_cast<HIR::ArrayElemsCopied &> (elements);
- translated = array_copied_expr (expr.get_locus (), array_type, elems);
+ translated
+ = array_copied_expr (expr.get_locus (), array_tyty, array_type, elems);
}
}
tree
-CompileExpr::array_value_expr (Location expr_locus, tree array_type,
- HIR::ArrayElemsValues &elems)
+CompileExpr::array_value_expr (Location expr_locus,
+ const TyTy::ArrayType &array_tyty,
+ tree array_type, HIR::ArrayElemsValues &elems)
{
std::vector<unsigned long> indexes;
std::vector<tree> constructor;
@@ -2394,8 +2402,9 @@ CompileExpr::array_value_expr (Location expr_locus, tree array_type,
}
tree
-CompileExpr::array_copied_expr (Location expr_locus, tree array_type,
- HIR::ArrayElemsCopied &elems)
+CompileExpr::array_copied_expr (Location expr_locus,
+ const TyTy::ArrayType &array_tyty,
+ tree array_type, HIR::ArrayElemsCopied &elems)
{
// see gcc/cp/typeck2.cc:1369-1401
gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
@@ -2557,8 +2566,7 @@ HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment,
tree
HIRCompileBase::resolve_indirection_adjustment (
- Resolver::Adjustment & /* adjustment FIXME: Reuse when needed */,
- tree expression, Location locus)
+ Resolver::Adjustment &adjustment, tree expression, Location locus)
{
return indirect_expression (expression, locus);
}
@@ -2971,13 +2979,14 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr,
}
tree
-CompileExpr::generate_closure_fntype (HIR::ClosureExpr &,
+CompileExpr::generate_closure_fntype (HIR::ClosureExpr &expr,
const TyTy::ClosureType &closure_tyty,
- tree, TyTy::FnType **fn_tyty)
+ tree compiled_closure_tyty,
+ TyTy::FnType **fn_tyty)
{
// grab the specified_bound
rust_assert (closure_tyty.num_specified_bounds () == 1);
- const TyTy::TypeBoundPredicate predicate
+ const TyTy::TypeBoundPredicate &predicate
= *closure_tyty.get_specified_bounds ().begin ();
// ensure the fn_once_output associated type is set
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index 98d322a..a259daf 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -97,12 +97,14 @@ protected:
TyTy::BaseType *receiver, TyTy::FnType *fntype,
tree receiver_ref, Location expr_locus);
- tree get_receiver_from_dyn (TyTy::BaseType *receiver, tree receiver_ref,
- Location expr_locus);
+ tree get_receiver_from_dyn (const TyTy::DynamicObjectType *dyn,
+ TyTy::BaseType *receiver, TyTy::FnType *fntype,
+ tree receiver_ref, Location expr_locus);
tree resolve_method_address (TyTy::FnType *fntype, HirId ref,
TyTy::BaseType *receiver,
HIR::PathIdentSegment &segment,
+ Analysis::NodeMapping expr_mappings,
Location expr_locus);
tree
@@ -133,10 +135,11 @@ protected:
tree type_cast_expression (tree type_to_cast_to, tree expr, Location locus);
- tree array_value_expr (Location expr_locus, tree array_type,
- HIR::ArrayElemsValues &elems);
+ tree array_value_expr (Location expr_locus, const TyTy::ArrayType &array_tyty,
+ tree array_type, HIR::ArrayElemsValues &elems);
- tree array_copied_expr (Location expr_locus, tree array_type,
+ tree array_copied_expr (Location expr_locus,
+ const TyTy::ArrayType &array_tyty, tree array_type,
HIR::ArrayElemsCopied &elems);
protected:
diff --git a/gcc/rust/backend/rust-compile-fnparam.cc b/gcc/rust/backend/rust-compile-fnparam.cc
index 7a38e76..3f0ec82 100644
--- a/gcc/rust/backend/rust-compile-fnparam.cc
+++ b/gcc/rust/backend/rust-compile-fnparam.cc
@@ -61,7 +61,7 @@ CompileFnParam::visit (HIR::IdentifierPattern &pattern)
}
void
-CompileFnParam::visit (HIR::WildcardPattern &)
+CompileFnParam::visit (HIR::WildcardPattern &pattern)
{
decl_type = ctx->get_backend ()->immutable_type (decl_type);
diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h
index c786fba..ac9478a 100644
--- a/gcc/rust/backend/rust-compile-implitem.h
+++ b/gcc/rust/backend/rust-compile-implitem.h
@@ -72,7 +72,7 @@ public:
void visit (HIR::TraitItemConst &constant) override;
void visit (HIR::TraitItemFunc &func) override;
- void visit (HIR::TraitItemType &) override {}
+ void visit (HIR::TraitItemType &typ) override {}
private:
CompileTraitItem (Context *ctx, TyTy::BaseType *concrete, Location ref_locus)
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index 78eee53..5522211 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -28,8 +28,6 @@
#include "print-tree.h"
#include "fold-const.h"
#include "langhooks.h"
-#include "rust-gcc.h"
-#include "rust-constexpr.h"
#include "print-tree.h"
@@ -153,7 +151,7 @@ unchecked_op_handler (tree_code op)
}
inline tree
-sorry_handler (Context *, TyTy::FnType *fntype)
+sorry_handler (Context *ctx, TyTy::FnType *fntype)
{
rust_sorry_at (fntype->get_locus (), "intrinsic %qs is not yet implemented",
fntype->get_identifier ().c_str ());
@@ -201,7 +199,6 @@ Intrinsics::compile (TyTy::FnType *fntype)
tree builtin = error_mark_node;
BuiltinsContext &builtin_ctx = BuiltinsContext::get ();
-
if (builtin_ctx.lookup_simple_builtin (fntype->get_identifier (), &builtin))
return builtin;
@@ -607,8 +604,7 @@ copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype)
= build2 (MULT_EXPR, size_type_node, TYPE_SIZE_UNIT (param_type), count);
tree memcpy_raw = nullptr;
- BuiltinsContext::get ().lookup_simple_builtin ("__builtin_memcpy",
- &memcpy_raw);
+ BuiltinsContext::get ().lookup_simple_builtin ("memcpy", &memcpy_raw);
rust_assert (memcpy_raw);
auto memcpy
= build_fold_addr_expr_loc (Location ().gcc_location (), memcpy_raw);
@@ -660,35 +656,18 @@ prefetch_data_handler (Context *ctx, TyTy::FnType *fntype, Prefetch kind)
enter_intrinsic_block (ctx, fndecl);
auto addr = ctx->get_backend ()->var_expression (args[0], Location ());
-
- // The core library technically allows you to pass any i32 value as a
- // locality, but LLVM will then complain if the value cannot be constant
- // evaluated. For now, we ignore the locality argument and instead always
- // pass `3` (the most restrictive value). This allows us to still have
- // prefetch behavior, just not as granular as expected. In future Rust
- // versions, we hope that prefetch intrinsics will be split up according to
- // locality, similarly to atomic intrinsics.
- // The solution is to try and perform constant folding for the locality
- // argument, or instead of creating a new function definition, modify the call
- // site directly This has the bad side-effect of creating warnings about
- // `unused name - locality`, which we hack away here:
- // TODO: Take care of handling locality properly
- ctx->get_backend ()->var_expression (args[1], Location ());
-
+ auto locality = ctx->get_backend ()->var_expression (args[1], Location ());
auto rw_flag = make_unsigned_long_tree (ctx, kind == Prefetch::Write ? 1 : 0);
auto prefetch_raw = NULL_TREE;
- auto ok = BuiltinsContext::get ().lookup_simple_builtin ("__builtin_prefetch",
- &prefetch_raw);
+ auto ok
+ = BuiltinsContext::get ().lookup_simple_builtin ("prefetch", &prefetch_raw);
rust_assert (ok);
auto prefetch
= build_fold_addr_expr_loc (Location ().gcc_location (), prefetch_raw);
auto prefetch_call
- = ctx->get_backend ()->call_expression (prefetch,
- {addr, rw_flag,
- // locality arg
- make_unsigned_long_tree (ctx, 3)},
+ = ctx->get_backend ()->call_expression (prefetch, {addr, rw_flag, locality},
nullptr, Location ());
TREE_READONLY (prefetch_call) = 0;
@@ -714,7 +693,7 @@ build_atomic_builtin_name (const std::string &prefix, Location locus,
// TODO: Can we maybe get the generic version (atomic_store_n) to work... This
// would be so much better
- std::string result = "__" + prefix; // + "n";
+ std::string result = prefix;
auto type_name = operand_type->get_name ();
if (type_name == "usize" || type_name == "isize")
@@ -724,13 +703,6 @@ build_atomic_builtin_name (const std::string &prefix, Location locus,
return "";
}
- if (type_name.at (0) == 'i')
- {
- rust_sorry_at (locus, "atomics are not yet supported for signed "
- "integer types (i8, i16, i32, i64, i128)");
- return "";
- }
-
auto type_size_str = allowed_types.find (type_name);
if (!check_for_basic_integer_type ("atomic", locus, operand_type))
@@ -860,7 +832,6 @@ atomic_load_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering)
TREE_SIDE_EFFECTS (load_call) = 1;
ctx->add_statement (return_statement);
-
finalize_intrinsic_block (ctx, fndecl);
return fndecl;
diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc
index 3f9d650..1d8eda1 100644
--- a/gcc/rust/backend/rust-compile-pattern.cc
+++ b/gcc/rust/backend/rust-compile-pattern.cc
@@ -71,7 +71,7 @@ CompilePatternCaseLabelExpr::visit (HIR::TupleStructPattern &pattern)
}
void
-CompilePatternCaseLabelExpr::visit (HIR::WildcardPattern &)
+CompilePatternCaseLabelExpr::visit (HIR::WildcardPattern &pattern)
{
// operand 0 being NULL_TREE signifies this is the default case label see:
// tree.def for documentation for CASE_LABEL_EXPR
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index 7becdf7..f89da2b 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -33,20 +33,20 @@ void
ResolvePathRef::visit (HIR::QualifiedPathInExpression &expr)
{
resolved = resolve (expr.get_final_segment ().get_segment (),
- expr.get_mappings (), expr.get_locus ());
+ expr.get_mappings (), expr.get_locus (), true);
}
void
ResolvePathRef::visit (HIR::PathInExpression &expr)
{
resolved = resolve (expr.get_final_segment ().get_segment (),
- expr.get_mappings (), expr.get_locus ());
+ expr.get_mappings (), expr.get_locus (), false);
}
tree
ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
const Analysis::NodeMapping &mappings,
- Location expr_locus)
+ Location expr_locus, bool is_qualified_path)
{
TyTy::BaseType *lookup = nullptr;
bool ok = ctx->get_tyctx ()->lookup_type (mappings.get_hirid (), &lookup);
@@ -157,8 +157,8 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
}
// let the query system figure it out
- tree resolved_item
- = query_compile (ref, lookup, final_segment, mappings, expr_locus);
+ tree resolved_item = query_compile (ref, lookup, final_segment, mappings,
+ expr_locus, is_qualified_path);
if (resolved_item != error_mark_node)
{
TREE_USED (resolved_item) = 1;
@@ -170,7 +170,7 @@ tree
HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup,
const HIR::PathIdentSegment &final_segment,
const Analysis::NodeMapping &mappings,
- Location expr_locus)
+ Location expr_locus, bool is_qualified_path)
{
HIR::Item *resolved_item = ctx->get_mappings ()->lookup_hir_item (ref);
HirId parent_block;
diff --git a/gcc/rust/backend/rust-compile-resolve-path.h b/gcc/rust/backend/rust-compile-resolve-path.h
index 63441b6..f0360bd 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.h
+++ b/gcc/rust/backend/rust-compile-resolve-path.h
@@ -61,7 +61,8 @@ public:
{}
tree resolve (const HIR::PathIdentSegment &final_segment,
- const Analysis::NodeMapping &mappings, Location locus);
+ const Analysis::NodeMapping &mappings, Location locus,
+ bool is_qualified_path);
tree resolved;
};
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc
index 8da2839..5e56e0a 100644
--- a/gcc/rust/backend/rust-compile-type.cc
+++ b/gcc/rust/backend/rust-compile-type.cc
@@ -399,7 +399,7 @@ TyTyResolveCompile::visit (const TyTy::SliceType &type)
}
void
-TyTyResolveCompile::visit (const TyTy::BoolType &)
+TyTyResolveCompile::visit (const TyTy::BoolType &type)
{
translated
= ctx->get_backend ()->named_type ("bool",
@@ -503,7 +503,7 @@ TyTyResolveCompile::visit (const TyTy::FloatType &type)
}
void
-TyTyResolveCompile::visit (const TyTy::USizeType &)
+TyTyResolveCompile::visit (const TyTy::USizeType &type)
{
translated = ctx->get_backend ()->named_type (
"usize",
@@ -513,7 +513,7 @@ TyTyResolveCompile::visit (const TyTy::USizeType &)
}
void
-TyTyResolveCompile::visit (const TyTy::ISizeType &)
+TyTyResolveCompile::visit (const TyTy::ISizeType &type)
{
translated = ctx->get_backend ()->named_type (
"isize",
@@ -523,7 +523,7 @@ TyTyResolveCompile::visit (const TyTy::ISizeType &)
}
void
-TyTyResolveCompile::visit (const TyTy::CharType &)
+TyTyResolveCompile::visit (const TyTy::CharType &type)
{
translated
= ctx->get_backend ()->named_type ("char",
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index 1f97ad1..0c72a16 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -214,7 +214,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref,
auto address = compute_address_for_trait_item (item, predicate,
probed_bounds_for_receiver,
- actual, locus);
+ actual, actual, locus);
vtable_ctor_elems.push_back (address);
vtable_ctor_idx.push_back (i++);
}
@@ -233,7 +233,7 @@ HIRCompileBase::compute_address_for_trait_item (
const TyTy::TypeBoundPredicate *predicate,
std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>>
&receiver_bounds,
- const TyTy::BaseType *root, Location locus)
+ const TyTy::BaseType *receiver, const TyTy::BaseType *root, Location locus)
{
// There are two cases here one where its an item which has an implementation
// within a trait-impl-block. Then there is the case where there is a default
@@ -360,11 +360,9 @@ HIRCompileBase::compute_address_for_trait_item (
}
bool
-HIRCompileBase::verify_array_capacities (
- tree ltype, tree rtype,
- // TODO: Reuse `lvalue_locus` when we want to switch to a RichLocation and
- // point to the
- Location /* lvalue_locus */, Location rvalue_locus)
+HIRCompileBase::verify_array_capacities (tree ltype, tree rtype,
+ Location lvalue_locus,
+ Location rvalue_locus)
{
rust_assert (ltype != NULL_TREE);
rust_assert (rtype != NULL_TREE);
diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc
index 4586110..21e8bed 100644
--- a/gcc/rust/backend/rust-constexpr.cc
+++ b/gcc/rust/backend/rust-constexpr.cc
@@ -3996,7 +3996,8 @@ constexpr_fn_retval (const constexpr_ctx *ctx, tree body)
// return an aggregate constant. If UNSHARE_P, return an unshared
// copy of the initializer.
static tree
-constant_value_1 (tree decl, bool, bool, bool unshare_p)
+constant_value_1 (tree decl, bool strict_p, bool return_aggregate_cst_ok_p,
+ bool unshare_p)
{
while (TREE_CODE (decl) == CONST_DECL)
{
@@ -6485,7 +6486,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
/* Like maybe_constant_init but first fully instantiate the argument. */
tree
-fold_non_dependent_init (tree t, tsubst_flags_t /*=tf_warning_or_error*/,
+fold_non_dependent_init (tree t,
+ tsubst_flags_t complain /*=tf_warning_or_error*/,
bool manifestly_const_eval /*=false*/,
tree object /* = NULL_TREE */)
{
diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc
index fb6ff0f..0c393d9 100644
--- a/gcc/rust/backend/rust-tree.cc
+++ b/gcc/rust/backend/rust-tree.cc
@@ -2059,7 +2059,11 @@ rs_tree_equal (tree t1, tree t2)
/* TRUE iff TYPE is publicly & uniquely derived from PARENT. */
-bool publicly_uniquely_derived_p (tree, tree) { return false; }
+bool
+publicly_uniquely_derived_p (tree parent, tree type)
+{
+ return false;
+}
// forked from gcc/cp/typeck.cc comp_except_types
@@ -3339,7 +3343,11 @@ release_tree_vector (vec<tree, va_gc> *vec)
/* As above, but also check value-dependence of the expression as a whole. */
-bool instantiation_dependent_expression_p (tree) { return false; }
+bool
+instantiation_dependent_expression_p (tree expression)
+{
+ return false;
+}
// forked from gcc/cp/cvt.cc cp_get_callee
@@ -3389,7 +3397,11 @@ scalarish_type_p (const_tree t)
constructors are deleted. This function implements the ABI notion of
non-trivial copy, which has diverged from the one in the standard. */
-bool type_has_nontrivial_copy_init (const_tree) { return false; }
+bool
+type_has_nontrivial_copy_init (const_tree type)
+{
+ return false;
+}
// forked from gcc/cp/tree.cc build_local_temp
@@ -3412,7 +3424,11 @@ build_local_temp (tree type)
/* Returns true iff DECL is a capture proxy for a normal capture
(i.e. without explicit initializer). */
-bool is_normal_capture_proxy (tree) { return false; }
+bool
+is_normal_capture_proxy (tree decl)
+{
+ return false;
+}
// forked from gcc/cp/c-common.cc reject_gcc_builtin
@@ -3677,7 +3693,7 @@ char_type_p (tree type)
lvalue for the function template specialization. */
tree
-resolve_nondeduced_context (tree orig_expr, tsubst_flags_t)
+resolve_nondeduced_context (tree orig_expr, tsubst_flags_t complain)
{
return orig_expr;
}
@@ -3956,13 +3972,21 @@ decl_constant_var_p (tree decl)
/* Returns true iff DECL is a variable or function declared with an auto type
that has not yet been deduced to a real type. */
-bool undeduced_auto_decl (tree) { return false; }
+bool
+undeduced_auto_decl (tree decl)
+{
+ return false;
+}
// forked from gcc/cp/decl.cc require_deduced_type
/* Complain if DECL has an undeduced return type. */
-bool require_deduced_type (tree, tsubst_flags_t) { return true; }
+bool
+require_deduced_type (tree decl, tsubst_flags_t complain)
+{
+ return true;
+}
/* Return the location of a tree passed to %+ formats. */