https://gcc.gnu.org/g:d7e88ed1c8d7eaadf6fc8b8f1e554d4fe6312e37

commit r15-8340-gd7e88ed1c8d7eaadf6fc8b8f1e554d4fe6312e37
Author: badumbatish <tanghocle...@gmail.com>
Date:   Sun Jun 30 16:48:30 2024 -0700

    gccrs: Scaffolding new compile-asm files
    
    gcc/rust/ChangeLog:
    
            * Make-lang.in:
            Scaffolding new compile-asm files
            * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise
            * hir/tree/rust-hir-expr.h: Likewise
            * backend/rust-compile-asm.cc: New file. Likewise
            * backend/rust-compile-asm.h: New file. Likewise

Diff:
---
 gcc/rust/Make-lang.in                 |  1 +
 gcc/rust/backend/rust-compile-asm.cc  | 80 +++++++++++++++++++++++++++++++++++
 gcc/rust/backend/rust-compile-asm.h   | 46 ++++++++++++++++++++
 gcc/rust/backend/rust-compile-expr.cc |  9 ++--
 gcc/rust/hir/tree/rust-hir-expr.h     | 35 ---------------
 5 files changed, 131 insertions(+), 40 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index c892fa3091e3..d291dd647654 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -196,6 +196,7 @@ GRS_OBJS = \
     rust/rust-compile-item.o \
     rust/rust-compile-implitem.o \
     rust/rust-compile-stmt.o \
+    rust/rust-compile-asm.o \
     rust/rust-compile-expr.o \
     rust/rust-compile-type.o \
     rust/rust-compile-block.o \
diff --git a/gcc/rust/backend/rust-compile-asm.cc 
b/gcc/rust/backend/rust-compile-asm.cc
new file mode 100644
index 000000000000..5bc7bce07e66
--- /dev/null
+++ b/gcc/rust/backend/rust-compile-asm.cc
@@ -0,0 +1,80 @@
+#include "rust-compile-asm.h"
+
+#include "rust-tree.h"
+#include "rust-system.h"
+namespace Rust {
+namespace Compile {
+
+tree
+CompileAsm::asm_build_expr (HIR::InlineAsm &expr)
+{
+  return NULL_TREE;
+  // return build_asm_expr (CompileAsm::asm_get_locus (expr),
+  //                    CompileAsm::asm_construct_string_tree (expr),
+  //                    CompileAsm::asm_construct_outputs (expr),
+  //                    CompileAsm::asm_construct_inputs (expr),
+  //                    CompileAsm::asm_construct_clobber_tree (expr),
+  //                    CompileAsm::asm_construct_label_tree (expr),
+  //                    CompileAsm::asm_is_simple (expr),
+  //                    CompileAsm::asm_is_inline (expr));
+}
+
+location_t
+CompileAsm::asm_get_locus (HIR::InlineAsm &expr)
+{
+  return expr.get_locus ();
+}
+tree
+CompileAsm::asm_construct_string_tree (HIR::InlineAsm &expr)
+{
+  if (expr.template_strs.empty ())
+    return build_string (1, "");
+  // Initialize to NULL_TREE
+  tree string_chain = NULL_TREE;
+
+  for (const auto &template_str : expr.template_strs)
+    {
+      auto str = template_str.symbol;
+      auto string_tree = build_string (str.size () + 1, str.c_str ());
+
+      string_chain = tree_cons (NULL_TREE, string_tree, string_chain);
+    }
+  // Reverse the chain before returning
+  return nreverse (string_chain);
+}
+tree
+CompileAsm::asm_construct_outputs (HIR::InlineAsm &expr)
+{
+  return NULL_TREE;
+}
+
+tree
+CompileAsm::asm_construct_inputs (HIR::InlineAsm &expr)
+{
+  return NULL_TREE;
+}
+
+tree
+CompileAsm::asm_construct_clobber_tree (HIR::InlineAsm &expr)
+{
+  return NULL_TREE;
+}
+tree
+CompileAsm::asm_construct_label_tree (HIR::InlineAsm &expr)
+{
+  return NULL_TREE;
+}
+
+bool
+CompileAsm::asm_is_simple (HIR::InlineAsm &expr)
+{
+  return true;
+}
+
+bool
+CompileAsm::asm_is_inline (HIR::InlineAsm &expr)
+{
+  return true;
+}
+} // namespace Compile
+} // namespace Rust
diff --git a/gcc/rust/backend/rust-compile-asm.h 
b/gcc/rust/backend/rust-compile-asm.h
new file mode 100644
index 000000000000..58f0f51e9cf4
--- /dev/null
+++ b/gcc/rust/backend/rust-compile-asm.h
@@ -0,0 +1,46 @@
+
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
+
+// 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/>.
+
+#ifndef RUST_COMPILE_ASM
+#define RUST_COMPILE_ASM
+
+#include "rust-compile-base.h"
+#include "rust-hir-visitor.h"
+
+namespace Rust {
+namespace Compile {
+
+class CompileAsm
+{
+public:
+  static tree asm_build_expr (HIR::InlineAsm &);
+  static location_t asm_get_locus (HIR::InlineAsm &);
+  static tree asm_construct_string_tree (HIR::InlineAsm &);
+  static tree asm_construct_outputs (HIR::InlineAsm &);
+  static tree asm_construct_inputs (HIR::InlineAsm &);
+  static tree asm_construct_clobber_tree (HIR::InlineAsm &);
+  static tree asm_construct_label_tree (HIR::InlineAsm &);
+
+  static bool asm_is_simple (HIR::InlineAsm &);
+
+  static bool asm_is_inline (HIR::InlineAsm &);
+};
+} // namespace Compile
+} // namespace Rust
+#endif // RUST_COMPILE_ASM
diff --git a/gcc/rust/backend/rust-compile-expr.cc 
b/gcc/rust/backend/rust-compile-expr.cc
index 2792e8b5f043..064be6ee81f8 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -25,7 +25,7 @@
 #include "rust-constexpr.h"
 #include "rust-compile-type.h"
 #include "rust-gcc.h"
-
+#include "rust-compile-asm.h"
 #include "fold-const.h"
 #include "realmpfr.h"
 #include "convert.h"
@@ -321,10 +321,9 @@ CompileExpr::visit (HIR::IfExpr &expr)
 void
 CompileExpr::visit (HIR::InlineAsm &expr)
 {
-  // translated = build_asm_expr()(expr.get_locus(),
-  //      expr.construct_string_tree(), expr.construct_outputs(),
-  //      expr.construct_inputs(),   expr.construct_clobber_tree(),
-  //      expr.construct_label_tree(), expr.is_simple(), expr.is_inline_asm());
+  // translated = build_asm_expr (0, NULL_TREE, NULL_TREE, NULL_TREE, 
NULL_TREE,
+  //                  NULL_TREE, true, true);
+  // CompileAsm::asm_build_expr (expr);
 }
 
 void
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h 
b/gcc/rust/hir/tree/rust-hir-expr.h
index ee469806847d..2b86d59f969f 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -4163,41 +4163,6 @@ public:
       options (std::move (options))
 
   {}
-
-  tree construct_string_tree ()
-  {
-    if (template_strs.empty ())
-      return build_string (1, "");
-    // Initialize to NULL_TREE
-    tree string_chain = NULL_TREE;
-
-    for (const auto &template_str : template_strs)
-      {
-       auto str = template_str.symbol;
-       auto string_tree = build_string (str.size () + 1, str.c_str ());
-
-       string_chain = tree_cons (NULL_TREE, string_tree, string_chain);
-      }
-    // Reverse the chain before returning
-    return nreverse (string_chain);
-  }
-
-  tree construct_clobber_tree () { return NULL_TREE; }
-  tree construct_label_tree () { return NULL_TREE; }
-  tree construct_inputs () { return NULL_TREE; }
-  tree construct_outputs () { return NULL_TREE; }
-  // This function checks if the assembly macro is "simple" or not, according 
to
-  // the tree defition (tree.h) of the
-
-  // SIMPLE indicates whether there was anything at all after the
-  // string in the asm expression
-  bool is_simple ()
-  {
-    return operands.size () == 0 && clobber_abi.size () == 0
-          && options.size () == 0;
-  }
-
-  bool is_inline_asm () { return !is_global_asm; }
 };
 } // namespace HIR
 } // namespace Rust

Reply via email to