Branch data Line data Source code
1 : : // Copyright (C) 2020-2024 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 : 156823 : virtual ~HIRCompileBase () {}
31 : :
32 : : static tree address_expression (tree expr, location_t locus);
33 : :
34 : : protected:
35 : 71653 : HIRCompileBase (Context *ctx) : ctx (ctx) {}
36 : :
37 : : Context *ctx;
38 : :
39 : : protected:
40 : : Context *get_context () { return ctx; }
41 : :
42 : : tree coercion_site (HirId id, tree rvalue, TyTy::BaseType *actual,
43 : : TyTy::BaseType *expected, location_t lvalue_locus,
44 : : location_t rvalue_locus);
45 : : tree coercion_site1 (tree rvalue, TyTy::BaseType *actual,
46 : : TyTy::BaseType *expected, location_t lvalue_locus,
47 : : location_t rvalue_locus);
48 : :
49 : : tree coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual,
50 : : const TyTy::DynamicObjectType *ty,
51 : : location_t locus);
52 : :
53 : : tree compute_address_for_trait_item (
54 : : const Resolver::TraitItemReference *ref,
55 : : const TyTy::TypeBoundPredicate *predicate,
56 : : std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>>
57 : : &receiver_bounds,
58 : : const TyTy::BaseType *receiver, const TyTy::BaseType *root,
59 : : location_t locus);
60 : :
61 : : bool verify_array_capacities (tree ltype, tree rtype, location_t ltype_locus,
62 : : location_t rtype_locus);
63 : :
64 : : tree query_compile (HirId ref, TyTy::BaseType *lookup,
65 : : const HIR::PathIdentSegment &final_segment,
66 : : const Analysis::NodeMapping &mappings,
67 : : location_t expr_locus, bool is_qualified_path);
68 : :
69 : : tree resolve_adjustements (std::vector<Resolver::Adjustment> &adjustments,
70 : : tree expression, location_t locus);
71 : :
72 : : tree resolve_deref_adjustment (Resolver::Adjustment &adjustment,
73 : : tree expression, location_t locus);
74 : :
75 : : tree resolve_indirection_adjustment (Resolver::Adjustment &adjustment,
76 : : tree expression, location_t locus);
77 : :
78 : : tree resolve_unsized_adjustment (Resolver::Adjustment &adjustment,
79 : : tree expression, location_t locus);
80 : :
81 : : tree resolve_unsized_slice_adjustment (Resolver::Adjustment &adjustment,
82 : : tree expression, location_t locus);
83 : :
84 : : tree resolve_unsized_dyn_adjustment (Resolver::Adjustment &adjustment,
85 : : tree expression, location_t locus);
86 : :
87 : : tree resolve_method_address (TyTy::FnType *fntype, TyTy::BaseType *receiver,
88 : : location_t expr_locus);
89 : :
90 : : void compile_function_body (tree fndecl, HIR::BlockExpr &function_body,
91 : : TyTy::BaseType *fn_return_ty);
92 : :
93 : : tree compile_constant_item (TyTy::BaseType *resolved_type,
94 : : const Resolver::CanonicalPath *canonical_path,
95 : : HIR::Expr *const_value_expr, location_t locus);
96 : :
97 : : tree compile_function (const std::string &fn_name, HIR::SelfParam &self_param,
98 : : std::vector<HIR::FunctionParam> &function_params,
99 : : const HIR::FunctionQualifiers &qualifiers,
100 : : HIR::Visibility &visibility, AST::AttrVec &outer_attrs,
101 : : location_t locus, HIR::BlockExpr *function_body,
102 : : const Resolver::CanonicalPath *canonical_path,
103 : : TyTy::FnType *fntype);
104 : :
105 : : static tree unit_expression (Context *ctx, location_t locus);
106 : :
107 : : void setup_fndecl (tree fndecl, bool is_main_entry_point, bool is_generic_fn,
108 : : HIR::Visibility &visibility,
109 : : const HIR::FunctionQualifiers &qualifiers,
110 : : const AST::AttrVec &attrs);
111 : :
112 : : static void handle_inline_attribute_on_fndecl (tree fndecl,
113 : : const AST::Attribute &attr);
114 : :
115 : : void handle_bang_proc_macro_attribute_on_fndecl (tree fndecl,
116 : : const AST::Attribute &attr);
117 : :
118 : : void
119 : : handle_attribute_proc_macro_attribute_on_fndecl (tree fndecl,
120 : : const AST::Attribute &attr);
121 : :
122 : : void
123 : : handle_derive_proc_macro_attribute_on_fndecl (tree fndecl,
124 : : const AST::Attribute &attr);
125 : :
126 : : static void handle_cold_attribute_on_fndecl (tree fndecl,
127 : : const AST::Attribute &attr);
128 : :
129 : : static void handle_must_use_attribute_on_fndecl (tree fndecl,
130 : : const AST::Attribute &attr);
131 : :
132 : : static void
133 : : handle_link_section_attribute_on_fndecl (tree fndecl,
134 : : const AST::Attribute &attr);
135 : : static void
136 : : handle_deprecated_attribute_on_fndecl (tree fndecl,
137 : : const AST::Attribute &attr);
138 : :
139 : : static void handle_no_mangle_attribute_on_fndecl (tree fndecl,
140 : : const AST::Attribute &attr);
141 : :
142 : : static void setup_abi_options (tree fndecl, ABI abi);
143 : :
144 : : static tree indirect_expression (tree expr, location_t locus);
145 : :
146 : : static bool mark_addressable (tree, location_t);
147 : :
148 : : static tree named_constant_expression (tree type_tree,
149 : : const std::string &name,
150 : : tree const_val, location_t location);
151 : : };
152 : :
153 : : } // namespace Compile
154 : : } // namespace Rust
155 : :
156 : : #endif // RUST_COMPILE_BASE
|