Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,10 @@ class MCTargetAsmParser : public MCAsmParserExtension {
virtual bool equalIsAsmAssignment() { return true; };
// Return whether this start of statement identifier is a label
virtual bool isLabel(AsmToken &Token) { return true; };
// Return whether this parser accept star as start of statement
virtual bool starIsStartOfStatement() { return false; };
// Return whether this parser accepts the given token as start of statement.
virtual bool tokenIsStartOfStatement(AsmToken::TokenKind Token) {
return false;
}

virtual const MCExpr *applySpecifier(const MCExpr *E, uint32_t,
MCContext &Ctx) {
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,11 +1769,9 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
// Treat '}' as a valid identifier in this context.
Lex();
IDVal = "}";
} else if (Lexer.is(AsmToken::Star) &&
getTargetParser().starIsStartOfStatement()) {
// Accept '*' as a valid start of statement.
} else if (getTargetParser().tokenIsStartOfStatement(ID.getKind())) {
Copy link
Contributor

@s-barannikov s-barannikov May 9, 2025

Choose a reason for hiding this comment

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

LCurly/RCurly should be pushed into the new method as well, they are invalid at the start of a statement on most targets. In-tree exceptions are Hexagon (curlies are used for bundles) and X86 (used for various prefixes such as {evex}).

Copy link
Member

Choose a reason for hiding this comment

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

Follow-up:) #140101

Lex();
IDVal = "*";
IDVal = ID.getString();
} else if (parseIdentifier(IDVal)) {
if (!TheCondState.Ignore) {
Lex(); // always eat a token
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class BPFAsmParser : public MCTargetAsmParser {
bool equalIsAsmAssignment() override { return false; }
// "*" is used for dereferencing memory that it will be the start of
// statement.
bool starIsStartOfStatement() override { return true; }
bool tokenIsStartOfStatement(AsmToken::TokenKind Token) override {
return Token == AsmToken::Star;
}

#define GET_ASSEMBLER_HEADER
#include "BPFGenAsmMatcher.inc"
Expand Down