From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 006433858D39; Wed, 31 Aug 2022 10:40:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 006433858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661942435; bh=IgIt6uDqvwzGwp7wPgzIr+G33hYKLkt5aQpFiWkYh5c=; h=From:To:Subject:Date:From; b=wBl/ytHKbrjrVpnR7fLD/+u6p3nOD1G5ItliTuFcCNEdYKMqflXyF8LvFNsQ6X3kO w4irt8hJJxaDoi9ftonG4WrhgdrGCgEcaj/qMeSN7vM1pOIrpF+DbFAdMr7/i3JraT utjUfeJW0kgMYdTu2aOaDh1LgJlzWqgjMPT3GZcI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] backend: Expose Bvariable class through rust-gcc header X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 1416b85322cd9cd74c7a79e3270bb334ceb3a44c X-Git-Newrev: 3e79563a65e78ddb6b2ef10df7e1d4e3441aaff2 Message-Id: <20220831104035.006433858D39@sourceware.org> Date: Wed, 31 Aug 2022 10:40:34 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3e79563a65e78ddb6b2ef10df7e1d4e3441aaff2 commit 3e79563a65e78ddb6b2ef10df7e1d4e3441aaff2 Author: Arthur Cohen Date: Wed Aug 24 17:20:57 2022 +0200 backend: Expose Bvariable class through rust-gcc header Diff: --- gcc/rust/rust-gcc.cc | 30 +-------------------------- gcc/rust/rust-gcc.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index ffb67f3fe78..9c1bb5314bc 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 +// . + +#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 + +#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_; +};