Skip to content

Commit 56600c1

Browse files
committed
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.
1 parent ac1d560 commit 56600c1

File tree

5 files changed

+13
-54
lines changed

5 files changed

+13
-54
lines changed

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ class MCAsmInfo {
9898
/// part of .global, .weak, .extern, and .comm. Default is false.
9999
bool HasVisibilityOnlyWithLinkage = false;
100100

101+
// True if using the HLASM dialect on z/OS.
102+
bool IsHLASM = false;
103+
101104
/// This is the maximum possible length of an instruction, which is needed to
102105
/// compute the size of an inline asm. Defaults to 4.
103106
unsigned MaxInstLength = 4;
@@ -110,14 +113,6 @@ class MCAsmInfo {
110113
/// the current PC. Defaults to false.
111114
bool DollarIsPC = false;
112115

113-
/// Allow '.' token, when not referencing an identifier or constant, to refer
114-
/// to the current PC. Defaults to true.
115-
bool DotIsPC = true;
116-
117-
/// Whether the '*' token refers to the current PC. This is used for the
118-
/// HLASM dialect.
119-
bool StarIsPC = false;
120-
121116
/// This string, if specified, is used to separate instructions from each
122117
/// other when on the same line. Defaults to ';'
123118
const char *SeparatorString;
@@ -126,10 +121,6 @@ class MCAsmInfo {
126121
/// "#"
127122
StringRef CommentString;
128123

129-
/// This indicates whether the comment string is only accepted as a comment
130-
/// at the beginning of statements. Defaults to false.
131-
bool RestrictCommentStringToStartOfStatement = false;
132-
133124
/// This indicates whether to allow additional "comment strings" to be lexed
134125
/// as a comment. Setting this attribute to true, will ensure that C-style
135126
/// line comments (// ..), C-style block comments (/* .. */), and "#" are
@@ -138,16 +129,9 @@ class MCAsmInfo {
138129
/// Default is true.
139130
bool AllowAdditionalComments = true;
140131

141-
/// Should we emit the '\t' as the starting indentation marker for GNU inline
142-
/// asm statements. Defaults to true.
143-
bool EmitGNUAsmStartIndentationMarker = true;
144-
145132
/// This is appended to emitted labels. Defaults to ":"
146133
const char *LabelSuffix;
147134

148-
/// Emit labels in purely upper case. Defaults to false.
149-
bool EmitLabelsInUpperCase = false;
150-
151135
// Print the EH begin symbol with an assignment. Defaults to false.
152136
bool UseAssignmentForEHBegin = false;
153137

@@ -209,13 +193,6 @@ class MCAsmInfo {
209193
/// still be lexed as a comment.
210194
bool AllowAtAtStartOfIdentifier = false;
211195

212-
/// This is true if the assembler allows the "#" character at the start of
213-
/// a string to be lexed as an AsmToken::Identifier.
214-
/// If the AsmLexer determines that the string can be lexed as a possible
215-
/// comment, setting this option will have no effect, and the string will
216-
/// still be lexed as a comment.
217-
bool AllowHashAtStartOfIdentifier = false;
218-
219196
/// If this is true, symbol names with invalid characters will be printed in
220197
/// quotes.
221198
bool SupportsQuotedNames = true;
@@ -590,6 +567,7 @@ class MCAsmInfo {
590567

591568
// Accessors.
592569

570+
bool isHLASM() const { return IsHLASM; }
593571
bool isMachO() const { return HasSubsectionsViaSymbols; }
594572
bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
595573
bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
@@ -605,23 +583,14 @@ class MCAsmInfo {
605583

606584
unsigned getMinInstAlignment() const { return MinInstAlignment; }
607585
bool getDollarIsPC() const { return DollarIsPC; }
608-
bool getDotIsPC() const { return DotIsPC; }
609-
bool getStarIsPC() const { return StarIsPC; }
610586
const char *getSeparatorString() const { return SeparatorString; }
611587

612588
unsigned getCommentColumn() const { return CommentColumn; }
613589
void setCommentColumn(unsigned Col) { CommentColumn = Col; }
614590

615591
StringRef getCommentString() const { return CommentString; }
616-
bool getRestrictCommentStringToStartOfStatement() const {
617-
return RestrictCommentStringToStartOfStatement;
618-
}
619592
bool shouldAllowAdditionalComments() const { return AllowAdditionalComments; }
620-
bool getEmitGNUAsmStartIndentationMarker() const {
621-
return EmitGNUAsmStartIndentationMarker;
622-
}
623593
const char *getLabelSuffix() const { return LabelSuffix; }
624-
bool shouldEmitLabelsInUpperCase() const { return EmitLabelsInUpperCase; }
625594

626595
bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
627596
bool needsLocalForSize() const { return NeedsLocalForSize; }
@@ -655,9 +624,6 @@ class MCAsmInfo {
655624
bool doesAllowDollarAtStartOfIdentifier() const {
656625
return AllowDollarAtStartOfIdentifier;
657626
}
658-
bool doesAllowHashAtStartOfIdentifier() const {
659-
return AllowHashAtStartOfIdentifier;
660-
}
661627
bool supportsNameQuoting() const { return SupportsQuotedNames; }
662628

663629
bool doesSupportDataRegionDirectives() const {

llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void EmitInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
153153
AsmPrinterVariant = MMI->getTarget().unqualifiedInlineAsmVariant();
154154

155155
// FIXME: Should this happen for `asm inteldialect` as well?
156-
if (!InputIsIntelDialect && MAI->getEmitGNUAsmStartIndentationMarker())
156+
if (!InputIsIntelDialect && !MAI->isHLASM())
157157
OS << '\t';
158158

159159
while (*LastEmitted) {

llvm/lib/MC/MCParser/AsmLexer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ size_t AsmLexer::peekTokens(MutableArrayRef<AsmToken> Buf,
707707
}
708708

709709
bool AsmLexer::isAtStartOfComment(const char *Ptr) {
710-
if (MAI.getRestrictCommentStringToStartOfStatement() && !IsAtStartOfStatement)
710+
if (MAI.isHLASM() && !IsAtStartOfStatement)
711711
return false;
712712

713713
StringRef CommentString = MAI.getCommentString();
@@ -836,7 +836,7 @@ AsmToken AsmLexer::LexToken() {
836836
return LexIdentifier();
837837
return AsmToken(AsmToken::At, StringRef(TokStart, 1));
838838
case '#':
839-
if (MAI.doesAllowHashAtStartOfIdentifier())
839+
if (MAI.isHLASM())
840840
return LexIdentifier();
841841
return AsmToken(AsmToken::Hash, StringRef(TokStart, 1));
842842
case '?':

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
11811181
if (getTok().is(AsmToken::Dollar) || getTok().is(AsmToken::Star)) {
11821182
bool ShouldGenerateTempSymbol = false;
11831183
if ((getTok().is(AsmToken::Dollar) && MAI.getDollarIsPC()) ||
1184-
(getTok().is(AsmToken::Star) && MAI.getStarIsPC()))
1184+
(getTok().is(AsmToken::Star) && MAI.isHLASM()))
11851185
ShouldGenerateTempSymbol = true;
11861186

11871187
if (!ShouldGenerateTempSymbol)
@@ -1248,8 +1248,8 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
12481248

12491249
MCSymbol *Sym = getContext().getInlineAsmLabel(SymbolName);
12501250
if (!Sym)
1251-
Sym = getContext().getOrCreateSymbol(
1252-
MAI.shouldEmitLabelsInUpperCase() ? SymbolName.upper() : SymbolName);
1251+
Sym = getContext().getOrCreateSymbol(MAI.isHLASM() ? SymbolName.upper()
1252+
: SymbolName);
12531253

12541254
// If this is an absolute variable reference, substitute it now to preserve
12551255
// semantics in the face of reassignment.
@@ -1312,7 +1312,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc,
13121312
return false;
13131313
}
13141314
case AsmToken::Dot: {
1315-
if (!MAI.getDotIsPC())
1315+
if (MAI.isHLASM())
13161316
return TokError("cannot use . as current PC");
13171317

13181318
// This is a '.' reference, which references the current PC. Emit a
@@ -6322,9 +6322,7 @@ bool HLASMAsmParser::parseAsHLASMLabel(ParseStatementInfo &Info,
63226322
"Cannot have just a label for an HLASM inline asm statement");
63236323

63246324
MCSymbol *Sym = getContext().getOrCreateSymbol(
6325-
getContext().getAsmInfo()->shouldEmitLabelsInUpperCase()
6326-
? LabelVal.upper()
6327-
: LabelVal);
6325+
getContext().getAsmInfo()->isHLASM() ? LabelVal.upper() : LabelVal);
63286326

63296327
getTargetParser().doBeforeLabelEmit(Sym, LabelLoc);
63306328

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,14 @@ SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT) {
2929
AllowAtInName = true;
3030
AllowAtAtStartOfIdentifier = true;
3131
AllowDollarAtStartOfIdentifier = true;
32-
AllowHashAtStartOfIdentifier = true;
3332
AssemblerDialect = AD_HLASM;
3433
CalleeSaveStackSlotSize = 8;
3534
CodePointerSize = 8;
3635
CommentString = "*";
37-
DotIsPC = false;
38-
EmitGNUAsmStartIndentationMarker = false;
39-
EmitLabelsInUpperCase = true;
4036
ExceptionsType = ExceptionHandling::ZOS;
37+
IsHLASM = true;
4138
IsLittleEndian = false;
4239
MaxInstLength = 6;
43-
RestrictCommentStringToStartOfStatement = true;
44-
StarIsPC = true;
4540
SupportsDebugInformation = true;
4641
}
4742

0 commit comments

Comments
 (0)