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

Asm generic il codegen #3060

Merged
merged 23 commits into from
Sep 2, 2024
Merged

Conversation

badumbatish
Copy link
Contributor

@badumbatish badumbatish commented Jun 23, 2024

Draft PR for IL for my mentor.

I hope to get this merged into master after other misc like tl::expected and safeguard on asm has been merged first. Feels like i'll spend more time debugging without all the safety structure set up by other PRs

Fixes #3061

@badumbatish
Copy link
Contributor Author

hi @CohenArthur , i'd love to get some reviews :)

gcc/rust/backend/rust-compile-asm.cc Outdated Show resolved Hide resolved
gcc/rust/backend/rust-compile-asm.h Show resolved Hide resolved
gcc/rust/hir/tree/rust-hir-expr.h Outdated Show resolved Hide resolved
@badumbatish
Copy link
Contributor Author

dependent on #3098 and #3103 now

@badumbatish badumbatish force-pushed the asm_generic_il branch 3 times, most recently from 9b4af8f to a8c24ef Compare August 2, 2024 19:36
@badumbatish
Copy link
Contributor Author

Screenshot 2024-08-02 at 2 41 22 PM

weird format error version10 versus version14 of clang-format

@badumbatish
Copy link
Contributor Author

the tests passed for me locally but i'm not sure why it's behaving weird on CI

                  === rust Summary ===

# of expected passes            8621
# of expected failures          70
# of unsupported tests          2

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really, really, really good. well done, amazing work @badumbatish

gcc/rust/hir/tree/rust-hir-expr.h Outdated Show resolved Hide resolved
gcc/rust/backend/rust-compile-asm.h Outdated Show resolved Hide resolved
gcc/rust/backend/rust-compile-asm.h Outdated Show resolved Hide resolved
gcc/rust/backend/rust-compile-asm.h Outdated Show resolved Hide resolved
gcc/rust/expand/rust-macro-builtins-asm.cc Outdated Show resolved Hide resolved
gcc/rust/expand/rust-macro-builtins-asm.cc Outdated Show resolved Hide resolved
gcc/rust/expand/rust-macro-builtins-asm.cc Show resolved Hide resolved
gcc/rust/expand/rust-macro-builtins-asm.cc Outdated Show resolved Hide resolved
gcc/rust/expand/rust-macro-builtins-asm.h Outdated Show resolved Hide resolved
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
	Fix parsing logic & reassignment logic
	(parse_reg_operand_in): Fix parsing
	(parse_reg_operand_out): Fix parsing
	(parse_reg_operand_inout): Fix parsing
	(parse_reg_operand_unexpected): Remove rust_unreachable()
	(parse_asm_arg): Fix parsing logic
gcc/rust/ChangeLog:

	* backend/rust-compile-block.h:
	Scaffolding asm codegen
	* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
	* backend/rust-compile-expr.h: Likewise.
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise.
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise.
	* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise.
	* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
	* checks/errors/privacy/rust-privacy-reporter.h: Likewise.
	* hir/tree/rust-hir-expr.h: Likewise.
	* hir/tree/rust-hir-visitor.h: Likewise.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
	* typecheck/rust-hir-type-check-expr.h: Likewise.
gcc/rust/ChangeLog:

	* hir/tree/rust-hir.cc (InlineAsm::accept_vis):
	Make sure CompileExpr::visit is reached
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Likewise
gcc/testsuite/ChangeLog:

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

	* backend/rust-compile-expr.cc (CompileExpr::visit):
	Local testing for build_string and debug()
gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit):
	Setting up interfaces for codegen
	* hir/tree/rust-hir-expr.h: Likewise.
gcc/rust/ChangeLog:

	* Make-lang.in:
	Scaffolding new compile-asm files
	* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise
	* hir/tree/rust-hir-expr.h: Likewise
	* backend/rust-compile-asm.cc: New file. Likewise
	* backend/rust-compile-asm.h: New file. Likewise
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (CompileAsm::add_stmt):
	Scaffolding code.
	(CompileAsm::asm_build_asm_stmt): Likewise.
	(CompileAsm::asm_build_expr): Likewise.
	(CompileAsm::asm_construct_string_tree): Likewise.
	* backend/rust-compile-asm.h: Likewise.
	* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (CompileAsm::add_stmt):
	Deleted
	(CompileAsm::CompileAsm):
	Successfully produce pseudo-nop
	(CompileAsm::visit): Likewise
	(CompileAsm::asm_build_asm_stmt): Likewise
	(CompileAsm::asm_construct_string_tree): Likewise
	(CompileAsm::asm_is_inline): Likewise
	* backend/rust-compile-asm.h (class CompileAsm): Likewise
	* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (strip_double_quotes):
	Refactor compile-asm for first round review
	(CompileAsm::asm_build_asm_stmt): Likewise.
	(CompileAsm::asm_build_expr): Likewise.
	(CompileAsm::asm_get_locus): Likewise.
	(CompileAsm::asm_construct_string_tree): Likewise.
	(CompileAsm::asm_construct_outputs): Likewise.
	(CompileAsm::asm_construct_inputs): Likewise.
	(CompileAsm::asm_construct_clobber_tree): Likewise.
	(CompileAsm::asm_construct_label_tree): Likewise.
	(CompileAsm::asm_is_simple): Likewise.
	(CompileAsm::asm_is_inline): Likewise.
	* backend/rust-compile-asm.h (strip_double_quotes): Likewise.
	(class CompileAsm): Likewise.
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (CompileAsm::asm_build_expr):
	Use expr's is_simple_asm and is_inline_asm
	(CompileAsm::asm_is_simple): removed
	(CompileAsm::asm_is_inline): removed
	* backend/rust-compile-asm.h: Add docs to ASM_TREE_ARRAY_LENGTH
	* hir/tree/rust-hir-expr.h: Add is_simple_asm, is_inline_asm
	and remove #include tree
gcc/testsuite/ChangeLog:

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

	* backend/rust-compile-asm.cc (CompileAsm::asm_construct_outputs):
	Set up counting to check
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
	Remove warnings
	(parse_reg_operand_out): Remove warnings
	(expand_inline_asm): New function for eventual expansion
	(parse_asm): Use expand_inline_asm

gcc/testsuite/ChangeLog:

	* rust/execute/torture/inline_asm_mov_x_5.rs: New test.
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (strip_double_quotes):
	Move strip double quotes to parse phase
	(CompileAsm::asm_construct_string_tree): Likewise
	* backend/rust-compile-asm.h (strip_double_quotes): Likewise
	* expand/rust-macro-builtins-asm.cc (strip_double_quotes):
	Likewise
	(expand_inline_asm): Renamed to expand_inline_asm_strings
	(expand_inline_asm_strings): Renamed from expand_inline_asm
	(parse_asm): Move strip double quotes to parse phase
	(parse_format_strings): Likewise
	* expand/rust-macro-builtins-asm.h (strip_double_quotes):
	Likewise
	(expand_inline_asm_strings): Inline asm expansion fn
	(expand_inline_asm_string): Inline asm expansion fn
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (CompileAsm::asm_construct_outputs):
	Lower the HIR to tree with CompileExpr
	* backend/rust-compile-asm.h: Remove static from method
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Perform type check on InlineAsm's operand
	(typecheck_inline_asm_operand): Likewise
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (CompileAsm::asm_build_expr):
	Add debug comment
	(CompileAsm::asm_construct_outputs):
	Perform lowering hir output operand to tree
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Added noreturn checking for nevertype

gcc/testsuite/ChangeLog:

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

	* backend/rust-compile-asm.cc (CompileAsm::asm_build_expr):
	Use's array type when constring string tree
	(CompileAsm::asm_construct_string_tree):
	Use's array type when constring string tree
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (CompileAsm::asm_build_expr):
	Remove debug
	* expand/rust-macro-builtins-asm.cc (expand_inline_asm_strings):
	properly formatted via rust instead of c
	(parse_asm): formatted comment
	(parse_format_strings): formatted comment
	* hir/tree/rust-hir-expr.h: fix is_simple_asm()

gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_parse_operand.rs: Fix format asm
	* rust/compile/inline_asm_parse_output_operand.rs:
	Fix format asm
	* rust/execute/torture/inline_asm_mov_x_5.rs: Move to...
	* rust/execute/inline_asm_mov_x_5.rs: ...here.
gcc/testsuite/ChangeLog:

	* rust/execute/inline_asm_mov_x_5.rs: Move to...
	* rust/execute/torture/inline_asm_mov_x_5.rs: ...here.
gcc/rust/ChangeLog:

	* backend/rust-compile-asm.cc (CompileAsm::visit):
	Change API, public/private, comments, formatting from code
	review
	(CompileAsm::asm_build_expr): Likewise.
	(CompileAsm::tree_codegen_asm): Likewise.
	* backend/rust-compile-asm.h (class CompileAsm): Likewise.
	* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
	* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
	* expand/rust-macro-builtins-asm.cc (strip_double_quotes): Likewise.
	(parse_options): Likewise.
	(parse_asm_arg): Likewise.
	(expand_inline_asm_strings): Likewise.
	(parse_asm): Likewise.
	* expand/rust-macro-builtins-asm.h (strip_double_quotes): Likewise.
	(expand_inline_asm_strings): Likewise.
	(expand_inline_asm_string): Likewise.
	* hir/tree/rust-hir-expr.h: Likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/inline_asm_typecheck.rs: Change comments
gcc/testsuite/ChangeLog:

	* rust/execute/torture/inline_asm_mov_x_5.rs: Move to...
	* rust/execute/torture/inline_asm_mov_x_5_ARM.rs: ...here.
	* rust/execute/torture/inline_asm_mov_x_5_x86_64.rs: New test.
@CohenArthur CohenArthur added this pull request to the merge queue Sep 2, 2024
Merged via the queue into Rust-GCC:master with commit e4953b4 Sep 2, 2024
11 checks passed
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.

Typechecking of asm! failed in let _
2 participants