Skip to content

Commit

Permalink
AArch64 .arch directive - Include default arch attributes with extens…
Browse files Browse the repository at this point in the history
…ions.

Fix the .arch asm parser to use the full set of features for the architecture
and any extensions on the command line. Add and update testcases accordingly
as well as add an extension that was used but not supported.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280971 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
echristo committed Sep 8, 2016
1 parent d764af3 commit a50ca9f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 18 deletions.
42 changes: 39 additions & 3 deletions lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCContext.h"
Expand All @@ -28,6 +29,7 @@
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetParser.h"
Expand Down Expand Up @@ -4193,6 +4195,7 @@ static const struct {
{ "crypto", {AArch64::FeatureCrypto} },
{ "fp", {AArch64::FeatureFPARMv8} },
{ "simd", {AArch64::FeatureNEON} },
{ "ras", {AArch64::FeatureRAS} },

// FIXME: Unsupported extensions
{ "lse", {} },
Expand All @@ -4217,12 +4220,45 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
return false;
}

// Get the architecture and extension features.
std::vector<const char *> AArch64Features;
AArch64::getArchFeatures(ID, AArch64Features);
AArch64::getExtensionFeatures(AArch64::getDefaultExtensions("generic", ID),
AArch64Features);

MCSubtargetInfo &STI = copySTI();
STI.setDefaultFeatures("", "");
std::vector<std::string> ArchFeatures(AArch64Features.begin(), AArch64Features.end());
STI.setDefaultFeatures("generic", join(ArchFeatures.begin(), ArchFeatures.end(), ","));

SmallVector<StringRef, 4> RequestedExtensions;
if (!ExtensionString.empty())
STI.setDefaultFeatures("", ("+" + ExtensionString).str());
setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
ExtensionString.split(RequestedExtensions, '+');

FeatureBitset Features = STI.getFeatureBits();
for (auto Name : RequestedExtensions) {
bool EnableFeature = true;

if (Name.startswith_lower("no")) {
EnableFeature = false;
Name = Name.substr(2);
}

for (const auto &Extension : ExtensionMap) {
if (Extension.Name != Name)
continue;

if (Extension.Features.none())
report_fatal_error("unsupported architectural extension: " + Name);

FeatureBitset ToggleFeatures = EnableFeature
? (~Features & Extension.Features)
: ( Features & Extension.Features);
uint64_t Features =
ComputeAvailableFeatures(STI.ToggleFeature(ToggleFeatures));
setAvailableFeatures(Features);
break;
}
}
return false;
}

Expand Down
27 changes: 12 additions & 15 deletions test/MC/AArch64/directive-arch-negative.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@
# CHECK: ^

.arch armv8
aese v0.8h, v1.8h

fminnm d0, d0, d1

# CHECK: error: instruction requires: fp-armv8
# CHECK: fminnm d0, d0, d1
# CHECK: error: invalid operand for instruction
# CHECK: aese v0.8h, v1.8h
# CHECK: ^

.arch armv8+fp

# CHECK: '+fp' is not a recognized feature for this target (ignoring feature)

fminnm d0, d0, d1
// We silently ignore invalid features.
.arch armv8+foo
aese v0.8h, v1.8h

# CHECK: error: instruction requires: fp-armv8
# CHECK: fminnm d0, d0, d1
# CHECK: error: invalid operand for instruction
# CHECK: aese v0.8h, v1.8h
# CHECK: ^

.arch armv8+neon
.arch armv8+crypto

.arch armv8

fminnm d0, d0, d1
aese v0.8h, v1.8h

# CHECK: error: instruction requires: fp-armv8
# CHECK: fminnm d0, d0, d1
# CHECK: error: invalid operand for instruction
# CHECK: aese v0.8h, v1.8h
# CHECK: ^

2 changes: 2 additions & 0 deletions test/MC/AArch64/directive-arch.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
.arch armv8-a+crypto

aesd v0.16b, v2.16b
eor v0.16b, v0.16b, v2.16b

# CHECK: aesd v0.16b, v2.16b
# CHECK: eor v0.16b, v0.16b, v2.16b

.arch armv8.1-a+ras
esb
Expand Down

0 comments on commit a50ca9f

Please sign in to comment.