From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 3E64B392AF99 for ; Tue, 31 Jan 2023 13:28:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E64B392AF99 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-ej1-x62e.google.com with SMTP id bk15so41547310ejb.9 for ; Tue, 31 Jan 2023 05:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=L3317EO5kXFvGGnq8KgoHbFOtqhBfgoPZl+rK4r9Dbc=; b=QkVsVvXV7UJAcVsUcIA/Sth1GbTrjhAn1+bAAxopi1iNAhz3Xmk7QfCq40vCLthTCK B6JB3veoWU4JU+2j2YE+XkEuDP2nN80CXGhmllmx1zdrZZ+sYQ3BSmPO/buMg9oV7uUR r/xUIi2WleW94hnU2J0X7V7nkRiCB0lBh+Mw+8//wPn6P8Xx78D4MDj9CKaVSrEbh4zx rvAzbjTnpkMRWiT8mlrersQ0Xgbt931bOZrw07BpCsYaA62uyv+cQzzBz0ukc+GqOQZ+ j5jix6HutqlomrZaxT2ub1tE+0YvZJyz0dK1aTa/bULH/AG0SBlM7K2DBE5xkViwR7DH aS8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L3317EO5kXFvGGnq8KgoHbFOtqhBfgoPZl+rK4r9Dbc=; b=kaHiME1h7E8CcGsSfmTvN3FIyURJdYaLa9C1q37nFW2FZxj5eVCqQ1Fhig2tEQCCW0 0n6I8ucgLNTRmnN2dHpBWPRbwwvxjp6JKV9RBT1ekr1rBpByy5dYgmnuXv8Wo6XVCRV9 NHYBMXgasAg9X7LbvRgjSRik2GJHpgCe+9BwdtomYQGfpeyMwjmlzAXN9M/2r9OR2k/b GEA7EAjRMvGZExxszk/A+NZat+ZZHLEv2YxQpaAe4NLZ+o/jDiF/RKnKQWojU/2bgZaP AArbN94avOyAKc6B1mZ6t8iih6fen7Ur6YfCSI9ZoMP1+RVlwSbASUS0aXo9reQ7A0NO p28A== X-Gm-Message-State: AO0yUKXQROd8R0+ERJ9N/vlui3uI6uIXRMM7xMO0giEa7gQg5VM60lXa WavsZsS/ncGonBmzb6mUN1CLa8nA8xCB/3P0Xg== X-Google-Smtp-Source: AMrXdXuPesVZc1boV8rWhmruBkCNXCwqv/TH5KfU0f7YbhqofKvoh1Tk81rrUJGC3AurskMACdA5Vw== X-Received: by 2002:adf:e9d2:0:b0:242:800:9a7f with SMTP id l18-20020adfe9d2000000b0024208009a7fmr47211433wrn.65.1675171211078; Tue, 31 Jan 2023 05:20:11 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id n9-20020a5d4c49000000b002bfb7c2430bsm14697480wrt.19.2023.01.31.05.20.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:20:10 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [COMMITTED] gccrs: backend: Expose Bvariable class through rust-gcc header Date: Tue, 31 Jan 2023 14:23:36 +0100 Message-Id: <20230131132335.661108-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 +// . + +#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_; +}; -- 2.39.1