aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
AgeCommit message (Collapse)AuthorFilesLines
2024-01-16gccrs: Add utility function to build proc macro typesPierre-Emmanuel Patry2-0/+180
Add some utility function to build proc macro entrypoint related types. Those functions will help generate all required metadata in order for proc macros to be expanded properly. gcc/rust/ChangeLog: * backend/rust-compile.cc (build_attribute_array): Add a function to build the attribute array type. (build_derive_proc_macro): Add a function to build the derive proc macro type. (build_bang_proc_macro): Add a function to build the bang proc macro type. (build_attribute_proc_macro): Add a function to build the attribute proc macro type. (build_proc_macro): Add a function to build the proc macro tagged union type. (build_proc_macro_buffer): Add a function to build the proc macro buffer type. (build_entrypoint): Add a function to build the proc macro entrypoint type. * backend/rust-compile.h: Add function prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add getters for proc macro mappingsPierre-Emmanuel Patry1-0/+10
Add three different getters, one for each proc macro type. gcc/rust/ChangeLog: * backend/rust-compile-context.h: Add getters. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Collect procedural macros in the cratePierre-Emmanuel Patry2-17/+63
Collect informations on procedural macros in the compiled crate. For attribute and bang procedural macros we only require the final address as well as the name of the function. Derive procedural macros are a bit different, we collect the fonction's address through it's fndecl tree as well as the trait's name and the multiple attributes. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl): Make the function non static in order to be able to access the compile context. Also add the whole proc macro infomrmation collection. (get_attributes): Add a function to retrieve the different attributes from a derive procedural macro definition attribute. (get_trait_name): Add a function to retrieve the trait name from a derive procedural macro definition attribute. * backend/rust-compile-base.h: Add function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Reformat commentsPierre-Emmanuel Patry1-6/+6
gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_abi_options): Reformat uncorrectly formatted comments. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Add containers for proc macro collection mappingsPierre-Emmanuel Patry1-0/+23
Add one container for each kind of procedural macro mapping. Also add a new structure to gather informations required for derive procedural macros. Add different functions to fill those new containers. gcc/rust/ChangeLog: * backend/rust-compile-context.h (struct CustomDeriveInfo): Add new derive procedural macro metadata information holder for mappings. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Change ABI setup and add gccrs_proc_macro attrPierre-Emmanuel Patry1-3/+18
Change the way the ABI is setup on a function to avoid duplicates. ABI is setup by the setup function only now. Add a new attribute to the function "gccrs_proc_macro" in order to differentiate it from another type of function. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (handle_proc_macro_common): Add new attribute "gccrs_proc_macro" to all procedural macro functions. (get_abi): Add a function to retrieve the correct ABI depending on wether the function is a proc macro or not. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Make proc macro definition cdeclPierre-Emmanuel Patry2-0/+59
We need to make sure proc macros have the C abi in order to be called by the compiler with dlopen. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl): Add proc macro handlers dispatch. (handle_proc_macro_common): Add a function for common behavior between all kinds of proc macros. * backend/rust-compile-base.h: Add function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: hir: Rename ComoundAssignment gettersJakub Dupak1-4/+4
Use more a consistent name. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Rename method. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Rename method. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Rename method. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Rename method. * hir/rust-hir-dump.cc (Dump::visit): Rename method. * hir/tree/rust-hir-expr.h: Rename method. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Rename method. * typecheck/rust-tyty.h: Rename method.
2024-01-16gccrs: hir: Rename get_pattern_mappings methodJakub Dupak5-15/+15
Unify with the name used in Expr to allow convenient template over everything that has mappings. gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Rename method. * backend/rust-compile-expr.cc (sort_tuple_patterns): Rename method. * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Rename method. (CompilePatternBindings::visit): Rename method. (CompilePatternLet::visit): Rename method. * backend/rust-compile-stmt.cc (CompileStmt::visit): Rename method. * backend/rust-compile-var-decl.h: Rename method. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Rename method. * hir/rust-hir-dump.cc (Dump::visit): Rename method. * hir/tree/rust-hir-path.h: Rename method. * hir/tree/rust-hir-pattern.h: Rename method. * hir/tree/rust-hir.h: Rename method. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::Resolve): Rename method. (TypeCheckPattern::visit): Rename method. (ClosureParamInfer::visit): Rename method. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Rename method. * util/rust-hir-map.cc (Mappings::insert_hir_pattern): Rename method. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: compile: bail on labelled blockJakub Dupak1-0/+6
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Bail on labelled block. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Add tests for v0 manglingRaiki Tamura1-22/+19
gcc/rust/ChangeLog: * backend/rust-mangle.cc (v0_identifier): Fix broken encoding. (v0_scope_path): Modify paramter. (v0_path): Fix namespace for modules. gcc/testsuite/ChangeLog: * rust/compile/v0-mangle1.rs: New test. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Initial implementation of v0 manglingRaiki Tamura3-51/+343
gcc/rust/ChangeLog: * backend/rust-compile-context.h: Modify declaration. * backend/rust-mangle.cc (struct V0Path): New struct. (v0_path): New function. (legacy_mangle_name): Take Context as argument. (v0_numeric_prefix): Fix type strings. (v0_complex_type_prefix): New function. (v0_add_integer_62): Deleted (v0_integer_62): New function. (v0_add_opt_integer_62): Deleted. (v0_opt_integer_62): New function. (v0_add_disambiguator): Deleted. (v0_disambiguator): New function. (v0_type_prefix): Support more types. (v0_generic_args): New function. (v0_add_identifier): Deleted. (v0_identifier): New function. (v0_type_path): New function. (v0_function_path): New function. (v0_scope_path): New function. (v0_crate_path): New function. (v0_inherent_or_trait_impl_path): New function. (v0_mangle_item): Use v0_path. (Mangler::mangle_item): Take Context as argument. * backend/rust-mangle.h (class Context): Add forward declaration. * hir/tree/rust-hir-item.h: Fix include. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Adjust methods for TuplePatternItems to match TupleStructItemsOwen Avery2-2/+2
gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern.h (TuplePatternItems::get_pattern_type): Rename to... (TuplePatternItems::get_item_type): ...here. (TuplePatternItemsMultiple::get_pattern_type): Rename to... (TuplePatternItemsMultiple::get_item_type): ...here. (TuplePatternItemsRanged::get_pattern_type): Rename to... (TuplePatternItemsRanged::get_item_type): ...here. * backend/rust-compile-expr.cc: Adjust calls to renamed methods. * backend/rust-compile-pattern.cc: Likewise. * typecheck/rust-hir-type-check-pattern.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: minor changes (typo and minor refactor)Marc Poulhiès2-10/+4
Fix a typo and merge 2 if clauses using the same condition. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Merge 2 if clauses. * backend/rust-compile-extern.h: Fix typo in comment. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Fix type confusion in coercionJakub Dupak1-2/+2
There was a mismatch between a manual discriminant test and the static cast. gcc/rust/ChangeLog: * backend/rust-compile.cc (HIRCompileBase::coercion_site1): Fix wrong cast Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: Fix spellingOwen Avery3-4/+4
gcc/rust/ChangeLog: * ast/rust-expr.h: Fix spelling of "doesn't". * backend/rust-compile-expr.cc: Fix spelling of "accessors". * backend/rust-compile-implitem.h: Fix spelling of "normal". * backend/rust-constexpr.cc: Fix spelling of "actual". Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Remove HIR::ForLoopExprPhilip Herron2-3/+0
This will end up getting desugared into a LoopExpr with a MatchExpr body. gcc/rust/ChangeLog: * backend/rust-compile-block.h: remove HIR::ForLoopExpr * backend/rust-compile-expr.h: likewise * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): likewise * checks/errors/privacy/rust-privacy-reporter.h: likewise * checks/errors/rust-const-checker.cc (ConstChecker::visit): likewise * checks/errors/rust-const-checker.h: likewise * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): likewise * checks/errors/rust-unsafe-checker.h: likewise * checks/lints/rust-lint-marklive.h: likewise * hir/rust-ast-lower.cc (ASTLoweringExprWithBlock::visit): likewise * hir/rust-hir-dump.cc (Dump::visit): likewise * hir/rust-hir-dump.h: likewise * hir/tree/rust-hir-expr.h (class ForLoopExpr): likewise * hir/tree/rust-hir-full-decls.h (class ForLoopExpr): likewise * hir/tree/rust-hir-visitor.h: likewise * hir/tree/rust-hir.cc (ForLoopExpr::as_string): likewise (ForLoopExpr::accept_vis): likewise * typecheck/rust-hir-type-check-expr.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Minor typo fixMarc Poulhiès2-6/+7
Fix varadic -> variadic gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Fix typo in varIadic. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. * rust-backend.h (function_type_varadic): Rename into ... (function_type_variadic): ... this. * rust-gcc.cc (function_type_varadic): Rename into ... (function_type_variadic): ... this. * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise. * typecheck/rust-tyty.h (is_varadic): Renamed into ... (is_variadic): ... this. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: trivial typo fix.Marc Poulhiès6-12/+12
Fix subsititions -> substitutions gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_function): Fix typo in substitutions. (HIRCompileBase::resolve_method_address): Likewise. * backend/rust-compile-extern.h (CompileExternItem::visit): Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-intrinsic.cc (maybe_override_ctx): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Likewise. * typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::ResolveImplBlockSelfWithInference): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Likewise. * typecheck/rust-tyty.cc (BaseType::has_subsititions_defined): Renamed into ... (BaseType::has_substitutions_defined): ... this. (ADTType::is_equal): Fix typo in substitutions. (handle_substitions): Likewise. (FnType::is_equal): Likewise. (FnType::handle_substitions): Likewise. * typecheck/rust-tyty.h (has_subsititions_defined): Renamed into ... (has_substitutions_defined): ... this. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Add intrinsics::assumeOwen Avery1-0/+53
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (get_identifier): Add declaration. (assume_handler): New. (generic_intrinsics): Add assume_handler entry. gcc/testsuite/ChangeLog: * rust/compile/assume.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: rust-compile-intrinsic: add `copy` intrinsics ...liushuyu1-6/+19
... also made `copy_nonoverlapping` handler more generic gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: add `copy` intrinsics and make `copy_nonoverlapping` handler more generic Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2024-01-16gccrs: rust-builtins: add likely and unlikey intrinsicsliushuyu2-0/+63
gcc/rust/ChangeLog: * backend/rust-builtins.cc: add `expect` builtin definition. * backend/rust-compile-intrinsic.cc: add `likely` and `unlikely` intrinsics handler. Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2024-01-16gccrs: Shorten `make_unsigned_long_tree` code and remove ↵Guillaume Gomez1-4/+1
`Backend::integer_constant_expression` gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: Simplify `make_unsigned_long_tree` * rust-backend.h: Remove `integer_constant_expression` * rust-gcc.cc: Remove `integer_constant_expression`
2024-01-16gccrs: Fix typechecking (and compilation) error for alt patterns in match ↵Dave Evans2-14/+13
expressions. gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Add AltPattern visitor function * backend/rust-compile-pattern.h: Update CompilePatternCaseLabelExpr::visit(AltPattern&). * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Update AltPattern visitor gcc/testsuite/ChangeLog: * rust/compile/issue-2431.rs: New test. Signed-off-by: Dave Evans <dave@dmetwo.org>
2024-01-16gccrs: Remove unused `ctx` argument in `make_unsigned_long_tree` functionGuillaume Gomez1-4/+4
gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc: Remove unused argument
2024-01-16gccrs: Convert class Backend into namespaceOwen Avery14-548/+458
gcc/rust/ChangeLog: * rust-backend.h (class Backend): Convert to ... (namespace Backend): ... namespace. * rust-gcc.cc (Backend::Backend): Rename to ... (Backend::init): ... here. (rust_get_backend): Remove. * rust-session-manager.cc (rust_get_backend): Remove. (Session::init): Use Backend::init instead of rust_get_backend. (Session::compile_crate): Initialize Context without pointer to Backend. * rust-session-manager.h (Session::backend): Remove. * backend/rust-compile-context.cc (Context::Context): Remove pointer to Backend. * backend/rust-compile-context.h (class Context): Remove pointer to Backend, update function calls. * backend/rust-compile-base.cc: Update function calls. * backend/rust-compile-block.cc: Likewise. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-fnparam.cc: Likewise. * backend/rust-compile-intrinsic.cc: Likewise. * backend/rust-compile-item.cc: Likewise. * backend/rust-compile-pattern.cc: Likewise. * backend/rust-compile-resolve-path.cc: Likewise. * backend/rust-compile-type.cc: Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-compile.cc: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Unify raw attribute valuesPierre-Emmanuel Patry1-11/+17
Attribute values were used as raw string, this is error prone and makes renaming harder. Using a constexpr instead will leverage the power of the compiler and emit an error when an incorrect builtin attribute value is used. gcc/rust/ChangeLog: * ast/rust-ast.cc (Attribute::check_cfg_predicate): Change raw string to constexpr call. (Attribute::separate_cfg_attrs): Likewise. * backend/rust-compile-base.cc (should_mangle_item): Likewise. (HIRCompileBase::setup_fndecl): Likewise. (HIRCompileBase::handle_cold_attribute_on_fndecl): Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (find_proc_macro_attribute): Likewise. * checks/errors/rust-unsafe-checker.cc (check_target_attr): Likewise. * expand/rust-cfg-strip.cc (fails_cfg): Likewise. (fails_cfg_with_expand): Likewise. (expand_cfg_attrs): Likewise. * expand/rust-macro-builtins.cc: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Likewise. (ASTLoweringBase::lower_macro_definition): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * parse/rust-parse-impl.h (Parser::parse_doc_comment): Likewise. * parse/rust-parse.cc (extract_module_path): Likewise. * resolve/rust-early-name-resolver.cc (is_macro_use_module): Likewise. (EarlyNameResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (is_macro_export): Likwise. * rust-session-manager.cc (Session::injection): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): Likewise. * util/rust-attributes.cc (is_proc_macro_type): Likewise. (AttributeChecker::check_attribute): Likewise. (AttributeChecker::visit): Likewise. * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise. * util/rust-attribute-values.h: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Fix match-expression code-genPhilip Herron1-1/+15
We were massing the match scruitinee expression as a way to access the result of the expression. This is wrong and needs to be stored in a temporary otherwise it will cause the code to be regnerated for each time it is used. This is not an issue in the case where the expression is only used once. Fixes #1895 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): use a temp for the value gcc/testsuite/ChangeLog: * rust/execute/torture/iter1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Fix ODR violationsOwen Avery1-29/+32
gcc/rust/ChangeLog: * backend/rust-constexpr.cc (struct constexpr_fundef): Rename to ... (struct rust_constexpr_fundef): ... here. (struct constexpr_call): Rename to ... (struct rust_constexpr_call): ... here. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add check for no_mangle attributeRaiki Tamura1-1/+1
gcc/rust/ChangeLog: * lex/rust-input-source.h: Move constants from here... * util/rust-codepoint.h (struct Codepoint): ... to here * util/rust-attributes.cc (check_no_mangle_function): New function. (AttributeChecker::visit): Use it. * util/rust-unicode.cc (is_ascii_only): New function. * util/rust-unicode.h (is_ascii_only): Likewise. * backend/rust-mangle.cc (legacy_mangle_name): Use it. * util/rust-punycode.cc (extract_basic_string): Likewise. * lex/rust-lex.cc (Lexer::parse_byte_char): Likewise. Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: Fix move_val_initPhilip Herron1-2/+4
The intrinsic move_val_init was being optimized away even at -O0 because the function looked "pure" but this adds in the attributes to enforce that this function has side-effects to override that bad assumption by the middle-end. Addresses #1895 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (move_val_init_handler): mark as side-effects Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Mark uninit-intrinsic as side-effectsPhilip Herron1-3/+4
Ensure the uninit intrinsic does not get optimized away Addresses #1895 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (uninit_handler): Update fndecl attributes Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Fix overflow intrinsic use before initPhilip Herron1-16/+30
The overflow intrinsic returns a tuple of (value, boolean) where it value is the operator result and boolean if it overflowed or not. The intrinsic here did not initilize the resulting tuple and therefore was creating a use before init error resulting in garbage results Addresses #1895 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (op_with_overflow_inner): fix use before init Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Fix bad uninit intrinsicPhilip Herron1-7/+20
We were using the DECL_RESULT but this just contains the TREE_TYPE of the retval. It was also missing taking the address of the destination for the memset call. This changes the code to create a temp variable for the return value and asserts the destination size is the same as the size of the template param. Fixes #2583 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (enter_intrinsic_block): take the locals vector (uninit_handler): make a temp variable and use the address of it gcc/testsuite/ChangeLog: * rust/execute/torture/issue-2583.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Handle gengtype annotations in backend/rust-tree.{cc,h}Owen Avery2-1/+6
gcc/rust/ChangeLog: * config-lang.in: Add "backend/rust-tree.h" and "backend/rust-tree.h" to gtfiles. * backend/rust-tree.cc: Include new header generated by gengtype. * backend/rust-tree.h (struct language_function): Add TODO. * rust-lang.cc: Include "rust-tree.h". (struct lang_type): Remove duplicate definition. (struct lang_decl): Likewise. (struct lang_identifier): Likewise. (struct language_function): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add missing gengtype related structsOwen Avery1-4/+145
gcc/rust/ChangeLog: * backend/rust-tree.h (struct rust_cp_class_binding): Fork from gcc/cp/name_lookup.h. (struct rust_cp_binding_level): Likewise. (struct named_label_entry): Remove declaration... (struct rust_named_label_entry): ... and fork definition from gcc/cp/decl.cc. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Fork c++ resorting methodsOwen Avery2-0/+56
gcc/rust/ChangeLog: * backend/rust-tree.cc (resort_data): Fork from c++ frontend. (resort_member_name_cmp): Likewise. (resort_type_member_vec): Likewise. * backend/rust-tree.h (resort_type_member_vec): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Rename some structs to avoid ODR issuesOwen Avery2-20/+20
gcc/rust/ChangeLog: * backend/rust-tree.cc (struct conv_type_hasher): Rename to ... (struct rust_conv_type_hasher): ... here. (struct cplus_array_hasher): Rename to ... (struct rust_cplus_array_hasher): ... here. (struct source_location_table_entry_hash): Rename to ... (struct rust_source_location_table_entry_hash): ... here. * backend/rust-tree.h (struct named_decl_hash): Rename to ... (struct rust_named_decl_hash): ... here. (struct cxx_saved_binding): Rename to ... (struct rust_cxx_saved_binding): ... here. (struct named_label_hash): Rename to ... (struct rust_named_label_hash): ... here. (struct tree_pair_s): Rename to ... (struct rust_tree_pair_s): ... here. (struct tree_pair_p): Rename to ... (struct rust_tree_pair_p): ... here. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Namespace related tweaksOwen Avery2-8/+13
gcc/rust/ChangeLog: * backend/rust-tree.cc (Rust::gt_pch_nx): Move external function declaration ... (gt_pch_nx): ... out of Rust namespace. * backend/rust-tree.h (OVL_FIRST): Qualify function name. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Fix compilation of types which hold onto dangling infer varsPhilip Herron1-2/+17
There is a case where some generic types are holding onto inference variable pointers directly. So this gives the backend a chance to do one final lookup to resolve the type. This now allows us to compile a full test case for iterators but there is still one miscompilation in here which results in a segv on O2 and bad result on -O0. Addresses #1895 gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::visit): do a final lookup gcc/testsuite/ChangeLog: * rust/compile/iterators1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Remove stmt_tree and dependency on cp_token_cacheOwen Avery1-38/+2
gcc/rust/ChangeLog: * backend/rust-tree.h (struct stmt_tree_s): Remove. (typedef stmt_tree): Remove. (c_language_function::x_stmt_tree): Remove. (saved_scope::x_stmt_tree): Remove. (lang_decl_fn::pending_inline_p): Remove. (lang_decl_fn::spare): Adjust size. (lang_decl_fn::pending_inline_info): Remove. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Handle gengtype annotations in rust-constexpr.ccOwen Avery1-15/+19
gcc/rust/ChangeLog: * backend/rust-constexpr.cc: Include gt-rust-rust-constexpr.h. (struct constexpr_call_hasher): Rename to ... (struct rust_constexpr_call_hasher): ... here. (struct constexpr_fundef_hasher): Rename to ... (struct rust_constexpr_fundef_hasher): ... here. * config-lang.in: Add rust-constexpr.cc to gtfiles. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Add punycode encoding to v0 manglingRaiki Tamura1-15/+38
gcc/rust/ChangeLog: * backend/rust-mangle.cc (v0_add_identifier): Added punycode encoding (v0_mangle_item): Likewise. * lex/rust-lex.cc (assert_source_content): Change type (test_buffer_input_source): Change type (test_file_input_source): Change type * resolve/rust-ast-resolve-toplevel.h: fix typo * rust-session-manager.cc (Session::load_extern_crate): fix typo * util/rust-canonical-path.h: fix typo * util/rust-hir-map.cc (NodeMapping::get_error): fix typo (Mappings::Mappings): fix typo * util/rust-mapping-common.h (UNKNOWN_CREATENUM): fix typo (UNKNOWN_CRATENUM): Change 0 to UINT32_MAX Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: [E0535] Unknown argument given to inline attributeMuhammad Mahad1-1/+5
The inline attribute only supports two arguments: - always - never All other arguments given to the inline attribute will return error. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::handle_inline_attribute_on_fndecl): Added rich_location & error code. gcc/testsuite/ChangeLog: * rust/compile/inline_2.rs: Added new message. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-01-16gccrs: [E0534] inline attribute was malformedMuhammad Mahad1-1/+4
Inline attribute takes one argument, but more than one argument was found. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::handle_inline_attribute_on_fndecl): Added rich_location & error code. gcc/testsuite/ChangeLog: * rust/compile/inline_2.rs: Added new case. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-01-16gccrs: improve name mangling hashPhilip Herron2-10/+5
We can endup with duplicate symbol names for different intrinsics with our current hash setup. This adds in the mappings and extra info to improve hash uniqueness. Addresses #1895 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (check_for_cached_intrinsic): simplify this cached intrinsic check * backend/rust-mangle.cc (legacy_mangle_item): use new interface * typecheck/rust-tyty.h: new managle helper Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: simplify matching possible candidatesPhilip Herron1-0/+6
We do extra checking after the fact here to ensure its a valid candidate and in the case there is only one candidate lets just go for it. Addresses #1895 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address): use the single candidate Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16gccrs: Fix legacy mangling to use Unicode escapeRaiki Tamura1-6/+19
gcc/rust/ChangeLog: * backend/rust-mangle.cc (legacy_mangle_name): Use Unicode escape Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16gccrs: [E0541] Use of unknown meta itemMuhammad Mahad1-1/+2
gcc/rust/ChangeLog: * backend/rust-compile-base.cc: Added ErrorCode. gcc/testsuite/ChangeLog: * rust/compile/attr_deprecated_2.rs: Updated comment to pass the testcase. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-01-16gccrs: [E0308] array misamatch typesMuhammad Mahad1-5/+6
gcc/rust/ChangeLog: * backend/rust-compile.cc (HIRCompileBase::verify_array_capacities): Added ErrorCode. gcc/testsuite/ChangeLog: * rust/compile/arrays2.rs: changed comment to pass testcase. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>