aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-context.h
diff options
context:
space:
mode:
authorDavid Faust <david.faust@oracle.com>2021-11-15 11:29:10 -0800
committerDavid Faust <david.faust@oracle.com>2021-11-16 13:02:11 -0800
commit7a751f354a91a8459b877c60a5e5d78203aeb3ce (patch)
tree6905b25bbe6a6e9042ee93992e752987ed22dc15 /gcc/rust/backend/rust-compile-context.h
parent97c98deec7d4c698d7b8ee8a4e56888d5d85b8bd (diff)
downloadgcc-7a751f354a91a8459b877c60a5e5d78203aeb3ce.zip
gcc-7a751f354a91a8459b877c60a5e5d78203aeb3ce.tar.gz
gcc-7a751f354a91a8459b877c60a5e5d78203aeb3ce.tar.bz2
Replace Btype use with GCC tree
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r--gcc/rust/backend/rust-compile-context.h102
1 files changed, 51 insertions, 51 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index 396cb10..82c02f8 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -60,20 +60,20 @@ public:
ok = tyctx->lookup_type (ref, &lookup);
rust_assert (ok);
- Btype *compiled = TyTyCompile::compile (backend, lookup);
- compiled_type_map.insert (std::pair<HirId, Btype *> (ref, compiled));
+ tree compiled = TyTyCompile::compile (backend, lookup);
+ compiled_type_map.insert (std::pair<HirId, tree > (ref, compiled));
builtin_range.insert (ref);
}
}
- bool lookup_compiled_types (HirId id, ::Btype **type,
+ bool lookup_compiled_types (HirId id, ::tree *type,
const TyTy::BaseType *ref = nullptr)
{
if (ref != nullptr)
{
for (auto it = mono.begin (); it != mono.end (); it++)
{
- std::pair<HirId, ::Btype *> &val = it->second;
+ std::pair<HirId, ::tree > &val = it->second;
const TyTy::BaseType *r = it->first;
if (ref->is_equal (*r))
@@ -94,14 +94,14 @@ public:
return true;
}
- void insert_compiled_type (HirId id, ::Btype *type,
+ void insert_compiled_type (HirId id, ::tree type,
const TyTy::BaseType *ref = nullptr)
{
rust_assert (builtin_range.find (id) == builtin_range.end ());
- compiled_type_map.insert (std::pair<HirId, Btype *> (id, type));
+ compiled_type_map.insert (std::pair<HirId, tree > (id, type));
if (ref != nullptr)
{
- std::pair<HirId, ::Btype *> elem (id, type);
+ std::pair<HirId, ::tree > elem (id, type);
mono[ref] = std::move (elem);
}
}
@@ -247,7 +247,7 @@ public:
void pop_fn () { fn_stack.pop_back (); }
fncontext peek_fn () { return fn_stack.back (); }
- void push_type (::Btype *t) { type_decls.push_back (t); }
+ void push_type (::tree t) { type_decls.push_back (t); }
void push_var (::Bvariable *v) { var_decls.push_back (v); }
void push_const (::Bexpression *c) { const_decls.push_back (c); }
void push_function (::Bfunction *f) { func_decls.push_back (f); }
@@ -322,7 +322,7 @@ private:
// state
std::vector<fncontext> fn_stack;
std::map<HirId, ::Bvariable *> compiled_var_decls;
- std::map<HirId, ::Btype *> compiled_type_map;
+ std::map<HirId, ::tree > compiled_type_map;
std::map<HirId, ::Bfunction *> compiled_fn_map;
std::map<HirId, ::Bexpression *> compiled_consts;
std::map<HirId, ::Blabel *> compiled_labels;
@@ -330,12 +330,12 @@ private:
std::vector<::Bblock *> scope_stack;
std::vector<::Bvariable *> loop_value_stack;
std::vector<::Blabel *> loop_begin_labels;
- std::map<const TyTy::BaseType *, std::pair<HirId, ::Btype *>> mono;
+ std::map<const TyTy::BaseType *, std::pair<HirId, ::tree >> mono;
std::map<DefId, std::vector<std::pair<const TyTy::BaseType *, ::Bfunction *>>>
mono_fns;
// To GCC middle-end
- std::vector<::Btype *> type_decls;
+ std::vector<tree> type_decls;
std::vector<::Bvariable *> var_decls;
std::vector<::Bexpression *> const_decls;
std::vector<::Bfunction *> func_decls;
@@ -344,7 +344,7 @@ private:
class TyTyResolveCompile : public TyTy::TyConstVisitor
{
public:
- static ::Btype *compile (Context *ctx, const TyTy::BaseType *ty,
+ static tree compile (Context *ctx, const TyTy::BaseType *ty,
bool trait_object_mode = false)
{
TyTyResolveCompile compiler (ctx, trait_object_mode);
@@ -375,16 +375,16 @@ public:
void visit (const TyTy::FnType &type) override
{
- Backend::Btyped_identifier receiver;
- std::vector<Backend::Btyped_identifier> parameters;
- std::vector<Backend::Btyped_identifier> results;
+ Backend::typed_identifier receiver;
+ std::vector<Backend::typed_identifier> parameters;
+ std::vector<Backend::typed_identifier> results;
if (!type.get_return_type ()->is_unit ())
{
auto hir_type = type.get_return_type ();
auto ret
= TyTyResolveCompile::compile (ctx, hir_type, trait_object_mode);
- results.push_back (Backend::Btyped_identifier (
+ results.push_back (Backend::typed_identifier (
"_", ret,
ctx->get_mappings ()->lookup_location (hir_type->get_ref ())));
}
@@ -395,7 +395,7 @@ public:
auto compiled_param_type
= TyTyResolveCompile::compile (ctx, param_tyty, trait_object_mode);
- auto compiled_param = Backend::Btyped_identifier (
+ auto compiled_param = Backend::typed_identifier (
param_pair.first->as_string (), compiled_param_type,
ctx->get_mappings ()->lookup_location (param_tyty->get_ref ()));
@@ -414,12 +414,12 @@ public:
void visit (const TyTy::FnPtr &type) override
{
- Btype *result_type
+ tree result_type
= TyTyResolveCompile::compile (ctx, type.get_return_type ());
- std::vector<Btype *> parameters;
+ std::vector<tree > parameters;
type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool {
- Btype *pty = TyTyResolveCompile::compile (ctx, p);
+ tree pty = TyTyResolveCompile::compile (ctx, p);
parameters.push_back (pty);
return true;
});
@@ -439,25 +439,25 @@ public:
rust_assert (type.number_of_variants () == 1);
TyTy::VariantDef &variant = *type.get_variants ().at (0);
- std::vector<Backend::Btyped_identifier> fields;
+ std::vector<Backend::typed_identifier> fields;
for (size_t i = 0; i < variant.num_fields (); i++)
{
const TyTy::StructFieldType *field = variant.get_field_at_index (i);
- Btype *compiled_field_ty
+ tree compiled_field_ty
= TyTyResolveCompile::compile (ctx, field->get_field_type ());
- Backend::Btyped_identifier f (field->get_name (), compiled_field_ty,
+ Backend::typed_identifier f (field->get_name (), compiled_field_ty,
ctx->get_mappings ()->lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (f));
}
- Btype *type_record;
+ tree type_record;
if (type.is_union ())
type_record = ctx->get_backend ()->union_type (fields);
else
type_record = ctx->get_backend ()->struct_type (fields);
- Btype *named_struct
+ tree named_struct
= ctx->get_backend ()->named_type (type.get_name (), type_record,
ctx->get_mappings ()->lookup_location (
type.get_ty_ref ()));
@@ -482,11 +482,11 @@ public:
return;
// create implicit struct
- std::vector<Backend::Btyped_identifier> fields;
+ std::vector<Backend::typed_identifier> fields;
for (size_t i = 0; i < type.num_fields (); i++)
{
TyTy::BaseType *field = type.get_field (i);
- Btype *compiled_field_ty = TyTyResolveCompile::compile (ctx, field);
+ tree compiled_field_ty = TyTyResolveCompile::compile (ctx, field);
// rustc uses the convention __N, where N is an integer, to
// name the fields of a tuple. We follow this as well,
@@ -494,15 +494,15 @@ public:
// this, rather than simply emitting the integer, is that this
// approach makes it simpler to use a C-only debugger, or
// GDB's C mode, when debugging Rust.
- Backend::Btyped_identifier f ("__" + std::to_string (i),
+ Backend::typed_identifier f ("__" + std::to_string (i),
compiled_field_ty,
ctx->get_mappings ()->lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (f));
}
- Btype *struct_type_record = ctx->get_backend ()->struct_type (fields);
- Btype *named_struct
+ tree struct_type_record = ctx->get_backend ()->struct_type (fields);
+ tree named_struct
= ctx->get_backend ()->named_type (type.as_string (), struct_type_record,
ctx->get_mappings ()->lookup_location (
type.get_ty_ref ()));
@@ -514,7 +514,7 @@ public:
void visit (const TyTy::ArrayType &type) override
{
- Btype *element_type
+ tree element_type
= TyTyResolveCompile::compile (ctx, type.get_element_type ());
translated
= ctx->get_backend ()->array_type (element_type, type.get_capacity ());
@@ -522,7 +522,7 @@ public:
void visit (const TyTy::BoolType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -530,7 +530,7 @@ public:
void visit (const TyTy::IntType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -538,7 +538,7 @@ public:
void visit (const TyTy::UintType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -546,7 +546,7 @@ public:
void visit (const TyTy::FloatType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -554,7 +554,7 @@ public:
void visit (const TyTy::USizeType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -562,7 +562,7 @@ public:
void visit (const TyTy::ISizeType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -570,7 +570,7 @@ public:
void visit (const TyTy::CharType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -578,7 +578,7 @@ public:
void visit (const TyTy::ReferenceType &type) override
{
- Btype *base_compiled_type
+ tree base_compiled_type
= TyTyResolveCompile::compile (ctx, type.get_base (), trait_object_mode);
if (type.is_mutable ())
{
@@ -593,7 +593,7 @@ public:
void visit (const TyTy::PointerType &type) override
{
- Btype *base_compiled_type
+ tree base_compiled_type
= TyTyResolveCompile::compile (ctx, type.get_base (), trait_object_mode);
if (type.is_mutable ())
{
@@ -608,7 +608,7 @@ public:
void visit (const TyTy::StrType &type) override
{
- ::Btype *compiled_type = nullptr;
+ ::tree compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type);
rust_assert (ok);
translated = compiled_type;
@@ -633,13 +633,13 @@ public:
// create implicit struct
auto items = type.get_object_items ();
- std::vector<Backend::Btyped_identifier> fields;
+ std::vector<Backend::typed_identifier> fields;
- Btype *uint = ctx->get_backend ()->integer_type (
+ tree uint = ctx->get_backend ()->integer_type (
true, ctx->get_backend ()->get_pointer_size ());
- Btype *uintptr_ty = ctx->get_backend ()->pointer_type (uint);
+ tree uintptr_ty = ctx->get_backend ()->pointer_type (uint);
- Backend::Btyped_identifier f ("__receiver_trait_obj_ptr", uintptr_ty,
+ Backend::typed_identifier f ("__receiver_trait_obj_ptr", uintptr_ty,
ctx->get_mappings ()->lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (f));
@@ -647,18 +647,18 @@ public:
for (size_t i = 0; i < items.size (); i++)
{
// mrustc seems to make a vtable consisting of uintptr's
- Btype *uint = ctx->get_backend ()->integer_type (
+ tree uint = ctx->get_backend ()->integer_type (
true, ctx->get_backend ()->get_pointer_size ());
- Btype *uintptr_ty = ctx->get_backend ()->pointer_type (uint);
+ tree uintptr_ty = ctx->get_backend ()->pointer_type (uint);
- Backend::Btyped_identifier f ("__" + std::to_string (i), uintptr_ty,
+ Backend::typed_identifier f ("__" + std::to_string (i), uintptr_ty,
ctx->get_mappings ()->lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (f));
}
- Btype *type_record = ctx->get_backend ()->struct_type (fields);
- Btype *named_struct
+ tree type_record = ctx->get_backend ()->struct_type (fields);
+ tree named_struct
= ctx->get_backend ()->named_type (type.get_name (), type_record,
ctx->get_mappings ()->lookup_location (
type.get_ty_ref ()));
@@ -679,7 +679,7 @@ private:
Context *ctx;
bool trait_object_mode;
- ::Btype *translated;
+ ::tree translated;
size_t recursion_count;
static const size_t kDefaultRecusionLimit = 5;