diff options
author | David Faust <david.faust@oracle.com> | 2021-11-15 10:12:20 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2021-11-16 13:15:54 -0800 |
commit | a4e5aee5863c7d898ee640296bc837e0baa8e796 (patch) | |
tree | f40c90287ae41fa3689cdc38d4bb021fb6cc8394 /gcc/rust/backend | |
parent | 95048daaffa5e16df4d663702fe80294eac7b85e (diff) | |
download | gcc-a4e5aee5863c7d898ee640296bc837e0baa8e796.zip gcc-a4e5aee5863c7d898ee640296bc837e0baa8e796.tar.gz gcc-a4e5aee5863c7d898ee640296bc837e0baa8e796.tar.bz2 |
Replace Bblock with GCC tree
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-block.h | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 16 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 28 |
7 files changed, 32 insertions, 38 deletions
diff --git a/gcc/rust/backend/rust-compile-block.h b/gcc/rust/backend/rust-compile-block.h index 0e631e1..af90671 100644 --- a/gcc/rust/backend/rust-compile-block.h +++ b/gcc/rust/backend/rust-compile-block.h @@ -30,7 +30,7 @@ class CompileBlock : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bblock *compile (HIR::BlockExpr *expr, Context *ctx, Bvariable *result) + static tree compile (HIR::BlockExpr *expr, Context *ctx, Bvariable *result) { CompileBlock compiler (ctx, result); expr->accept_vis (compiler); @@ -44,7 +44,7 @@ private: : HIRCompileBase (ctx), translated (nullptr), result (result) {} - Bblock *translated; + tree translated; Bvariable *result; }; diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 4c8f722..1fe67d2 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -112,13 +112,13 @@ public: Analysis::Mappings *get_mappings () { return mappings; } ConstFold::Context *get_const_ctx () { return const_ctx; } - void push_block (Bblock *scope) + void push_block (tree scope) { scope_stack.push_back (scope); statements.push_back ({}); } - Bblock *pop_block () + tree pop_block () { auto block = scope_stack.back (); scope_stack.pop_back (); @@ -131,7 +131,7 @@ public: return block; } - Bblock *peek_enclosing_scope () + tree peek_enclosing_scope () { if (scope_stack.size () == 0) return nullptr; @@ -323,7 +323,7 @@ private: std::map<HirId, tree> compiled_consts; std::map<HirId, ::Blabel *> compiled_labels; std::vector<::std::vector<tree>> statements; - std::vector<::Bblock *> scope_stack; + std::vector<tree> scope_stack; std::vector<::Bvariable *> loop_value_stack; std::vector<::Blabel *> loop_begin_labels; std::map<const TyTy::BaseType *, std::pair<HirId, ::tree >> mono; diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 8b1da22..fb01d8d 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -176,7 +176,7 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, fn_vtable_access, expr_locus); fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); bool is_address_taken = false; tree ret_var_stmt = NULL_TREE; Bvariable *fn_convert_expr_tmp diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index f739273..52cc58a 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -514,7 +514,7 @@ public: if (needs_temp) { fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; @@ -551,7 +551,7 @@ public: if (needs_temp) { fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; @@ -587,7 +587,7 @@ public: if (needs_temp) { fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; @@ -740,7 +740,7 @@ public: bool needs_temp = !block_tyty->is_unit (); if (needs_temp) { - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; @@ -773,7 +773,7 @@ public: ctx->add_statement (loop_begin_label_decl); ctx->push_loop_begin_label (loop_begin_label); - Bblock *code_block + tree code_block = CompileBlock::compile (expr.get_loop_block ().get (), ctx, nullptr); tree loop_expr = ctx->get_backend ()->loop_expression (code_block, expr.get_locus ()); @@ -811,8 +811,8 @@ public: Location start_location = expr.get_loop_block ()->get_locus (); Location end_location = expr.get_loop_block ()->get_locus (); // FIXME - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Bblock *loop_block + tree enclosing_scope = ctx->peek_enclosing_scope (); + tree loop_block = ctx->get_backend ()->block (fnctx.fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (loop_block); @@ -832,7 +832,7 @@ public: = ctx->get_backend ()->expression_statement (fnctx.fndecl, exit_expr); ctx->add_statement (break_stmt); - Bblock *code_block + tree code_block = CompileBlock::compile (expr.get_loop_block ().get (), ctx, nullptr); tree code_block_stmt = ctx->get_backend ()->block_statement (code_block); ctx->add_statement (code_block_stmt); diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 23b10d6..7b41226 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -262,12 +262,12 @@ public: ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = NULL; + tree enclosing_scope = NULL_TREE; HIR::BlockExpr *function_body = function.get_definition ().get (); Location start_location = function_body->get_locus (); Location end_location = function_body->get_closing_locus (); - Bblock *code_block + tree code_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (code_block); @@ -522,12 +522,12 @@ public: ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = NULL; + tree enclosing_scope = NULL_TREE; HIR::BlockExpr *function_body = func.get_block_expr ().get (); Location start_location = function_body->get_locus (); Location end_location = function_body->get_closing_locus (); - Bblock *code_block + tree code_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (code_block); diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 94a313e..5af9ab3 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -261,12 +261,12 @@ public: ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = NULL; + tree enclosing_scope = NULL_TREE; HIR::BlockExpr *function_body = function.get_definition ().get (); Location start_location = function_body->get_locus (); Location end_location = function_body->get_closing_locus (); - Bblock *code_block + tree code_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (code_block); diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 71435f3..579b323 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -338,10 +338,9 @@ CompileBlock::visit (HIR::BlockExpr &expr) bool ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Bblock *new_block - = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, - start_location, end_location); + tree enclosing_scope = ctx->peek_enclosing_scope (); + tree new_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, + start_location, end_location); ctx->push_block (new_block); for (auto &s : expr.get_statements ()) @@ -395,8 +394,7 @@ CompileConditionalBlocks::visit (HIR::IfExpr &expr) fncontext fnctx = ctx->peek_fn (); tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); - Bblock *then_block - = CompileBlock::compile (expr.get_if_block (), ctx, result); + tree then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); translated = ctx->get_backend ()->if_statement (fndecl, condition_expr, then_block, @@ -409,10 +407,8 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqElse &expr) fncontext fnctx = ctx->peek_fn (); tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); - Bblock *then_block - = CompileBlock::compile (expr.get_if_block (), ctx, result); - Bblock *else_block - = CompileBlock::compile (expr.get_else_block (), ctx, result); + tree then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); + tree else_block = CompileBlock::compile (expr.get_else_block (), ctx, result); translated = ctx->get_backend ()->if_statement (fndecl, condition_expr, then_block, @@ -425,17 +421,15 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqIf &expr) fncontext fnctx = ctx->peek_fn (); tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); - Bblock *then_block - = CompileBlock::compile (expr.get_if_block (), ctx, result); + tree then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); // else block std::vector<Bvariable *> locals; Location start_location = expr.get_conseq_if_expr ()->get_locus (); Location end_location = expr.get_conseq_if_expr ()->get_locus (); // FIXME - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Bblock *else_block - = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, - start_location, end_location); + tree enclosing_scope = ctx->peek_enclosing_scope (); + tree else_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, + start_location, end_location); ctx->push_block (else_block); tree else_stmt_decl @@ -610,7 +604,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, locus); fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); bool is_address_taken = false; tree ret_var_stmt = NULL_TREE; |