aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-context.h19
-rw-r--r--gcc/rust/backend/rust-compile-expr.h12
-rw-r--r--gcc/rust/rust-backend.h12
-rw-r--r--gcc/rust/rust-gcc.cc63
4 files changed, 36 insertions, 70 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index 1fe67d2..72ab4f2 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -221,12 +221,9 @@ public:
return true;
}
- void insert_label_decl (HirId id, ::Blabel *label)
- {
- compiled_labels[id] = label;
- }
+ void insert_label_decl (HirId id, tree label) { compiled_labels[id] = label; }
- bool lookup_label_decl (HirId id, ::Blabel **label)
+ bool lookup_label_decl (HirId id, tree *label)
{
auto it = compiled_labels.find (id);
if (it == compiled_labels.end ())
@@ -278,16 +275,16 @@ public:
return back;
}
- void push_loop_begin_label (Blabel *label)
+ void push_loop_begin_label (tree label)
{
loop_begin_labels.push_back (label);
}
- Blabel *peek_loop_begin_label () { return loop_begin_labels.back (); }
+ tree peek_loop_begin_label () { return loop_begin_labels.back (); }
- Blabel *pop_loop_begin_label ()
+ tree pop_loop_begin_label ()
{
- Blabel *pop = loop_begin_labels.back ();
+ tree pop = loop_begin_labels.back ();
loop_begin_labels.pop_back ();
return pop;
}
@@ -321,11 +318,11 @@ private:
std::map<HirId, tree> compiled_type_map;
std::map<HirId, tree> compiled_fn_map;
std::map<HirId, tree> compiled_consts;
- std::map<HirId, ::Blabel *> compiled_labels;
+ std::map<HirId, tree> compiled_labels;
std::vector<::std::vector<tree>> statements;
std::vector<tree> scope_stack;
std::vector<::Bvariable *> loop_value_stack;
- std::vector<::Blabel *> loop_begin_labels;
+ std::vector<tree> loop_begin_labels;
std::map<const TyTy::BaseType *, std::pair<HirId, ::tree >> mono;
std::map<DefId, std::vector<std::pair<const TyTy::BaseType *, tree>>>
mono_fns;
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index 52cc58a..2bf969b 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -755,7 +755,7 @@ public:
if (expr.has_loop_label ())
{
HIR::LoopLabel &loop_label = expr.get_loop_label ();
- Blabel *label
+ tree label
= ctx->get_backend ()->label (fnctx.fndecl,
loop_label.get_lifetime ().get_name (),
loop_label.get_locus ());
@@ -766,7 +766,7 @@ public:
loop_label.get_lifetime ().get_mappings ().get_hirid (), label);
}
- Blabel *loop_begin_label
+ tree loop_begin_label
= ctx->get_backend ()->label (fnctx.fndecl, "", expr.get_locus ());
tree loop_begin_label_decl
= ctx->get_backend ()->label_definition_statement (loop_begin_label);
@@ -796,7 +796,7 @@ public:
if (expr.has_loop_label ())
{
HIR::LoopLabel &loop_label = expr.get_loop_label ();
- Blabel *label
+ tree label
= ctx->get_backend ()->label (fnctx.fndecl,
loop_label.get_lifetime ().get_name (),
loop_label.get_locus ());
@@ -817,7 +817,7 @@ public:
start_location, end_location);
ctx->push_block (loop_block);
- Blabel *loop_begin_label
+ tree loop_begin_label
= ctx->get_backend ()->label (fnctx.fndecl, "", expr.get_locus ());
tree loop_begin_label_decl
= ctx->get_backend ()->label_definition_statement (loop_begin_label);
@@ -887,7 +887,7 @@ public:
return;
}
- Blabel *label = nullptr;
+ tree label = NULL_TREE;
if (!ctx->lookup_label_decl (ref, &label))
{
rust_error_at (expr.get_label ().get_locus (),
@@ -912,7 +912,7 @@ public:
void visit (HIR::ContinueExpr &expr) override
{
- Blabel *label = ctx->peek_loop_begin_label ();
+ tree label = ctx->peek_loop_begin_label ();
if (expr.has_label ())
{
NodeId resolved_node_id = UNKNOWN_NODEID;
diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h
index d4d2b89..6a06cd7 100644
--- a/gcc/rust/rust-backend.h
+++ b/gcc/rust/rust-backend.h
@@ -44,9 +44,6 @@ saw_errors (void);
// The backend representation of a variable.
class Bvariable;
-// The backend representation of a label.
-class Blabel;
-
// The backend interface. This is a pure abstract class that a
// specific backend will implement.
@@ -76,7 +73,6 @@ public:
// debug
virtual void debug (tree) = 0;
virtual void debug (Bvariable *) = 0;
- virtual void debug (Blabel *) = 0;
// const folder helpers
virtual bool const_size_cast (tree, size_t *) = 0;
@@ -665,20 +661,20 @@ public:
// Create a new label. NAME will be empty if this is a label
// created by the frontend for a loop construct. The location is
// where the label is defined.
- virtual Blabel *label (tree, const std::string &name, Location) = 0;
+ virtual tree label (tree, const std::string &name, Location) = 0;
// Create a statement which defines a label. This statement will be
// put into the codestream at the point where the label should be
// defined.
- virtual tree label_definition_statement (Blabel *) = 0;
+ virtual tree label_definition_statement (tree) = 0;
// Create a goto statement to a label.
- virtual tree goto_statement (Blabel *, Location) = 0;
+ virtual tree goto_statement (tree, Location) = 0;
// Create an expression for the address of a label. This is used to
// get the return address of a deferred function which may call
// recover.
- virtual tree label_address (Blabel *, Location) = 0;
+ virtual tree label_address (tree, Location) = 0;
// Functions.
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 0fa07d9..482d11f 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -53,29 +53,6 @@
// TODO: this will have to be significantly modified to work with Rust
-// A class wrapping a tree.
-
-class Gcc_tree
-{
-public:
- Gcc_tree (tree t) : t_ (t) {}
-
- tree get_tree () const { return this->t_; }
-
- void set_tree (tree t) { this->t_ = t; }
-
-private:
- tree t_;
-};
-
-// In gcc, types, expressions, and statements are all trees.
-
-class Blabel : public Gcc_tree
-{
-public:
- Blabel (tree t) : Gcc_tree (t) {}
-};
-
// Bvariable is a bit more complicated, because of zero-sized types.
// The GNU linker does not permit dynamic variables with zero size.
// When we see such a variable, we generate a version of the type with
@@ -132,7 +109,6 @@ public:
void debug (tree t) { debug_tree (t); };
void debug (Bvariable *t) { debug_tree (t->get_decl ()); };
- void debug (Blabel *t) { debug_tree (t->get_tree ()); };
// Types.
tree error_type () { return error_mark_node; }
@@ -405,13 +381,13 @@ public:
// Labels.
- Blabel *label (tree, const std::string &name, Location);
+ tree label (tree, const std::string &name, Location);
- tree label_definition_statement (Blabel *);
+ tree label_definition_statement (tree);
- tree goto_statement (Blabel *, Location);
+ tree goto_statement (tree, Location);
- tree label_address (Blabel *, Location);
+ tree label_address (tree, Location);
// Functions.
@@ -2915,7 +2891,7 @@ Gcc_backend::immutable_struct_reference (const std::string &name,
// Make a label.
-Blabel *
+tree
Gcc_backend::label (tree func_tree, const std::string &name, Location location)
{
tree decl;
@@ -2937,41 +2913,38 @@ Gcc_backend::label (tree func_tree, const std::string &name, Location location)
= build_decl (location.gcc_location (), LABEL_DECL, id, void_type_node);
DECL_CONTEXT (decl) = func_tree;
}
- return new Blabel (decl);
+ return decl;
}
// Make a statement which defines a label.
tree
-Gcc_backend::label_definition_statement (Blabel *label)
+Gcc_backend::label_definition_statement (tree label)
{
- tree lab = label->get_tree ();
- return fold_build1_loc (DECL_SOURCE_LOCATION (lab), LABEL_EXPR,
- void_type_node, lab);
+ return fold_build1_loc (DECL_SOURCE_LOCATION (label), LABEL_EXPR,
+ void_type_node, label);
}
// Make a goto statement.
tree
-Gcc_backend::goto_statement (Blabel *label, Location location)
+Gcc_backend::goto_statement (tree label, Location location)
{
- tree lab = label->get_tree ();
return fold_build1_loc (location.gcc_location (), GOTO_EXPR, void_type_node,
- lab);
+ label);
}
// Get the address of a label.
tree
-Gcc_backend::label_address (Blabel *label, Location location)
+Gcc_backend::label_address (tree label, Location location)
{
- tree lab = label->get_tree ();
- TREE_USED (lab) = 1;
- TREE_ADDRESSABLE (lab) = 1;
+ TREE_USED (label) = 1;
+ TREE_ADDRESSABLE (label) = 1;
tree ret
= fold_convert_loc (location.gcc_location (), ptr_type_node,
build_fold_addr_expr_loc (location.gcc_location (),
- lab));
+ label));
return ret;
}
@@ -3047,11 +3020,11 @@ Gcc_backend::function_defer_statement (tree function, tree undefer_tree,
push_cfun (DECL_STRUCT_FUNCTION (function));
tree stmt_list = NULL;
- Blabel *blabel = this->label (function, "", location);
- tree label_def = this->label_definition_statement (blabel);
+ tree label = this->label (function, "", location);
+ tree label_def = this->label_definition_statement (label);
append_to_statement_list (label_def, &stmt_list);
- tree jump_stmt = this->goto_statement (blabel, location);
+ tree jump_stmt = this->goto_statement (label, location);
tree catch_body
= build2 (COMPOUND_EXPR, void_type_node, defer_tree, jump_stmt);
catch_body = build2 (CATCH_EXPR, void_type_node, NULL, catch_body);