aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-07-03 11:54:19 -0400
committerCohenArthur <arthur.cohen@embecosm.com>2023-07-09 08:29:07 +0000
commit763dd38a4924b23c73cafe9a3aab71d5b8494223 (patch)
tree0e019e814af997a032c8f844123902f6bdcdec53 /gcc/rust/backend
parente4647c3f3431ad3a4123874e4fd932bb4fbcda0d (diff)
downloadgcc-763dd38a4924b23c73cafe9a3aab71d5b8494223.zip
gcc-763dd38a4924b23c73cafe9a3aab71d5b8494223.tar.gz
gcc-763dd38a4924b23c73cafe9a3aab71d5b8494223.tar.bz2
Replace value initialization of Location with UNDEF_LOCATION
gcc/rust/ChangeLog: * rust-location.h (UNDEF_LOCATION): New. * ast/rust-ast-collector.cc: Replace Location () with UNDEF_LOCATION. * ast/rust-ast-fragment.cc: Likewise. * ast/rust-ast.h: Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-implitem.h: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-item.h: Likewise. * backend/rust-compile.cc: Likewise. * backend/rust-constexpr.cc: Likewise. * expand/rust-expand-visitor.cc: Likewise. * expand/rust-macro-expand.cc: Likewise. * expand/rust-macro-expand.h: Likewise. * expand/rust-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro-invoc-lexer.cc: Likewise. * expand/rust-proc-macro.cc: Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.h: Likewise. * lex/rust-lex.cc: Likewise. * metadata/rust-export-metadata.cc: Likewise. * parse/rust-parse-impl.h: Likewise. * resolve/rust-ast-resolve-item.cc: Likewise. * resolve/rust-ast-resolve.cc: Likewise. * rust-diagnostics.h: Likewise. * rust-session-manager.cc: Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-coercion.cc: Likewise. * typecheck/rust-hir-dot-operator.cc: Likewise. * typecheck/rust-hir-path-probe.cc: Likewise. * typecheck/rust-hir-trait-reference.cc: Likewise. * typecheck/rust-hir-trait-reference.h: Likewise. * typecheck/rust-hir-type-check-expr.cc: Likewise. * typecheck/rust-hir-type-check-implitem.cc: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-hir-type-check.cc: Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-subst.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. * util/rust-hir-map.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc2
-rw-r--r--gcc/rust/backend/rust-compile-extern.h2
-rw-r--r--gcc/rust/backend/rust-compile-implitem.h4
-rw-r--r--gcc/rust/backend/rust-compile-intrinsic.cc89
-rw-r--r--gcc/rust/backend/rust-compile-item.h2
-rw-r--r--gcc/rust/backend/rust-compile.cc5
-rw-r--r--gcc/rust/backend/rust-constexpr.cc7
7 files changed, 62 insertions, 49 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 96e7fd0..b46574d 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1092,7 +1092,7 @@ sort_tuple_patterns (HIR::MatchExpr &expr)
// compile.
auto foo = std::vector<std::unique_ptr<HIR::Pattern>> ();
foo.emplace_back (std::move (result_pattern));
- HIR::MatchArm new_arm (std::move (foo), Location (), nullptr,
+ HIR::MatchArm new_arm (std::move (foo), UNDEF_LOCATION, nullptr,
AST::AttrVec ());
HIR::MatchCase new_case (match_case.get_mappings (), new_arm,
diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h
index ffe6566..053b972 100644
--- a/gcc/rust/backend/rust-compile-extern.h
+++ b/gcc/rust/backend/rust-compile-extern.h
@@ -33,7 +33,7 @@ public:
static tree compile (HIR::ExternalItem *item, Context *ctx,
TyTy::BaseType *concrete = nullptr,
bool is_query_mode = false,
- Location ref_locus = Location ())
+ Location ref_locus = UNDEF_LOCATION)
{
CompileExternItem compiler (ctx, concrete, ref_locus);
item->accept_vis (compiler);
diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h
index a9a719d..e73c9ab 100644
--- a/gcc/rust/backend/rust-compile-implitem.h
+++ b/gcc/rust/backend/rust-compile-implitem.h
@@ -31,7 +31,7 @@ public:
static tree Compile (HIR::ImplItem *item, Context *ctx,
TyTy::BaseType *concrete = nullptr,
bool is_query_mode = false,
- Location ref_locus = Location ())
+ Location ref_locus = UNDEF_LOCATION)
{
CompileInherentImplItem compiler (ctx, concrete, ref_locus);
item->accept_vis (compiler);
@@ -55,7 +55,7 @@ class CompileTraitItem : public HIRCompileBase, public HIR::HIRTraitItemVisitor
public:
static tree Compile (HIR::TraitItem *item, Context *ctx,
TyTy::BaseType *concrete, bool is_query_mode = false,
- Location ref_locus = Location ())
+ Location ref_locus = UNDEF_LOCATION)
{
CompileTraitItem compiler (ctx, concrete, ref_locus);
item->accept_vis (compiler);
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index 697f40f..5cb6437 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -322,8 +322,8 @@ static void
enter_intrinsic_block (Context *ctx, tree fndecl)
{
tree enclosing_scope = NULL_TREE;
- Location start_location = Location ();
- Location end_location = Location ();
+ Location start_location = UNDEF_LOCATION;
+ Location end_location = UNDEF_LOCATION;
auto block = ctx->get_backend ()->block (fndecl, enclosing_scope, {},
start_location, end_location);
@@ -366,13 +366,13 @@ offset_handler (Context *ctx, TyTy::FnType *fntype)
enter_intrinsic_block (ctx, fndecl);
// BUILTIN offset FN BODY BEGIN
- tree dst = ctx->get_backend ()->var_expression (dst_param, Location ());
- tree size = ctx->get_backend ()->var_expression (size_param, Location ());
+ tree dst = ctx->get_backend ()->var_expression (dst_param, UNDEF_LOCATION);
+ tree size = ctx->get_backend ()->var_expression (size_param, UNDEF_LOCATION);
tree pointer_offset_expr
= pointer_offset_expression (dst, size, BUILTINS_LOCATION);
auto return_statement
= ctx->get_backend ()->return_statement (fndecl, {pointer_offset_expr},
- Location ());
+ UNDEF_LOCATION);
ctx->add_statement (return_statement);
// BUILTIN offset FN BODY END
@@ -406,7 +406,8 @@ sizeof_handler (Context *ctx, TyTy::FnType *fntype)
// BUILTIN size_of FN BODY BEGIN
tree size_expr = TYPE_SIZE_UNIT (template_parameter_type);
auto return_statement
- = ctx->get_backend ()->return_statement (fndecl, {size_expr}, Location ());
+ = ctx->get_backend ()->return_statement (fndecl, {size_expr},
+ UNDEF_LOCATION);
ctx->add_statement (return_statement);
// BUILTIN size_of FN BODY END
@@ -437,7 +438,7 @@ transmute_handler (Context *ctx, TyTy::FnType *fntype)
// param to convert
Bvariable *convert_me_param = param_vars.at (0);
tree convert_me_expr
- = ctx->get_backend ()->var_expression (convert_me_param, Location ());
+ = ctx->get_backend ()->var_expression (convert_me_param, UNDEF_LOCATION);
// check for transmute pre-conditions
tree target_type_expr = TREE_TYPE (DECL_RESULT (fndecl));
@@ -480,7 +481,7 @@ transmute_handler (Context *ctx, TyTy::FnType *fntype)
auto return_statement
= ctx->get_backend ()->return_statement (fndecl, {result_expr},
- Location ());
+ UNDEF_LOCATION);
ctx->add_statement (return_statement);
// BUILTIN transmute FN BODY END
@@ -514,13 +515,13 @@ rotate_handler (Context *ctx, TyTy::FnType *fntype, tree_code op)
enter_intrinsic_block (ctx, fndecl);
// BUILTIN rotate FN BODY BEGIN
- tree x = ctx->get_backend ()->var_expression (x_param, Location ());
- tree y = ctx->get_backend ()->var_expression (y_param, Location ());
+ tree x = ctx->get_backend ()->var_expression (x_param, UNDEF_LOCATION);
+ tree y = ctx->get_backend ()->var_expression (y_param, UNDEF_LOCATION);
tree rotate_expr
= fold_build2_loc (BUILTINS_LOCATION, op, TREE_TYPE (x), x, y);
auto return_statement
= ctx->get_backend ()->return_statement (fndecl, {rotate_expr},
- Location ());
+ UNDEF_LOCATION);
ctx->add_statement (return_statement);
// BUILTIN rotate FN BODY END
@@ -557,8 +558,8 @@ wrapping_op_handler_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
enter_intrinsic_block (ctx, fndecl);
// BUILTIN wrapping_<op> FN BODY BEGIN
- auto lhs = ctx->get_backend ()->var_expression (lhs_param, Location ());
- auto rhs = ctx->get_backend ()->var_expression (rhs_param, Location ());
+ auto lhs = ctx->get_backend ()->var_expression (lhs_param, UNDEF_LOCATION);
+ auto rhs = ctx->get_backend ()->var_expression (rhs_param, UNDEF_LOCATION);
// Operations are always wrapping in Rust, as we have -fwrapv enabled by
// default. The difference between a wrapping_{add, sub, mul} and a regular
@@ -567,7 +568,8 @@ wrapping_op_handler_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
auto wrap_expr = build2 (op, TREE_TYPE (lhs), lhs, rhs);
auto return_statement
- = ctx->get_backend ()->return_statement (fndecl, {wrap_expr}, Location ());
+ = ctx->get_backend ()->return_statement (fndecl, {wrap_expr},
+ UNDEF_LOCATION);
ctx->add_statement (return_statement);
// BUILTIN wrapping_<op> FN BODY END
@@ -604,8 +606,8 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
enter_intrinsic_block (ctx, fndecl);
// BUILTIN op_with_overflow FN BODY BEGIN
- auto x = ctx->get_backend ()->var_expression (x_param, Location ());
- auto y = ctx->get_backend ()->var_expression (y_param, Location ());
+ auto x = ctx->get_backend ()->var_expression (x_param, UNDEF_LOCATION);
+ auto y = ctx->get_backend ()->var_expression (y_param, UNDEF_LOCATION);
tree overflow_builtin = error_mark_node;
switch (op)
@@ -638,10 +640,10 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
= ctx->get_backend ()->temporary_variable (fndecl, NULL_TREE,
overflow_op_type, NULL_TREE,
true /*address_is_taken*/,
- Location (), &tmp_stmt);
+ UNDEF_LOCATION, &tmp_stmt);
ctx->add_statement (tmp_stmt);
- tree result_decl = bvar->get_tree (Location ());
+ tree result_decl = bvar->get_tree (UNDEF_LOCATION);
tree result_ref = build_fold_addr_expr_loc (BUILTINS_LOCATION, result_decl);
tree did_overflow_node
@@ -652,11 +654,11 @@ op_with_overflow_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
tree tuple_type = TREE_TYPE (DECL_RESULT (fndecl));
tree result_expr
= ctx->get_backend ()->constructor_expression (tuple_type, false, vals, -1,
- Location ());
+ UNDEF_LOCATION);
auto return_statement
= ctx->get_backend ()->return_statement (fndecl, {result_expr},
- Location ());
+ UNDEF_LOCATION);
ctx->add_statement (return_statement);
// BUILTIN wrapping_<op> FN BODY END
@@ -696,9 +698,12 @@ copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype)
// BUILTIN copy_nonoverlapping BODY BEGIN
- auto src = ctx->get_backend ()->var_expression (param_vars[0], Location ());
- auto dst = ctx->get_backend ()->var_expression (param_vars[1], Location ());
- auto count = ctx->get_backend ()->var_expression (param_vars[2], Location ());
+ auto src
+ = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION);
+ auto dst
+ = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION);
+ auto count
+ = ctx->get_backend ()->var_expression (param_vars[2], UNDEF_LOCATION);
// We want to create the following statement
// memcpy(dst, src, size_of::<T>());
@@ -718,7 +723,7 @@ copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype)
auto copy_call
= ctx->get_backend ()->call_expression (memcpy, {dst, src, size_expr},
- nullptr, Location ());
+ nullptr, UNDEF_LOCATION);
ctx->add_statement (copy_call);
@@ -762,8 +767,8 @@ 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 ());
- auto locality = ctx->get_backend ()->var_expression (args[1], Location ());
+ auto addr = ctx->get_backend ()->var_expression (args[0], UNDEF_LOCATION);
+ auto locality = ctx->get_backend ()->var_expression (args[1], UNDEF_LOCATION);
auto rw_flag = make_unsigned_long_tree (ctx, kind == Prefetch::Write ? 1 : 0);
auto prefetch_raw = NULL_TREE;
@@ -774,7 +779,7 @@ prefetch_data_handler (Context *ctx, TyTy::FnType *fntype, Prefetch kind)
auto prefetch_call
= ctx->get_backend ()->call_expression (prefetch, {addr, rw_flag, locality},
- nullptr, Location ());
+ nullptr, UNDEF_LOCATION);
TREE_READONLY (prefetch_call) = 0;
TREE_SIDE_EFFECTS (prefetch_call) = 1;
@@ -845,10 +850,12 @@ atomic_store_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering)
enter_intrinsic_block (ctx, fndecl);
- auto dst = ctx->get_backend ()->var_expression (param_vars[0], Location ());
+ auto dst
+ = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION);
TREE_READONLY (dst) = 0;
- auto value = ctx->get_backend ()->var_expression (param_vars[1], Location ());
+ auto value
+ = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION);
auto memorder = make_unsigned_long_tree (ctx, ordering);
auto monomorphized_type
@@ -871,7 +878,7 @@ atomic_store_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering)
auto store_call
= ctx->get_backend ()->call_expression (atomic_store,
{dst, value, memorder}, nullptr,
- Location ());
+ UNDEF_LOCATION);
TREE_READONLY (store_call) = 0;
TREE_SIDE_EFFECTS (store_call) = 1;
@@ -908,7 +915,8 @@ atomic_load_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering)
enter_intrinsic_block (ctx, fndecl);
- auto src = ctx->get_backend ()->var_expression (param_vars[0], Location ());
+ auto src
+ = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION);
auto memorder = make_unsigned_long_tree (ctx, ordering);
auto monomorphized_type
@@ -930,9 +938,10 @@ atomic_load_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering)
auto load_call
= ctx->get_backend ()->call_expression (atomic_load, {src, memorder},
- nullptr, Location ());
+ nullptr, UNDEF_LOCATION);
auto return_statement
- = ctx->get_backend ()->return_statement (fndecl, {load_call}, Location ());
+ = ctx->get_backend ()->return_statement (fndecl, {load_call},
+ UNDEF_LOCATION);
TREE_READONLY (load_call) = 0;
TREE_SIDE_EFFECTS (load_call) = 1;
@@ -966,8 +975,8 @@ unchecked_op_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
// BUILTIN unchecked_<op> BODY BEGIN
- auto x = ctx->get_backend ()->var_expression (param_vars[0], Location ());
- auto y = ctx->get_backend ()->var_expression (param_vars[1], Location ());
+ auto x = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION);
+ auto y = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION);
auto *monomorphized_type
= fntype->get_substs ().at (0).get_param_ty ()->resolve ();
@@ -977,7 +986,7 @@ unchecked_op_inner (Context *ctx, TyTy::FnType *fntype, tree_code op)
auto expr = build2 (op, TREE_TYPE (x), x, y);
auto return_statement
- = ctx->get_backend ()->return_statement (fndecl, {expr}, Location ());
+ = ctx->get_backend ()->return_statement (fndecl, {expr}, UNDEF_LOCATION);
ctx->add_statement (return_statement);
@@ -1032,7 +1041,7 @@ uninit_handler (Context *ctx, TyTy::FnType *fntype)
auto return_statement
= ctx->get_backend ()->return_statement (fndecl, {DECL_RESULT (fndecl)},
- Location ());
+ UNDEF_LOCATION);
ctx->add_statement (return_statement);
// BUILTIN size_of FN BODY END
@@ -1070,8 +1079,10 @@ move_val_init_handler (Context *ctx, TyTy::FnType *fntype)
// BUILTIN size_of FN BODY BEGIN
- tree dst = ctx->get_backend ()->var_expression (param_vars[0], Location ());
- tree src = ctx->get_backend ()->var_expression (param_vars[1], Location ());
+ tree dst
+ = ctx->get_backend ()->var_expression (param_vars[0], UNDEF_LOCATION);
+ tree src
+ = ctx->get_backend ()->var_expression (param_vars[1], UNDEF_LOCATION);
tree size = TYPE_SIZE_UNIT (template_parameter_type);
tree memcpy_builtin = error_mark_node;
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h
index 42ff875..b5c4fb3 100644
--- a/gcc/rust/backend/rust-compile-item.h
+++ b/gcc/rust/backend/rust-compile-item.h
@@ -32,7 +32,7 @@ public:
static tree compile (HIR::Item *item, Context *ctx,
TyTy::BaseType *concrete = nullptr,
bool is_query_mode = false,
- Location ref_locus = Location ())
+ Location ref_locus = UNDEF_LOCATION)
{
CompileItem compiler (ctx, concrete, ref_locus);
item->accept_vis (compiler);
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index 7c60980..ed4792b 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -336,11 +336,12 @@ HIRCompileBase::compute_address_for_trait_item (
if (lookup_fntype->needs_substitution ())
{
TyTy::BaseType *infer
- = Resolver::SubstMapper::InferSubst (lookup_fntype, Location ());
+ = Resolver::SubstMapper::InferSubst (lookup_fntype, UNDEF_LOCATION);
infer
= Resolver::unify_site (infer->get_ref (),
TyTy::TyWithLocation (trait_item_fntype),
- TyTy::TyWithLocation (infer), Location ());
+ TyTy::TyWithLocation (infer),
+ UNDEF_LOCATION);
rust_assert (infer->get_kind () == TyTy::TypeKind::FNDEF);
lookup_fntype = static_cast<TyTy::FnType *> (infer);
}
diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc
index 34443cd..5b90f8f 100644
--- a/gcc/rust/backend/rust-constexpr.cc
+++ b/gcc/rust/backend/rust-constexpr.cc
@@ -3831,7 +3831,8 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec)
member = TREE_OPERAND (member, 1);
else if (ANON_AGGR_TYPE_P (TREE_TYPE (aggr)))
/* Initializing a member of an anonymous union. */
- rust_sorry_at (Location (), "cannot handle value initialization yet");
+ rust_sorry_at (UNDEF_LOCATION,
+ "cannot handle value initialization yet");
// return build_anon_member_initialization (member, init, vec);
else
/* We're initializing a vtable pointer in a base. Leave it as
@@ -3842,10 +3843,10 @@ build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec)
/* Value-initialization can produce multiple initializers for the
same field; use the last one. */
if (!vec_safe_is_empty (*vec) && (*vec)->last ().index == member)
- rust_sorry_at (Location (), "cannot handle value initialization yet");
+ rust_sorry_at (UNDEF_LOCATION, "cannot handle value initialization yet");
// (*vec)->last ().value = init;
else
- rust_sorry_at (Location (), "cannot handle value initialization yet");
+ rust_sorry_at (UNDEF_LOCATION, "cannot handle value initialization yet");
// CONSTRUCTOR_APPEND_ELT (*vec, member, init);
return true;
}