[llvm] 56600c1 - MCAsmInfo: replace HLASM-specific variables with IsHLASM
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 24 18:37:52 PST 2024
Author: Fangrui Song
Date: 2024-12-24T18:37:46-08:00
New Revision: 56600c11add12aababdd313c43650facf2a0338f
URL: https://github.com/llvm/llvm-project/commit/56600c11add12aababdd313c43650facf2a0338f
DIFF: https://github.com/llvm/llvm-project/commit/56600c11add12aababdd313c43650facf2a0338f.diff
LOG: MCAsmInfo: replace HLASM-specific variables with IsHLASM
HLASM is very different from the gas syntax. We don't expect other
targets to customize the differences. Unify the numerous variables.
Added:
Modified:
llvm/include/llvm/MC/MCAsmInfo.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index cf31c36cc4cef8..fb49eb7645dfbd 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -98,6 +98,9 @@ class MCAsmInfo {
/// part of .global, .weak, .extern, and .comm. Default is false.
bool HasVisibilityOnlyWithLinkage = false;
+ // True if using the HLASM dialect on z/OS.
+ bool IsHLASM = false;
+
/// This is the maximum possible length of an instruction, which is needed to
/// compute the size of an inline asm. Defaults to 4.
unsigned MaxInstLength = 4;
@@ -110,14 +113,6 @@ class MCAsmInfo {
/// the current PC. Defaults to false.
bool DollarIsPC = false;
- /// Allow '.' token, when not referencing an identifier or constant, to refer
- /// to the current PC. Defaults to true.
- bool DotIsPC = true;
-
- /// Whether the '*' token refers to the current PC. This is used for the
- /// HLASM dialect.
- bool StarIsPC = false;
-
/// This string, if specified, is used to separate instructions from each
/// other when on the same line. Defaults to ';'
const char *SeparatorString;
@@ -126,10 +121,6 @@ class MCAsmInfo {
/// "#"
StringRef CommentString;
- /// This indicates whether the comment string is only accepted as a comment
- /// at the beginning of statements. Defaults to false.
- bool RestrictCommentStringToStartOfStatement = false;
-
/// This indicates whether to allow additional "comment strings" to be lexed
/// as a comment. Setting this attribute to true, will ensure that C-style
/// line comments (// ..), C-style block comments (/* .. */), and "#" are
@@ -138,16 +129,9 @@ class MCAsmInfo {
/// Default is true.
bool AllowAdditionalComments = true;
- /// Should we emit the '\t' as the starting indentation marker for GNU inline
- /// asm statements. Defaults to true.
- bool EmitGNUAsmStartIndentationMarker = true;
-
/// This is appended to emitted labels. Defaults to ":"
const char *LabelSuffix;
- /// Emit labels in purely upper case. Defaults to false.
- bool EmitLabelsInUpperCase = false;
-
// Print the EH begin symbol with an assignment. Defaults to false.
bool UseAssignmentForEHBegin = false;
@@ -209,13 +193,6 @@ class MCAsmInfo {
/// still be lexed as a comment.
bool AllowAtAtStartOfIdentifier = false;
- /// This is true if the assembler allows the "#" character at the start of
- /// a string to be lexed as an AsmToken::Identifier.
- /// If the AsmLexer determines that the string can be lexed as a possible
- /// comment, setting this option will have no effect, and the string will
- /// still be lexed as a comment.
- bool AllowHashAtStartOfIdentifier = false;
-
/// If this is true, symbol names with invalid characters will be printed in
/// quotes.
bool SupportsQuotedNames = true;
@@ -590,6 +567,7 @@ class MCAsmInfo {
// Accessors.
+ bool isHLASM() const { return IsHLASM; }
bool isMachO() const { return HasSubsectionsViaSymbols; }
bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
@@ -605,23 +583,14 @@ class MCAsmInfo {
unsigned getMinInstAlignment() const { return MinInstAlignment; }
bool getDollarIsPC() const { return DollarIsPC; }
- bool getDotIsPC() const { return DotIsPC; }
- bool getStarIsPC() const { return StarIsPC; }
const char *getSeparatorString() const { return SeparatorString; }
unsigned getCommentColumn() const { return CommentColumn; }
void setCommentColumn(unsigned Col) { CommentColumn = Col; }
StringRef getCommentString() const { return CommentString; }
- bool getRestrictCommentStringToStartOfStatement() const {
- return RestrictCommentStringToStartOfStatement;
- }
bool shouldAllowAdditionalComments() const { return AllowAdditionalComments; }
- bool getEmitGNUAsmStartIndentationMarker() const {
- return EmitGNUAsmStartIndentationMarker;
- }
const char *getLabelSuffix() const { return LabelSuffix; }
- bool shouldEmitLabelsInUpperCase() const { return EmitLabelsInUpperCase; }
bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
bool needsLocalForSize() const { return NeedsLocalForSize; }
@@ -655,9 +624,6 @@ class MCAsmInfo {
bool doesAllowDollarAtStartOfIdentifier() const {
return AllowDollarAtStartOfIdentifier;
}
- bool doesAllowHashAtStartOfIdentifier() const {
- return AllowHashAtStartOfIdentifier;
- }
bool supportsNameQuoting() const { return SupportsQuotedNames; }
bool doesSupportDataRegionDirectives() const {
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index ebae27e37b4fcb..59fc4cfc23e104 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -153,7 +153,7 @@ static void EmitInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
AsmPrinterVariant = MMI->getTarget().unqualifiedInlineAsmVariant();
// FIXME: Should this happen for `asm inteldialect` as well?
- if (!InputIsIntelDialect && MAI->getEmitGNUAsmStartIndentationMarker())
+ if (!InputIsIntelDialect && !MAI->isHLASM())
OS << '\t';
while (*LastEmitted) {
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index 778ca340e12489..32b6e869cc636e 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -707,7 +707,7 @@ size_t AsmLexer::peekTokens(MutableArrayRef<AsmToken> Buf,
}
bool AsmLexer::isAtStartOfComment(const char *Ptr) {
- if (MAI.getRestrictCommentStringToStartOfStatement() && !IsAtStartOfStatement)
+ if (MAI.isHLASM() && !IsAtStartOfStatement)
return false;
StringRef CommentString = MAI.getCommentString();
@@ -836,7 +836,7 @@ AsmToken AsmLexer::LexToken() {
return LexIdentifier();
return AsmToken(AsmToken::At, StringRef(TokStart, 1));
case '#':
- if (MAI.doesAllowHashAtStartOfIdentifier())
+ if (MAI.isHLASM())
return LexIdentifier();
return AsmToken(AsmToken::Hash, StringRef(TokStart, 1));
case '?':
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 153c1070a68c82..bf952df1b24180 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -1181,7 +1181,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
if (getTok().is(AsmToken::Dollar) || getTok().is(AsmToken::Star)) {
bool ShouldGenerateTempSymbol = false;
if ((getTok().is(AsmToken::Dollar) && MAI.getDollarIsPC()) ||
- (getTok().is(AsmToken::Star) && MAI.getStarIsPC()))
+ (getTok().is(AsmToken::Star) && MAI.isHLASM()))
ShouldGenerateTempSymbol = true;
if (!ShouldGenerateTempSymbol)
@@ -1248,8 +1248,8 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
MCSymbol *Sym = getContext().getInlineAsmLabel(SymbolName);
if (!Sym)
- Sym = getContext().getOrCreateSymbol(
- MAI.shouldEmitLabelsInUpperCase() ? SymbolName.upper() : SymbolName);
+ Sym = getContext().getOrCreateSymbol(MAI.isHLASM() ? SymbolName.upper()
+ : SymbolName);
// If this is an absolute variable reference, substitute it now to preserve
// semantics in the face of reassignment.
@@ -1312,7 +1312,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
return false;
}
case AsmToken::Dot: {
- if (!MAI.getDotIsPC())
+ if (MAI.isHLASM())
return TokError("cannot use . as current PC");
// This is a '.' reference, which references the current PC. Emit a
@@ -6322,9 +6322,7 @@ bool HLASMAsmParser::parseAsHLASMLabel(ParseStatementInfo &Info,
"Cannot have just a label for an HLASM inline asm statement");
MCSymbol *Sym = getContext().getOrCreateSymbol(
- getContext().getAsmInfo()->shouldEmitLabelsInUpperCase()
- ? LabelVal.upper()
- : LabelVal);
+ getContext().getAsmInfo()->isHLASM() ? LabelVal.upper() : LabelVal);
getTargetParser().doBeforeLabelEmit(Sym, LabelLoc);
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
index 06d7d422e647e6..16e7d05b8fb733 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp
@@ -29,19 +29,14 @@ SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT) {
AllowAtInName = true;
AllowAtAtStartOfIdentifier = true;
AllowDollarAtStartOfIdentifier = true;
- AllowHashAtStartOfIdentifier = true;
AssemblerDialect = AD_HLASM;
CalleeSaveStackSlotSize = 8;
CodePointerSize = 8;
CommentString = "*";
- DotIsPC = false;
- EmitGNUAsmStartIndentationMarker = false;
- EmitLabelsInUpperCase = true;
ExceptionsType = ExceptionHandling::ZOS;
+ IsHLASM = true;
IsLittleEndian = false;
MaxInstLength = 6;
- RestrictCommentStringToStartOfStatement = true;
- StarIsPC = true;
SupportsDebugInformation = true;
}
More information about the llvm-commits
mailing list