]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Scaffolding new compile-asm files
authorbadumbatish <tanghocle456@gmail.com>
Sun, 30 Jun 2024 23:48:30 +0000 (16:48 -0700)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 19 Mar 2025 14:32:06 +0000 (15:32 +0100)
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

gcc/rust/Make-lang.in
gcc/rust/backend/rust-compile-asm.cc [new file with mode: 0644]
gcc/rust/backend/rust-compile-asm.h [new file with mode: 0644]
gcc/rust/backend/rust-compile-expr.cc
gcc/rust/hir/tree/rust-hir-expr.h

index c892fa3091e3b68962ffe730c57a6e69f89388ce..d291dd6476546590d35b46fb761f3abd8707eb91 100644 (file)
@@ -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 (file)
index 0000000..5bc7bce
--- /dev/null
@@ -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 (file)
index 0000000..58f0f51
--- /dev/null
@@ -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
index 2792e8b5f043139c9e1ac9ba3e84fc1231dcdbf8..064be6ee81f87d1f39e8dda7c98d476bc2b365f0 100644 (file)
@@ -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
index ee469806847d0c1c54231cd48a831a36d82be86b..2b86d59f969f0a5f601ad3c9dd7ac4ecdc7cefd1 100644 (file)
@@ -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