Skip to content

Commit 25bb659

Browse files
committed
MCAsmInfo: replace AIX-specific variables with IsAIX
AIX assembly is very different from the gas syntax. We don't expect other targets to share these differences. Unify the numerous, essentially AIX-specific variables.
1 parent 5d81b14 commit 25bb659

File tree

5 files changed

+48
-146
lines changed

5 files changed

+48
-146
lines changed

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ class MCAsmInfo {
9494
/// constants into comdat sections.
9595
bool HasCOFFComdatConstants = false;
9696

97-
/// True if this is an XCOFF target that supports visibility attributes as
98-
/// part of .global, .weak, .extern, and .comm. Default is false.
99-
bool HasVisibilityOnlyWithLinkage = false;
97+
bool IsAIX = false;
10098

10199
// True if using the HLASM dialect on z/OS.
102100
bool IsHLASM = false;
@@ -202,10 +200,6 @@ class MCAsmInfo {
202200
/// instead.
203201
bool UseDataRegionDirectives = false;
204202

205-
/// True if .align is to be used for alignment. Only power-of-two
206-
/// alignment is supported.
207-
bool UseDotAlignForAlignment = false;
208-
209203
/// True if the target supports LEB128 directives.
210204
bool HasLEB128Directives = true;
211205

@@ -220,11 +214,6 @@ class MCAsmInfo {
220214
/// "\t.zero\t"
221215
const char *ZeroDirective;
222216

223-
/// This should be set to true if the zero directive supports a value to emit
224-
/// other than zero. If this is set to false, the Data*bitsDirective's will be
225-
/// used to emit these bytes. Defaults to true.
226-
bool ZeroDirectiveSupportsNonZeroValue = true;
227-
228217
/// This directive allows emission of an ascii string with the standard C
229218
/// escape characters embedded into it. If a target doesn't support this, it
230219
/// can be set to null. Defaults to "\t.ascii\t"
@@ -235,16 +224,6 @@ class MCAsmInfo {
235224
/// doesn't support this, it can be set to null. Defaults to "\t.asciz\t"
236225
const char *AscizDirective;
237226

238-
/// This directive accepts a comma-separated list of bytes for emission as a
239-
/// string of bytes. For targets that do not support this, it shall be set to
240-
/// null. Defaults to null.
241-
const char *ByteListDirective = nullptr;
242-
243-
/// This directive allows emission of a zero-terminated ascii string without
244-
/// the standard C escape characters embedded into it. If a target doesn't
245-
/// support this, it can be set to null. Defaults to null.
246-
const char *PlainStringDirective = nullptr;
247-
248227
/// Form used for character literals in the assembly syntax. Useful for
249228
/// producing strings as byte lists. If a target does not use or support
250229
/// this, it shall be set to ACLS_Unknown. Defaults to ACLS_Unknown.
@@ -325,16 +304,6 @@ class MCAsmInfo {
325304
/// argument and how it is interpreted. Defaults to NoAlignment.
326305
LCOMM::LCOMMType LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
327306

328-
/// True if the target only has basename for .file directive. False if the
329-
/// target also needs the directory along with the basename. Defaults to true.
330-
bool HasBasenameOnlyForFileDirective = true;
331-
332-
/// True if the target represents string constants as mostly raw characters in
333-
/// paired double quotation with paired double quotation marks as the escape
334-
/// mechanism to represent a double quotation mark within the string. Defaults
335-
/// to false.
336-
bool HasPairedDoubleQuoteStringConstants = false;
337-
338307
// True if the target allows .align directives on functions. This is true for
339308
// most targets, so defaults to true.
340309
bool HasFunctionAlignment = true;
@@ -347,10 +316,6 @@ class MCAsmInfo {
347316
/// for ELF targets. Defaults to true.
348317
bool HasSingleParameterDotFile = true;
349318

350-
/// True if the target has a four strings .file directive, strings separated
351-
/// by comma. Defaults to false.
352-
bool HasFourStringsDotFile = false;
353-
354319
/// True if the target has a .ident directive, this is true for ELF targets.
355320
/// Defaults to false.
356321
bool HasIdentDirective = false;
@@ -417,10 +382,6 @@ class MCAsmInfo {
417382
/// absolute difference.
418383
bool DwarfFDESymbolsUseAbsDiff = false;
419384

420-
/// True if the target supports generating the DWARF line table through using
421-
/// the .loc/.file directives. Defaults to true.
422-
bool UsesDwarfFileAndLocDirectives = true;
423-
424385
/// True if DWARF `.file directory' directive syntax is used by
425386
/// default.
426387
bool EnableDwarfFileDirectoryDefault = true;
@@ -484,9 +445,6 @@ class MCAsmInfo {
484445
// If true, use Motorola-style integers in Assembly (ex. $0ac).
485446
bool UseMotorolaIntegers = false;
486447

487-
// If true, emit function descriptor symbol on AIX.
488-
bool NeedsFunctionDescriptors = false;
489-
490448
public:
491449
explicit MCAsmInfo();
492450
virtual ~MCAsmInfo();
@@ -567,13 +525,11 @@ class MCAsmInfo {
567525

568526
// Accessors.
569527

528+
bool isAIX() const { return IsAIX; }
570529
bool isHLASM() const { return IsHLASM; }
571530
bool isMachO() const { return HasSubsectionsViaSymbols; }
572531
bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
573532
bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
574-
bool hasVisibilityOnlyWithLinkage() const {
575-
return HasVisibilityOnlyWithLinkage;
576-
}
577533

578534
/// Returns the maximum possible encoded instruction size in bytes. If \p STI
579535
/// is null, this should be the maximum size for any subtarget.
@@ -630,23 +586,14 @@ class MCAsmInfo {
630586
return UseDataRegionDirectives;
631587
}
632588

633-
bool useDotAlignForAlignment() const {
634-
return UseDotAlignForAlignment;
635-
}
636-
637589
bool hasLEB128Directives() const { return HasLEB128Directives; }
638590

639591
bool useFullRegisterNames() const { return PPCUseFullRegisterNames; }
640592
void setFullRegisterNames(bool V) { PPCUseFullRegisterNames = V; }
641593

642594
const char *getZeroDirective() const { return ZeroDirective; }
643-
bool doesZeroDirectiveSupportNonZeroValue() const {
644-
return ZeroDirectiveSupportsNonZeroValue;
645-
}
646595
const char *getAsciiDirective() const { return AsciiDirective; }
647596
const char *getAscizDirective() const { return AscizDirective; }
648-
const char *getByteListDirective() const { return ByteListDirective; }
649-
const char *getPlainStringDirective() const { return PlainStringDirective; }
650597
AsmCharLiteralSyntax characterLiteralSyntax() const {
651598
return CharacterLiteralSyntax;
652599
}
@@ -666,16 +613,9 @@ class MCAsmInfo {
666613
return LCOMMDirectiveAlignmentType;
667614
}
668615

669-
bool hasBasenameOnlyForFileDirective() const {
670-
return HasBasenameOnlyForFileDirective;
671-
}
672-
bool hasPairedDoubleQuoteStringConstants() const {
673-
return HasPairedDoubleQuoteStringConstants;
674-
}
675616
bool hasFunctionAlignment() const { return HasFunctionAlignment; }
676617
bool hasDotTypeDotSizeDirective() const { return HasDotTypeDotSizeDirective; }
677618
bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; }
678-
bool hasFourStringsDotFile() const { return HasFourStringsDotFile; }
679619
bool hasIdentDirective() const { return HasIdentDirective; }
680620
bool hasNoDeadStrip() const { return HasNoDeadStrip; }
681621
const char *getWeakDirective() const { return WeakDirective; }
@@ -742,13 +682,7 @@ class MCAsmInfo {
742682
return SupportsExtendedDwarfLocDirective;
743683
}
744684

745-
bool usesDwarfFileAndLocDirectives() const {
746-
return UsesDwarfFileAndLocDirectives;
747-
}
748-
749-
bool needsDwarfSectionSizeInHeader() const {
750-
return DwarfSectionSizeRequired;
751-
}
685+
bool usesDwarfFileAndLocDirectives() const { return !IsAIX; }
752686

753687
bool enableDwarfFileDirectoryDefault() const {
754688
return EnableDwarfFileDirectoryDefault;
@@ -798,7 +732,6 @@ class MCAsmInfo {
798732
bool shouldUseLogicalShr() const { return UseLogicalShr; }
799733

800734
bool hasMipsExpressions() const { return HasMipsExpressions; }
801-
bool needsFunctionDescriptors() const { return NeedsFunctionDescriptors; }
802735
bool shouldUseMotorolaIntegers() const { return UseMotorolaIntegers; }
803736
};
804737

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,7 @@ bool AsmPrinter::doInitialization(Module &M) {
503503
// don't, this at least helps the user find where a global came from.
504504
if (MAI->hasSingleParameterDotFile()) {
505505
// .file "foo.c"
506-
507-
SmallString<128> FileName;
508-
if (MAI->hasBasenameOnlyForFileDirective())
509-
FileName = llvm::sys::path::filename(M.getSourceFileName());
510-
else
511-
FileName = M.getSourceFileName();
512-
if (MAI->hasFourStringsDotFile()) {
506+
if (MAI->isAIX()) {
513507
const char VerStr[] =
514508
#ifdef PACKAGE_VENDOR
515509
PACKAGE_VENDOR " "
@@ -520,9 +514,10 @@ bool AsmPrinter::doInitialization(Module &M) {
520514
#endif
521515
;
522516
// TODO: Add timestamp and description.
523-
OutStreamer->emitFileDirective(FileName, VerStr, "", "");
517+
OutStreamer->emitFileDirective(M.getSourceFileName(), VerStr, "", "");
524518
} else {
525-
OutStreamer->emitFileDirective(FileName);
519+
OutStreamer->emitFileDirective(
520+
llvm::sys::path::filename(M.getSourceFileName()));
526521
}
527522
}
528523

@@ -967,11 +962,10 @@ void AsmPrinter::emitFunctionHeader() {
967962
MF->setSection(getObjFileLowering().SectionForGlobal(&F, TM));
968963
OutStreamer->switchSection(MF->getSection());
969964

970-
if (!MAI->hasVisibilityOnlyWithLinkage())
971-
emitVisibility(CurrentFnSym, F.getVisibility());
972-
973-
if (MAI->needsFunctionDescriptors())
965+
if (MAI->isAIX())
974966
emitLinkage(&F, CurrentFnDescSym);
967+
else
968+
emitVisibility(CurrentFnSym, F.getVisibility());
975969

976970
emitLinkage(&F, CurrentFnSym);
977971
if (MAI->hasFunctionAlignment())
@@ -1031,7 +1025,7 @@ void AsmPrinter::emitFunctionHeader() {
10311025
// to emit their specific function descriptor. Right now it is only used by
10321026
// the AIX target. The PowerPC 64-bit V1 ELF target also uses function
10331027
// descriptors and should be converted to use this hook as well.
1034-
if (MAI->needsFunctionDescriptors())
1028+
if (MAI->isAIX())
10351029
emitFunctionDescriptor();
10361030

10371031
// Emit the CurrentFnSym. This is a virtual function to allow targets to do
@@ -2234,9 +2228,6 @@ void AsmPrinter::emitGlobalAlias(const Module &M, const GlobalAlias &GA) {
22342228
// point, all the extra label is emitted, we just have to emit linkage for
22352229
// those labels.
22362230
if (TM.getTargetTriple().isOSBinFormatXCOFF()) {
2237-
assert(MAI->hasVisibilityOnlyWithLinkage() &&
2238-
"Visibility should be handled with emitLinkage() on AIX.");
2239-
22402231
// Linkage for alias of global variable has been emitted.
22412232
if (isa<GlobalVariable>(GA.getAliaseeObject()))
22422233
return;
@@ -2730,7 +2721,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
27302721
HasNoSplitStack = true;
27312722

27322723
// Get the function symbol.
2733-
if (!MAI->needsFunctionDescriptors()) {
2724+
if (!MAI->isAIX()) {
27342725
CurrentFnSym = getSymbol(&MF.getFunction());
27352726
} else {
27362727
assert(TM.getTargetTriple().isOSAIX() &&

llvm/lib/MC/MCAsmInfoXCOFF.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,17 @@ extern cl::opt<cl::boolOrDefault> UseLEB128Directives;
1919
void MCAsmInfoXCOFF::anchor() {}
2020

2121
MCAsmInfoXCOFF::MCAsmInfoXCOFF() {
22+
IsAIX = true;
2223
IsLittleEndian = false;
23-
HasVisibilityOnlyWithLinkage = true;
24-
HasBasenameOnlyForFileDirective = false;
25-
HasFourStringsDotFile = true;
26-
27-
// For XCOFF, string constant consists of any number of characters enclosed in
28-
// "" (double quotation marks).
29-
HasPairedDoubleQuoteStringConstants = true;
3024

3125
PrivateGlobalPrefix = "L..";
3226
PrivateLabelPrefix = "L..";
3327
SupportsQuotedNames = false;
34-
UseDotAlignForAlignment = true;
35-
UsesDwarfFileAndLocDirectives = false;
36-
DwarfSectionSizeRequired = false;
3728
if (UseLEB128Directives == cl::BOU_UNSET)
3829
HasLEB128Directives = false;
3930
ZeroDirective = "\t.space\t";
40-
ZeroDirectiveSupportsNonZeroValue = false;
4131
AsciiDirective = nullptr; // not supported
4232
AscizDirective = nullptr; // not supported
43-
ByteListDirective = "\t.byte\t";
44-
PlainStringDirective = "\t.string\t";
4533
CharacterLiteralSyntax = ACLS_SingleQuotePrefix;
4634

4735
// Use .vbyte for data definition to avoid directives that apply an implicit
@@ -53,7 +41,6 @@ MCAsmInfoXCOFF::MCAsmInfoXCOFF() {
5341
LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
5442
HasDotTypeDotSizeDirective = false;
5543
ParseInlineAsmUsingAsmParser = true;
56-
NeedsFunctionDescriptors = true;
5744

5845
ExceptionsType = ExceptionHandling::AIX;
5946
}

0 commit comments

Comments
 (0)