Skip to content

Conversation

@P-E-P
Copy link
Member

@P-E-P P-E-P commented Apr 9, 2025

No description provided.

@P-E-P P-E-P force-pushed the black-box-infinite-loop branch 2 times, most recently from ce0031a to d9be35c Compare April 17, 2025 13:58
P-E-P added 2 commits April 17, 2025 16:11
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-asm.cc (parse_asm_arg): Emit error
	message.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
InlineAsm node does not support memory clobbers.

gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Make visitor
	unreachable.
	* ast/rust-ast-collector.h: Add visit for LlvmInlineAsmNode.
	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add visit
	function for the default ast visitor.
	* ast/rust-ast-visitor.h: Add function prototype.
	* ast/rust-ast.cc (LlvmInlineAsm::accept_vis): Add accept_vis to
	LlvmInlineAsm node.
	* ast/rust-ast.h: Add LlvmInlineAsm node kind.
	* ast/rust-expr.h (class LlvmInlineAsm): Add LlvmInlineAsm node.
	* expand/rust-derive.h: Add visit function for LlvmInlineAsm node.
	* expand/rust-macro-builtins-asm.cc (MacroBuiltin::llvm_asm_handler):
	Add handler for llvm inline assembly nodes.
	(parse_llvm_asm): Add function to parse llvm assembly nodes.
	* expand/rust-macro-builtins-asm.h (parse_llvm_asm): Add function
	prototypes.
	* expand/rust-macro-builtins.cc (inline_llvm_asm_maker): Add macro
	transcriber.
	* expand/rust-macro-builtins.h: Add transcriber function prototype.
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add visit
	function for LlvmInlineAsm node.
	* hir/rust-ast-lower-base.h: Add visit function prototype.
	* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visit
	function for LlvmInlineAsm node.
	* resolve/rust-ast-resolve-base.h: Add visit function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
@P-E-P P-E-P force-pushed the black-box-infinite-loop branch from d9be35c to 355b56b Compare April 17, 2025 15:17
@P-E-P P-E-P marked this pull request as ready for review April 17, 2025 15:31
@P-E-P P-E-P requested a review from CohenArthur April 17, 2025 15:31
@P-E-P P-E-P force-pushed the black-box-infinite-loop branch from 355b56b to f5696db Compare April 17, 2025 15:37
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 looks really good, well done @P-E-P thank you!

P-E-P added 4 commits April 17, 2025 18:39
Add a new HIR LlvmInlineAsm HIR node as well as some structures to
represent it's options and operands. Lower AST::LlvmInlineAsm node to it
and then create a tree from that node.

gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Remove unreachable
	code.
	* ast/rust-expr.h (struct LlvmOperand): Add LlvmOperand struct to
	represent input and outputs.
	(class LlvmInlineAsm): Add input, output and clobber operands.
	(struct TupleTemplateStr): Add locus getter.
	* backend/rust-compile-block.h: Add visit for LlvmInlineAsm.
	* backend/rust-compile-expr.cc (CompileExpr::visit): Add llvm inline
	asm stmt compilation.
	* backend/rust-compile-expr.h: Add function prototype.
	* backend/rust-compile-asm.h (class CompileLlvmAsm): Add llvm asm hir
	not to gimple.
	* backend/rust-compile-asm.cc (CompileLlvmAsm::CompileLlvmAsm): Add
	constructor.
	(CompileLlvmAsm::construct_operands): Add function to construct operand
	tree.
	(CompileLlvmAsm::construct_clobbers): Add function to construct clobber
	tree.
	(CompileLlvmAsm::tree_codegen_asm): Generate the whole tree for a given
	llvm inline assembly node.
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
	Add visit function.
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Add function
	prototype.
	* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Add visit
	function.
	* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
	* checks/errors/borrowck/rust-function-collector.h: Likewise.
	* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit):
	Likewise.
	* checks/errors/privacy/rust-privacy-reporter.h: Add visit function
	prototype.
	* checks/errors/rust-const-checker.cc (ConstChecker::visit): Add visit
	function.
	* checks/errors/rust-const-checker.h: Add visit function prototype.
	* checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit):
	Add visit function.
	* checks/errors/rust-hir-pattern-analysis.h: Add visit function
	prototype.
	* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Add
	visit function.
	* checks/errors/rust-unsafe-checker.h: Add function prototype.
	* expand/rust-macro-builtins-asm.cc (parse_llvm_templates): Parse
	templates.
	(parse_llvm_arguments): Add function to parse non template tokens.
	(parse_llvm_operands): Add function to parse operands, either input or
	output.
	(parse_llvm_outputs): Add function to parse and collect llvm asm
	outputs.
	(parse_llvm_inputs): Likewise with inputs.
	(parse_llvm_clobbers): Add function to parse llvm asm clobbers.
	(parse_llvm_options): Add function to parse llvm asm options.
	(parse_llvm_asm): Add function to parse llvm asm.
	* expand/rust-macro-builtins-asm.h (class LlvmAsmContext): Add context
	for llvm asm parser.
	(parse_llvm_outputs): Add function prototype.
	(parse_llvm_inputs): Likewise.
	(parse_llvm_clobbers): Likewise.
	(parse_llvm_options): Likewise.
	* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Lower AST llvm
	asm node to HIR.
	* hir/rust-ast-lower-expr.h: Add function prototype.
	* hir/rust-hir-dump.cc (Dump::visit): Add visit function.
	* hir/rust-hir-dump.h: Add function prototype.
	* hir/tree/rust-hir-expr-abstract.h: Add HIR llvm asm node kind.
	* hir/tree/rust-hir-expr.h (struct LlvmOperand): Add LlvmOperand type
	to represent input and outputs.
	(class LlvmInlineAsm): Add LlvmInlineAsm hir node.
	* hir/tree/rust-hir-full-decls.h (class LlvmInlineAsm): Add
	LlvmInlineAsm hir node forward declaration.
	* hir/tree/rust-hir-visitor.h: Add visit functions for LlvmInlineAsm
	hir node.
	* hir/tree/rust-hir.cc (LlvmInlineAsm::accept_vis): Add hir node
	visitor related functions.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Type check input and output operands.
	* typecheck/rust-hir-type-check-expr.h: Add function prototype.
	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit input and
	output operand expressions.
	* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve input
	and output expressions.
	* resolve/rust-ast-resolve-expr.h: Add function prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Dump llvm inline
	asm tokens.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/ChangeLog:

	* rust/execute/black_box.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/ChangeLog:

	* rust/compile/black_box.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
@P-E-P P-E-P force-pushed the black-box-infinite-loop branch from 48daeb2 to 0707131 Compare April 17, 2025 16:39
@P-E-P P-E-P added this pull request to the merge queue Apr 17, 2025
Merged via the queue into Rust-GCC:master with commit d85328b Apr 17, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in libcore 1.49 Apr 17, 2025
@P-E-P P-E-P deleted the black-box-infinite-loop branch August 5, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants