aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand
diff options
context:
space:
mode:
authorjjasmine <tanghocle456@gmail.com>2024-05-28 01:21:07 -0700
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:43 +0100
commit5d2d1a2d9818bcde16e0c41df450e2537fb1fee4 (patch)
treea7fa106fbd1074b4525bed8630aa2cad97bb772a /gcc/rust/expand
parentaf786adccd9deaad6aad9e7a6472e26b1904b995 (diff)
downloadgcc-5d2d1a2d9818bcde16e0c41df450e2537fb1fee4.zip
gcc-5d2d1a2d9818bcde16e0c41df450e2537fb1fee4.tar.gz
gcc-5d2d1a2d9818bcde16e0c41df450e2537fb1fee4.tar.bz2
gccrs: Working towards parse_reg and parse_reg_operand
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg): Working towards parse_reg and parse_reg_operand (parse_reg_operand): Working towards parse_reg and parse_reg_operand (parse_asm_arg): Add todo about errors * expand/rust-macro-builtins-asm.h (parse_global_asm): remove dead code. (parse_nonglobal_asm): remove dead code.
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r--gcc/rust/expand/rust-macro-builtins-asm.cc29
-rw-r--r--gcc/rust/expand/rust-macro-builtins-asm.h4
2 files changed, 20 insertions, 13 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins-asm.cc b/gcc/rust/expand/rust-macro-builtins-asm.cc
index 3ce9bf9..9e02400 100644
--- a/gcc/rust/expand/rust-macro-builtins-asm.cc
+++ b/gcc/rust/expand/rust-macro-builtins-asm.cc
@@ -141,11 +141,10 @@ parse_reg (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
// InlineAsmRegOrRegClass of reg or reg class
auto token = parser.peek_current_token ();
auto tok_id = token->get_id ();
-
- if (tok_id == IDENTIFIER)
+ AST::InlineAsmRegOrRegClass regClass;
+ if (parser.skip_token (IDENTIFIER))
{
// construct a InlineAsmRegOrRegClass
- AST::InlineAsmRegOrRegClass regClass;
regClass.type = RegType::RegClass;
regClass.regClass.Symbol = token->as_string ();
}
@@ -156,18 +155,27 @@ parse_reg (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
// construct a InlineAsmRegOrRegClass
// parse_format_string
+ regClass.type = RegType::Reg;
+ inlineAsmCtx.is_explicit = true;
+ regClass.regClass.Symbol = token->as_string ();
}
else
{
- // TODO
+ // TODO: This should emit error
+ // return
+ // Err(p.dcx().create_err(errors::ExpectedRegisterClassOrExplicitRegister
+ // {
+ // span: p.token.span,
+ // }));
}
if (!parser.skip_token (RIGHT_PAREN))
{
- // we expect a left parenthesis here, please return the correct error.
+ // TODO: we expect a left parenthesis here, please return the correct
+ // error.
return tl::nullopt;
}
- return tl::nullopt;
+ return regClass;
}
int
@@ -193,7 +201,7 @@ parse_reg_operand (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
// };
using RegisterType = AST::InlineAsmOperand::RegisterType;
-
+ AST::InlineAsmOperand reg_operand;
auto token = parser.peek_current_token ();
auto iden_token = parser.peek_current_token ();
auto &inlineAsm = inlineAsmCtx.inlineAsm;
@@ -221,8 +229,9 @@ parse_reg_operand (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
{}
else if (!is_global_asm && check_identifier (parser, "inlateout"))
{}
- else if (false && check_identifier (parser, "const"))
+ else if (parser.peek_current_token ()->get_id () == CONST)
{
+ rust_unreachable ();
// todo: Please handle const
}
else if (false && check_identifier (parser, "sym"))
@@ -237,7 +246,7 @@ parse_reg_operand (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
{
return tl::nullopt;
}
- return tl::nullopt;
+ return reg_operand;
}
void
check_and_set (Parser<MacroInvocLexer> &parser, InlineAsmContext &inlineAsmCtx,
@@ -410,6 +419,8 @@ parse_asm_arg (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
}
else
{
+ // TODO: we consumed comma, and there happens to also be a comma
+ // error should be: expected expression, found `,`
break;
}
diff --git a/gcc/rust/expand/rust-macro-builtins-asm.h b/gcc/rust/expand/rust-macro-builtins-asm.h
index a35d770..c7fcf30 100644
--- a/gcc/rust/expand/rust-macro-builtins-asm.h
+++ b/gcc/rust/expand/rust-macro-builtins-asm.h
@@ -35,10 +35,6 @@ parse_asm_arg (Parser<MacroInvocLexer> &p, TokenId last_token_id,
InlineAsmContext &inlineAsmCtx);
tl::optional<AST::Fragment>
-parse_global_asm (location_t invoc_locus, AST::MacroInvocData &invoc);
-tl::optional<AST::Fragment>
-parse_nonglobal_asm (location_t invoc_locus, AST::MacroInvocData &invoc);
-tl::optional<AST::Fragment>
parse_asm (location_t invoc_locus, AST::MacroInvocData &invoc,
bool is_global_asm);