Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 6 additions & 2 deletions llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7152,9 +7152,9 @@ static SMLoc incrementLoc(SMLoc L, int Offset) {
bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
SMLoc CurLoc = getLoc();

StringRef Name = getParser().parseStringToEndOfStatement().trim();
StringRef Arch, ExtensionString;
std::tie(Arch, ExtensionString) =
getParser().parseStringToEndOfStatement().trim().split('+');
std::tie(Arch, ExtensionString) = Name.split('+');

const AArch64::ArchInfo *ArchInfo = AArch64::parseArch(Arch);
if (!ArchInfo)
Expand Down Expand Up @@ -7201,6 +7201,8 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
}
FeatureBitset Features = ComputeAvailableFeatures(STI.getFeatureBits());
setAvailableFeatures(Features);

getTargetStreamer().emitDirectiveArch(Name);
return false;
}

Expand Down Expand Up @@ -7234,6 +7236,8 @@ bool AArch64AsmParser::parseDirectiveArchExtension(SMLoc L) {
STI.ClearFeatureBitsTransitively(It->Features);
FeatureBitset Features = ComputeAvailableFeatures(STI.getFeatureBits());
setAvailableFeatures(Features);

getTargetStreamer().emitDirectiveArchExtension(Name);
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong, as Name might have been updated on (new) line 7222. This would be clear with a .arch_extension nolse test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for catching that. I have updated the code so that it emits the full name from before the no prefix is stripped, along with a test. Let me know if you'd like further changes.

return false;
}

Expand Down
8 changes: 8 additions & 0 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
OS << "\t.variant_pcs\t" << Symbol->getName() << "\n";
}

void emitDirectiveArch(StringRef Name) override {
OS << "\t.arch\t" << Name << "\n";
}

void emitDirectiveArchExtension(StringRef Name) override {
OS << "\t.arch_extension\t" << Name << "\n";
}

void emitARM64WinCFIAllocStack(unsigned Size) override {
OS << "\t.seh_stackalloc\t" << Size << "\n";
}
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class AArch64TargetStreamer : public MCTargetStreamer {
/// Callback used to implement the .variant_pcs directive.
virtual void emitDirectiveVariantPCS(MCSymbol *Symbol) {};

virtual void emitDirectiveArch(StringRef Name) {};
virtual void emitDirectiveArchExtension(StringRef Name) {};

virtual void emitARM64WinCFIAllocStack(unsigned Size) {}
virtual void emitARM64WinCFISaveR19R20X(int Offset) {}
virtual void emitARM64WinCFISaveFPLR(int Offset) {}
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/MC/AArch64/arch_directive.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# RUN: llvm-mc -assemble -triple=aarch64- %s | FileCheck %s
# CHECK: .text
# CHECK-NEXT: .arch armv8-a+lse
# CHECK-NEXT: cas x0, x1, [x2]
# CHECK-NEXT: .arch armv8-a
# CHECK-NEXT: .arch_extension lse
# CHECK-NEXT: cas x0, x1, [x2]
.text
.arch armv8-a+lse
cas x0, x1, [x2]
.arch armv8-a
.arch_extension lse
cas x0, x1, [x2]
Loading