Branch data Line data Source code
1 : : // Copyright (C) 2020-2025 Free Software Foundation, Inc.
2 : :
3 : : // This file is part of GCC.
4 : :
5 : : // GCC is free software; you can redistribute it and/or modify it under
6 : : // the terms of the GNU General Public License as published by the Free
7 : : // Software Foundation; either version 3, or (at your option) any later
8 : : // version.
9 : :
10 : : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 : : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 : : // for more details.
14 : :
15 : : // You should have received a copy of the GNU General Public License
16 : : // along with GCC; see the file COPYING3. If not see
17 : : // <http://www.gnu.org/licenses/>.
18 : :
19 : : #ifndef RUST_COMPILE_BASE
20 : : #define RUST_COMPILE_BASE
21 : :
22 : : #include "rust-compile-context.h"
23 : :
24 : : namespace Rust {
25 : : namespace Compile {
26 : :
27 : : class HIRCompileBase
28 : : {
29 : : public:
30 : 226688 : virtual ~HIRCompileBase () {}
31 : :
32 : : static tree address_expression (tree expr, location_t locus,
33 : : tree ptrty = NULL_TREE);
34 : :
35 : : static tree compile_constant_expr (
36 : : Context *ctx, HirId coercion_id, TyTy::BaseType *resolved_type,
37 : : TyTy::BaseType *expected_type,
38 : : const Resolver::CanonicalPath &canonical_path, HIR::Expr &const_value_expr,
39 : : location_t locus, location_t expr_locus);
40 : :
41 : : protected:
42 : 74317 : HIRCompileBase (Context *ctx) : ctx (ctx) {}
43 : :
44 : : Context *ctx;
45 : :
46 : : protected:
47 : : Context *get_context () { return ctx; }
48 : :
49 : : tree coercion_site (HirId id, tree rvalue, TyTy::BaseType *actual,
50 : : TyTy::BaseType *expected, location_t lvalue_locus,
51 : : location_t rvalue_locus);
52 : : tree coercion_site1 (tree rvalue, TyTy::BaseType *actual,
53 : : TyTy::BaseType *expected, location_t lvalue_locus,
54 : : location_t rvalue_locus);
55 : :
56 : : tree coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual,
57 : : const TyTy::DynamicObjectType *ty,
58 : : location_t locus);
59 : :
60 : : tree compute_address_for_trait_item (
61 : : const Resolver::TraitItemReference *ref,
62 : : const TyTy::TypeBoundPredicate *predicate,
63 : : std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>>
64 : : &receiver_bounds,
65 : : const TyTy::BaseType *receiver, const TyTy::BaseType *root,
66 : : location_t locus);
67 : :
68 : : bool verify_array_capacities (tree ltype, tree rtype, location_t ltype_locus,
69 : : location_t rtype_locus);
70 : :
71 : : tree query_compile (HirId ref, TyTy::BaseType *lookup,
72 : : const HIR::PathIdentSegment &final_segment,
73 : : const Analysis::NodeMapping &mappings,
74 : : location_t expr_locus, bool is_qualified_path);
75 : :
76 : : tree resolve_adjustements (std::vector<Resolver::Adjustment> &adjustments,
77 : : tree expression, location_t locus);
78 : :
79 : : tree resolve_deref_adjustment (Resolver::Adjustment &adjustment,
80 : : tree expression, location_t locus);
81 : :
82 : : tree resolve_indirection_adjustment (Resolver::Adjustment &adjustment,
83 : : tree expression, location_t locus);
84 : :
85 : : tree resolve_unsized_adjustment (Resolver::Adjustment &adjustment,
86 : : tree expression, location_t locus);
87 : :
88 : : tree resolve_unsized_slice_adjustment (Resolver::Adjustment &adjustment,
89 : : tree expression, location_t locus);
90 : :
91 : : tree resolve_unsized_dyn_adjustment (Resolver::Adjustment &adjustment,
92 : : tree expression, location_t locus);
93 : :
94 : : tree resolve_method_address (TyTy::FnType *fntype, TyTy::BaseType *receiver,
95 : : location_t expr_locus);
96 : :
97 : : void compile_function_body (tree fndecl, HIR::BlockExpr &function_body,
98 : : TyTy::BaseType *fn_return_ty);
99 : :
100 : : tree compile_constant_item (HirId coercion_id, TyTy::BaseType *resolved_type,
101 : : TyTy::BaseType *expected_type,
102 : : const Resolver::CanonicalPath &canonical_path,
103 : : HIR::Expr &const_value_expr, location_t locus,
104 : : location_t expr_locus);
105 : :
106 : : tree compile_function (bool is_root_item, const std::string &fn_name,
107 : : tl::optional<HIR::SelfParam> &self_param,
108 : : std::vector<HIR::FunctionParam> &function_params,
109 : : const HIR::FunctionQualifiers &qualifiers,
110 : : HIR::Visibility &visibility, AST::AttrVec &outer_attrs,
111 : : location_t locus, HIR::BlockExpr *function_body,
112 : : const Resolver::CanonicalPath &canonical_path,
113 : : TyTy::FnType *fntype);
114 : :
115 : : tree unit_expression (location_t locus);
116 : :
117 : : void setup_fndecl (tree fndecl, bool is_main_entry_point, bool is_generic_fn,
118 : : HIR::Visibility &visibility,
119 : : const HIR::FunctionQualifiers &qualifiers,
120 : : const AST::AttrVec &attrs);
121 : :
122 : : static void handle_inline_attribute_on_fndecl (tree fndecl,
123 : : const AST::Attribute &attr);
124 : :
125 : : void handle_bang_proc_macro_attribute_on_fndecl (tree fndecl,
126 : : const AST::Attribute &attr);
127 : :
128 : : void
129 : : handle_attribute_proc_macro_attribute_on_fndecl (tree fndecl,
130 : : const AST::Attribute &attr);
131 : :
132 : : void
133 : : handle_derive_proc_macro_attribute_on_fndecl (tree fndecl,
134 : : const AST::Attribute &attr);
135 : :
136 : : static void handle_cold_attribute_on_fndecl (tree fndecl,
137 : : const AST::Attribute &attr);
138 : :
139 : : static void handle_must_use_attribute_on_fndecl (tree fndecl,
140 : : const AST::Attribute &attr);
141 : :
142 : : static void
143 : : handle_link_section_attribute_on_fndecl (tree fndecl,
144 : : const AST::Attribute &attr);
145 : : static void
146 : : handle_deprecated_attribute_on_fndecl (tree fndecl,
147 : : const AST::Attribute &attr);
148 : :
149 : : static void handle_no_mangle_attribute_on_fndecl (tree fndecl,
150 : : const AST::Attribute &attr);
151 : :
152 : : static void setup_abi_options (tree fndecl, ABI abi);
153 : :
154 : : static tree indirect_expression (tree expr, location_t locus);
155 : :
156 : : static bool mark_addressable (tree, location_t);
157 : :
158 : : static tree named_constant_expression (tree type_tree,
159 : : const std::string &name,
160 : : tree const_val, location_t location);
161 : : };
162 : :
163 : : } // namespace Compile
164 : : } // namespace Rust
165 : :
166 : : #endif // RUST_COMPILE_BASE
|