aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/rust/Make-lang.in1
-rw-r--r--gcc/rust/backend/rust-compile-asm.cc80
-rw-r--r--gcc/rust/backend/rust-compile-asm.h46
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc9
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h35
5 files changed, 131 insertions, 40 deletions
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index c892fa3..d291dd6 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 0000000..5bc7bce
--- /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 0000000..58f0f51
--- /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 2792e8b..064be6e 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 ee46980..2b86d59 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