aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorbadumbatish <tanghocle456@gmail.com>2024-09-04 23:59:36 -0700
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-10-17 08:38:08 +0000
commit2d95e156b4f69ebad177c90cfada79ba896f32f9 (patch)
treebaf80621163ee74c6cf41d170e45003165a9ae03 /gcc/rust
parent0b18baee05946a25ab757cac238c52e103e9a861 (diff)
downloadgcc-2d95e156b4f69ebad177c90cfada79ba896f32f9.zip
gcc-2d95e156b4f69ebad177c90cfada79ba896f32f9.tar.gz
gcc-2d95e156b4f69ebad177c90cfada79ba896f32f9.tar.bz2
Provide input operand for gccrs
gcc/rust/ChangeLog: * backend/rust-compile-asm.cc (CompileAsm::asm_construct_inputs): Provide input operand for gccrs * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Move expr to In (expand_inline_asm_strings): Add comments to debug strings gcc/testsuite/ChangeLog: * rust/compile/inline_asm_parse_operand.rs: Remove inout, functionality not supported. Remove redundant {} * rust/execute/torture/inline_asm_mov_x_5_ARM.rs: Add operand in * rust/execute/torture/inline_asm_mov_x_5_x86_64.rs: Likewise
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/backend/rust-compile-asm.cc22
-rw-r--r--gcc/rust/expand/rust-macro-builtins-asm.cc9
2 files changed, 25 insertions, 6 deletions
diff --git a/gcc/rust/backend/rust-compile-asm.cc b/gcc/rust/backend/rust-compile-asm.cc
index 953e913..751d64e 100644
--- a/gcc/rust/backend/rust-compile-asm.cc
+++ b/gcc/rust/backend/rust-compile-asm.cc
@@ -1,5 +1,4 @@
#include "rust-compile-asm.h"
-#include "rust-system.h"
#include "rust-compile-expr.h"
namespace Rust {
namespace Compile {
@@ -107,7 +106,26 @@ tree
CompileAsm::asm_construct_inputs (HIR::InlineAsm &expr)
{
// TODO: Do i need to do this?
- return NULL_TREE;
+ tree head = NULL_TREE;
+ for (auto &input : expr.get_operands ())
+ {
+ if (input.get_register_type () == AST::InlineAsmOperand::RegisterType::In)
+ {
+ auto in = input.get_in ();
+
+ tree in_tree = CompileExpr::Compile (in.expr.get (), this->ctx);
+ // expects a tree list
+ // TODO: This assumes that the input is a register
+ std::string expr_name = "r";
+ auto name = build_string (expr_name.size () + 1, expr_name.c_str ());
+ head
+ = chainon (head, build_tree_list (build_tree_list (NULL_TREE, name),
+ in_tree));
+
+ /*head = chainon (head, out_tree);*/
+ }
+ }
+ return head;
}
tree
diff --git a/gcc/rust/expand/rust-macro-builtins-asm.cc b/gcc/rust/expand/rust-macro-builtins-asm.cc
index 061c684..2b86b81 100644
--- a/gcc/rust/expand/rust-macro-builtins-asm.cc
+++ b/gcc/rust/expand/rust-macro-builtins-asm.cc
@@ -330,8 +330,8 @@ parse_reg_operand_in (InlineAsmContext inline_asm_ctx)
// TODO: When we've succesfully parse an expr, remember to clone_expr()
// instead of nullptr
- // struct AST::InlineAsmOperand::In in (reg, nullptr);
- // inline_asm_ctx.inline_asm.operands.push_back (in);
+ struct AST::InlineAsmOperand::In in (reg, std::move (expr));
+ inline_asm_ctx.inline_asm.operands.push_back (in);
return inline_asm_ctx;
}
return tl::unexpected<InlineAsmParseError> (NONCOMMITED);
@@ -792,8 +792,9 @@ expand_inline_asm_strings (InlineAsmContext inline_asm_ctx)
* trait});*/
transformed_template_str += "%" + std::to_string (idx);
- /*std::cout << "argument implicitly is: " << idx <<
- * std::endl;*/
+ // std::cout << "argument implicitly is: " << idx <<
+ // std::endl; std::cout << "transformed template str is:"
+ // << transformed_template_str << std::endl;
/*std::cout << "trait: " << trait.to_string () <<
* std::endl;*/
/*std::cout << "arg: " << arg.to_string () << std::endl;*/