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

Cleanup GCCAsmStmt children iterations #131358

Open
cor3ntin opened this issue Mar 14, 2025 · 3 comments
Open

Cleanup GCCAsmStmt children iterations #131358

cor3ntin opened this issue Mar 14, 2025 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" code-cleanup

Comments

@cor3ntin
Copy link
Contributor

GCCAsmStmt stores its arguments in separately allocated array

StringLiteral *AsmStr;
// FIXME: If we wanted to, we could allocate all of these in one big array.
StringLiteral **Constraints = nullptr;
StringLiteral **Clobbers = nullptr;
IdentifierInfo **Names = nullptr;
unsigned NumLabels = 0;

And is not considered to have any children.

Instead, we should store all these statements (contiguously) within the Exprs of ASmStmt and make sure that's returned from children()

Stmt **Exprs = nullptr;

However, we should also make sure that the order of the children - and therefore the order of elements
in Expr makes sense,

ie Template, OutputConstraint0, OutputExpr0, ... OutputConstraintN, OutputExprN, InputConstraint0, InputExpr0, ... InputConstraintN, InputExprN, Label0, ...

Constructors, Getter, Setters, etc of GCCAsmStmt needs to be adapted to understand this order

@cor3ntin cor3ntin added clang:frontend Language frontend issues, e.g. anything involving "Sema" code-cleanup labels Mar 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 14, 2025

@llvm/issue-subscribers-clang-frontend

Author: cor3ntin (cor3ntin)

`GCCAsmStmt` stores its arguments in separately allocated array

StringLiteral *AsmStr;
// FIXME: If we wanted to, we could allocate all of these in one big array.
StringLiteral **Constraints = nullptr;
StringLiteral **Clobbers = nullptr;
IdentifierInfo **Names = nullptr;
unsigned NumLabels = 0;

And is not considered to have any children.

Instead, we should store all these statements (contiguously) within the Exprs of ASmStmt and make sure that's returned from children()

Stmt **Exprs = nullptr;

However, we should also make sure that the order of the children - and therefore the order of elements
in Expr makes sense,

ie Template, OutputConstraint0, OutputExpr0, ... OutputConstraintN, OutputExprN, InputConstraint0, InputExpr0, ... InputConstraintN, InputExprN, Label0, ...

Constructors, Getter, Setters, etc of GCCAsmStmt needs to be adapted to understand this order

@cor3ntin
Copy link
Contributor Author

Note that we should wait #131003 to be merged before working on this

@erichkeane
Copy link
Collaborator

This is perhaps a 'medium first issue' as it requires significantly modifying the AST node, but is on the easier side. Any such patch should also refactor the MSAsmStmt.

Basically, we need to spend time evaluating the three types (AsmStmt, GCCAsmStmt and MSAsmStmt) to refactor them and make them more prototypical of our struct layouts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" code-cleanup
Projects
None yet
Development

No branches or pull requests

3 participants