aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-ast-resolve-expr.cc
diff options
context:
space:
mode:
authorbadumbatish <tanghocle456@gmail.com>2024-07-30 20:22:48 -0700
committerCohenArthur <arthur.cohen@embecosm.com>2024-08-02 11:39:01 +0000
commit812c5347bc088783ac3587f3ffab709968a7e628 (patch)
tree8f69825d70cc6eec957e61626d7f6da491042d03 /gcc/rust/resolve/rust-ast-resolve-expr.cc
parentbcd860f7f54a241ca8a2ce6fb4d61069fd7139d0 (diff)
downloadgcc-812c5347bc088783ac3587f3ffab709968a7e628.zip
gcc-812c5347bc088783ac3587f3ffab709968a7e628.tar.gz
gcc-812c5347bc088783ac3587f3ffab709968a7e628.tar.bz2
Implement resolve expr for inline asm ast
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Implement resolve expr for inline asm ast (translate_operand): Likewise. * resolve/rust-ast-resolve-expr.h: Likewise.
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve-expr.cc')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-expr.cc67
1 files changed, 61 insertions, 6 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc
index 1bb3fc6..cc7c11c 100644
--- a/gcc/rust/resolve/rust-ast-resolve-expr.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc
@@ -347,6 +347,60 @@ ResolveExpr::visit (AST::BlockExpr &expr)
}
void
+translate_operand (AST::InlineAsm &expr, const CanonicalPath &prefix,
+ const CanonicalPath &canonical_prefix)
+{
+ const auto &operands = expr.get_operands ();
+ using RegisterType = AST::InlineAsmOperand::RegisterType;
+ for (auto &operand : operands)
+ {
+ switch (operand.get_register_type ())
+ {
+ case RegisterType::In: {
+ auto in = operand.get_in ();
+ ResolveExpr::go (*in.expr, prefix, canonical_prefix);
+ break;
+ }
+ case RegisterType::Out: {
+ auto out = operand.get_out ();
+ ResolveExpr::go (*out.expr, prefix, canonical_prefix);
+ break;
+ }
+ case RegisterType::InOut: {
+ auto in_out = operand.get_in_out ();
+ ResolveExpr::go (*in_out.expr, prefix, canonical_prefix);
+ break;
+ }
+ case RegisterType::SplitInOut: {
+ auto split_in_out = operand.get_split_in_out ();
+ ResolveExpr::go (*split_in_out.in_expr, prefix, canonical_prefix);
+ ResolveExpr::go (*split_in_out.out_expr, prefix, canonical_prefix);
+ break;
+ }
+ case RegisterType::Const: {
+ auto anon_const = operand.get_const ().anon_const;
+ ResolveExpr::go (*anon_const.expr, prefix, canonical_prefix);
+ break;
+ }
+ case RegisterType::Sym: {
+ auto sym = operand.get_sym ();
+ ResolveExpr::go (*sym.expr, prefix, canonical_prefix);
+ break;
+ }
+ case RegisterType::Label: {
+ auto label = operand.get_label ();
+ ResolveExpr::go (*label.expr, prefix, canonical_prefix);
+ break;
+ }
+ }
+ }
+}
+void
+ResolveExpr::visit (AST::InlineAsm &expr)
+{
+ translate_operand (expr, prefix, canonical_prefix);
+}
+void
ResolveExpr::visit (AST::UnsafeBlockExpr &expr)
{
expr.get_block_expr ().accept_vis (*this);
@@ -477,12 +531,13 @@ ResolveExpr::visit (AST::BreakExpr &expr)
auto &break_expr = expr.get_break_expr ();
if (break_expr.get_ast_kind () == AST::Kind::IDENTIFIER)
{
- /* This is a break with an expression, and the expression is just a
- single identifier. See if the identifier is either "rust" or
- "gcc", in which case we have "break rust" or "break gcc", and so
- may need to emit our funny error. We cannot yet emit the error
- here though, because the identifier may still be in scope, and
- ICE'ing on valid programs would not be very funny. */
+ /* This is a break with an expression, and the expression is
+ just a single identifier. See if the identifier is either
+ "rust" or "gcc", in which case we have "break rust" or "break
+ gcc", and so may need to emit our funny error. We cannot yet
+ emit the error here though, because the identifier may still
+ be in scope, and ICE'ing on valid programs would not be very
+ funny. */
std::string ident
= static_cast<AST::IdentifierExpr &> (break_expr).as_string ();
if (ident == "rust" || ident == "gcc")