gccrs: Scaffolding parse_reg

gcc/rust/ChangeLog:

	* ast/rust-expr.h (struct InlineAsmRegOrRegClass):
	Scaffolding parse_reg
	* expand/rust-macro-builtins-asm.cc (parse_reg): Likewise.
	(parse_operand): Likewise.
	(parseAsmArg): Likewise.
This commit is contained in:
jjasmine
2024-05-24 15:18:45 -07:00
committed by Arthur Cohen
parent 3d99542a87
commit ec5104296c
3 changed files with 93 additions and 1 deletions

View File

@@ -4743,6 +4743,12 @@ struct InlineAsmRegOrRegClass
std::string Symbol;
};
Type type;
union
{
struct Reg reg;
struct RegClass regClass;
};
Identifier name;
location_t locus;
};

View File

@@ -0,0 +1,39 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "datafrog"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
[[package]]
name = "ffi-polonius"
version = "0.1.0"
dependencies = [
"polonius-engine",
]
[[package]]
name = "log"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "polonius-engine"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4e8e505342045d397d0b6674dcb82d6faf5cf40484d30eeb88fc82ef14e903f"
dependencies = [
"datafrog",
"log",
"rustc-hash",
]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"

View File

@@ -125,6 +125,53 @@ parse_clobber_abi (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
return 0;
}
int
parse_reg (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
AST::InlineAsm &inlineAsm, bool is_explicit)
{
if (!parser.skip_token (LEFT_PAREN))
{
// TODO: we expect a left parenthesis here, please return the correct
// error.
return 0;
}
// after successful left parenthesis parsing, we should return ast of
// InlineAsmRegOrRegClass of reg or reg class
auto token = parser.peek_current_token ();
auto tok_id = token->get_id ();
if (tok_id == IDENTIFIER)
{
// construct a InlineAsmRegOrRegClass
}
else if (tok_id == STRING_LITERAL)
{
// TODO: there is STRING_LITERAL, and BYTE_STRING_LITERAL, should we check
// for both?
// construct a InlineAsmRegOrRegClass
}
else
{
// TODO
}
if (!parser.skip_token (RIGHT_PAREN))
{
// we expect a left parenthesis here, please return the correct error.
return 0;
}
return 0;
}
int
parse_operand (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
AST::InlineAsm &inlineAsm)
{
return 0;
}
void
check_and_set (Parser<MacroInvocLexer> &parser, AST::InlineAsm &inlineAsm,
AST::InlineAsmOptions option)
@@ -340,7 +387,7 @@ parseAsmArg (Parser<MacroInvocLexer> &parser, TokenId last_token_id,
return 0;
}
static tl::optional<AST::Fragment>
tl::optional<AST::Fragment>
parse_asm (location_t invoc_locus, AST::MacroInvocData &invoc,
bool is_global_asm)
{