From: Arthur Cohen <arthur.cohen@embecosm.com>
To: gcc-patches@gcc.gnu.org
Cc: gcc-rust@gcc.gnu.org, Arthur Cohen <arthur.cohen@embecosm.com>
Subject: [COMMITTED] gccrs: backend: Expose Bvariable class through rust-gcc header
Date: Tue, 31 Jan 2023 14:23:36 +0100 [thread overview]
Message-ID: <20230131132335.661108-1-arthur.cohen@embecosm.com> (raw)
gcc/rust/ChangeLog:
* rust-gcc.cc (class Bvariable): Move class to `rust-gcc.h` header.
* rust-gcc.h: New file.
Tested on x86_64-pc-linux-gnu, committed on master.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/rust/rust-gcc.cc | 30 +----------------------
gcc/rust/rust-gcc.h | 58 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 29 deletions(-)
create mode 100644 gcc/rust/rust-gcc.h
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index e3331d60e32..82b2d33977d 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -50,38 +50,10 @@
#include "rust-linemap.h"
#include "rust-backend.h"
#include "rust-object-export.h"
+#include "rust-gcc.h"
#include "backend/rust-tree.h"
-// TODO: this will have to be significantly modified to work with Rust
-
-// 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
-// non-zero size. However, when referring to the global variable, we
-// want an expression of zero size; otherwise, if, say, the global
-// variable is passed to a function, we will be passing a
-// non-zero-sized value to a zero-sized value, which can lead to a
-// miscompilation.
-
-class Bvariable
-{
-public:
- Bvariable (tree t) : t_ (t), orig_type_ (NULL) {}
-
- Bvariable (tree t, tree orig_type) : t_ (t), orig_type_ (orig_type) {}
-
- // Get the tree for use as an expression.
- tree get_tree (Location) const;
-
- // Get the actual decl;
- tree get_decl () const { return this->t_; }
-
-private:
- tree t_;
- tree orig_type_;
-};
-
// Get the tree of a variable for use as an expression. If this is a
// zero-sized global, create an expression that refers to the decl but
// has zero size.
diff --git a/gcc/rust/rust-gcc.h b/gcc/rust/rust-gcc.h
new file mode 100644
index 00000000000..085c16d0f3b
--- /dev/null
+++ b/gcc/rust/rust-gcc.h
@@ -0,0 +1,58 @@
+// rust-gcc.cc -- Rust frontend to gcc IR.
+// Copyright (C) 2011-2022 Free Software Foundation, Inc.
+// Contributed by Ian Lance Taylor, Google.
+// forked from gccgo
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include "rust-system.h"
+
+// This has to be included outside of extern "C", so we have to
+// include it here before tree.h includes it later.
+#include <gmp.h>
+
+#include "tree.h"
+#include "rust-location.h"
+
+// TODO: this will have to be significantly modified to work with Rust
+
+// 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
+// non-zero size. However, when referring to the global variable, we
+// want an expression of zero size; otherwise, if, say, the global
+// variable is passed to a function, we will be passing a
+// non-zero-sized value to a zero-sized value, which can lead to a
+// miscompilation.
+
+class Bvariable
+{
+public:
+ Bvariable (tree t) : t_ (t), orig_type_ (NULL) {}
+
+ Bvariable (tree t, tree orig_type) : t_ (t), orig_type_ (orig_type) {}
+
+ // Get the tree for use as an expression.
+ tree get_tree (Location) const;
+
+ // Get the actual decl;
+ tree get_decl () const { return this->t_; }
+
+private:
+ tree t_;
+ tree orig_type_;
+};
--
2.39.1
reply other threads:[~2023-01-31 13:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230131132335.661108-1-arthur.cohen@embecosm.com \
--to=arthur.cohen@embecosm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gcc-rust@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).