Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline asm #2982

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft

Inline asm #2982

wants to merge 22 commits into from

Conversation

badumbatish
Copy link
Contributor

Draft PR for my mentors

@badumbatish badumbatish force-pushed the inline_asm branch 6 times, most recently from 5a0f0a9 to 69a06ce Compare May 22, 2024 04:28
gcc/rust/ast/rust-expr.h Outdated Show resolved Hide resolved
gcc/rust/ast/rust-expr.h Outdated Show resolved Hide resolved
gcc/rust/expand/rust-macro-builtins.cc Outdated Show resolved Hide resolved
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (struct AsmParseError): title.
	(enum InlineAsmDirSpec): title.
	(enum InlineAsmOptions): title.
	(struct AsmArg): title.
	(parseAsmArg): title.
	(parse_global_asm): title.
	(parse_nonglobal_asm): title.
	(parse_asm): title.
	(parseDirSpec): title.
	(parse_format_string): title.
	(MacroBuiltin::global_asm_handler): title.
	(MacroBuiltin::nonglobal_asm_handler): title.
	* expand/rust-macro-builtins.cc: title.
	* expand/rust-macro-builtins.h: title.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (enum InlineAsmRegOrRegClass): title.
	(parseAsmArg): title.
	(check_identifier): title.
	(parse_operand): title.
	(parse_options): title.
	(parse_reg): title.
	(parseDirSpec): title.
	(parse_asm): title.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): title.
	(parseAsmArg): title.
	* expand/rust-macro-builtins-asm.h (parse_clobber_abi): title.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_options): title.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): title.
Finish up on parse_option, formatted parse_clobber_abi
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): format
	(check_and_set): helper function, is try_set_option equivalent
	(parse_options): new function
	* expand/rust-macro-builtins-asm.h (enum InlineAsmOptions):
	removed
	(check_and_set): decl of helper function
gcc/rust/ChangeLog:

	* ast/rust-expr.h: Introduced is_global_asm to InlineAsm AST
gcc/rust/ChangeLog:

	* ast/rust-expr.h: Make InlineAsm non-abstract for usage in parsing.
Replace scaffolded InlineAsm with real InlineAsm node in rust-expr.h

gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parseDirSpec): replace
	scaffolded InlineAsm with real InlineAsm.
	(parse_clobber_abi): likewise.
	(check_and_set): likewise.
	(parse_options): likewise.
	(parseAsmArg): likewise.
	(parse_asm): likewise.
	* expand/rust-macro-builtins-asm.h (struct AsmParseError): likewise.
	(enum InlineAsmDirSpec): likewise.
	(enum InlineAsmRegOrRegClass): likewise.
	(struct AsmArg): likewise.
	(parseAsmArg): likewise.
	(check_and_set): likewise.
	(parse_operand): likewise.
	(parse_options): likewise.
	(parse_reg): likewise.
	(parse_clobber_abi): likewise.
gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_nop.rs: Simple test for asm!
gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_ident_first.rs: New test.
gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_nop_2.rs: New test.
gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_faulty_clobber.rs: New test.
	* rust/compile/inline_asm_faulty_clobber_1.rs: New test.
	* rust/compile/inline_asm_faulty_clobber_2.rs: New test.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
	implemented parse_clobber_abi
	(parse_format_string): likewise.
	(parseAsmArg): likewise.
	(parse_asm): likewise.
	* expand/rust-macro-builtins-asm.h (parseAsmArg): likewise.
This is without any mutually exclusive options checked, or
any relationship with reg_operands. Very primitive.

gcc/rust/ChangeLog:

	* ast/rust-expr.h: parsing of options(...)
	* expand/rust-macro-builtins-asm.cc (check_and_set):
	likewise.
	(parse_options): likewise.
	(parseAsmArg): likewise.
	* expand/rust-macro-builtins-asm.h (check_and_set):
	likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_legal_options.rs: New test.
gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_faulty_clobber.rs:
	Wraps inline_asm tests in unsafe {}
	* rust/compile/inline_asm_faulty_clobber_1.rs: likewise.
	* rust/compile/inline_asm_faulty_clobber_2.rs: likewise.
	* rust/compile/inline_asm_ident_first.rs: likewise.
	* rust/compile/inline_asm_nop.rs: likewise.
	* rust/compile/inline_asm_nop_2.rs: likewise.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (check_and_set):
	Add checks for duplicate options in inline asm
	(parse_options): likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_illegal_options.rs: New test.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.h (parseAsmArg):
	Resolve static decl warning
	(parse_nonglobal_asm):
	Resolve static decl warning
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.
Rename InlineAsmOptions to InlineAsmOption for clarity

gcc/rust/ChangeLog:

	* ast/rust-ast-full-decls.h (enum class):
	Rename InlineAsmOptions to InlineAsmOption for clarity
	* ast/rust-expr.h (enum class): Likewise.
	* expand/rust-macro-builtins-asm.cc (check_and_set): Likewise.
	(parse_options): Likewise.
	* expand/rust-macro-builtins-asm.h (check_and_set): Likewise.
	* hir/tree/rust-hir-expr.h: Likewise.
Safegaurd InlineAsm's clone_expr_... with unreachable since
we would never use them.

gcc/rust/ChangeLog:

	* ast/rust-expr.h:
	Safegaurd InlineAsm's clone_expr_... with unreachable.
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc
	(MacroBuiltin::global_asm_handler):
	Remove global_asm and non_global_asm handler
	(MacroBuiltin::nonglobal_asm_handler): Likewise.
	(MacroBuiltin::asm_handler): Likewise.
	* expand/rust-macro-builtins.cc (enum class): Likewise.
	(inline_asm_maker): Likewise.
	* expand/rust-macro-builtins.h: Likewise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants