16 changes: 10 additions & 6 deletions llvm/lib/Target/ARM64/ARM64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,20 @@ class ARM64TTI final : public ImmutablePass, public TargetTransformInfo {
/// @{

unsigned getNumberOfRegisters(bool Vector) const override {
if (Vector)
return 32;

if (Vector) {
if (ST->hasNEON())
return 32;
return 0;
}
return 31;
}

unsigned getRegisterBitWidth(bool Vector) const override {
if (Vector)
return 128;

if (Vector) {
if (ST->hasNEON())
return 128;
return 0;
}
return 64;
}

Expand Down
22 changes: 21 additions & 1 deletion llvm/lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class ARM64AsmParser : public MCTargetAsmParser {
const MCInstrInfo &MII)
: MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
MCAsmParserExtension::Initialize(_Parser);

// Initialize the set of available features.
setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
}

virtual bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
Expand Down Expand Up @@ -3815,6 +3818,8 @@ bool ARM64AsmParser::showMatchError(SMLoc Loc, unsigned ErrCode) {
}
}

static const char *getSubtargetFeatureName(unsigned Val);

bool ARM64AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
OperandVector &Operands,
MCStreamer &Out,
Expand Down Expand Up @@ -4247,7 +4252,21 @@ bool ARM64AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
Out.EmitInstruction(Inst, STI);
return false;
}
case Match_MissingFeature:
case Match_MissingFeature: {
assert(ErrorInfo && "Unknown missing feature!");
// Special case the error message for the very common case where only
// a single subtarget feature is missing (neon, e.g.).
std::string Msg = "instruction requires:";
unsigned Mask = 1;
for (unsigned i = 0; i < (sizeof(ErrorInfo)*8-1); ++i) {
if (ErrorInfo & Mask) {
Msg += " ";
Msg += getSubtargetFeatureName(ErrorInfo & Mask);
}
Mask <<= 1;
}
return Error(IDLoc, Msg);
}
case Match_MnemonicFail:
return showMatchError(IDLoc, MatchResult);
case Match_InvalidOperand: {
Expand Down Expand Up @@ -4494,6 +4513,7 @@ extern "C" void LLVMInitializeARM64AsmParser() {
}

#define GET_REGISTER_MATCHER
#define GET_SUBTARGET_FEATURE_NAME
#define GET_MATCHER_IMPLEMENTATION
#include "ARM64GenAsmMatcher.inc"

Expand Down
21 changes: 21 additions & 0 deletions llvm/test/CodeGen/ARM64/complex-copy-noneon.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; RUN: llc -mtriple=arm64-none-linux-gnu -mattr=-neon < %s

; The DAG combiner decided to use a vector load/store for this struct copy
; previously. This probably shouldn't happen without NEON, but the most
; important thing is that it compiles.

define void @store_combine() nounwind {
%src = alloca { double, double }, align 8
%dst = alloca { double, double }, align 8

%src.realp = getelementptr inbounds { double, double }* %src, i32 0, i32 0
%src.real = load double* %src.realp
%src.imagp = getelementptr inbounds { double, double }* %src, i32 0, i32 1
%src.imag = load double* %src.imagp

%dst.realp = getelementptr inbounds { double, double }* %dst, i32 0, i32 0
%dst.imagp = getelementptr inbounds { double, double }* %dst, i32 0, i32 1
store double %src.real, double* %dst.realp
store double %src.imag, double* %dst.imagp
ret void
}
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM64/crypto.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llc -march=arm64 -arm64-neon-syntax=apple -o - %s | FileCheck %s
; RUN: llc -march=arm64 -mattr=crypto -arm64-neon-syntax=apple -o - %s | FileCheck %s

declare <16 x i8> @llvm.arm64.crypto.aese(<16 x i8> %data, <16 x i8> %key)
declare <16 x i8> @llvm.arm64.crypto.aesd(<16 x i8> %data, <16 x i8> %key)
Expand Down
20 changes: 20 additions & 0 deletions llvm/test/CodeGen/ARM64/reg-copy-noneon.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: llc -mtriple=arm64-none-linux-gnu -mattr=-neon < %s | FileCheck %s

define float @copy_FPR32(float %a, float %b) {
;CHECK-LABEL: copy_FPR32:
;CHECK: fmov s0, s1
ret float %b;
}

define double @copy_FPR64(double %a, double %b) {
;CHECK-LABEL: copy_FPR64:
;CHECK: fmov d0, d1
ret double %b;
}

define fp128 @copy_FPR128(fp128 %a, fp128 %b) {
;CHECK-LABEL: copy_FPR128:
;CHECK: str q1, [sp, #-16]!
;CHECK-NEXT: ldr q0, [sp, #16]!
ret fp128 %b;
}
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/advsimd.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llvm-mc -triple arm64-apple-darwin -output-asm-variant=1 -show-encoding < %s | FileCheck %s
; RUN: llvm-mc -triple arm64-apple-darwin -mattr=crypto -output-asm-variant=1 -show-encoding < %s | FileCheck %s

foo:

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/aliases.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llvm-mc -triple arm64-apple-darwin -output-asm-variant=1 -show-encoding < %s | FileCheck %s
; RUN: llvm-mc -triple arm64-apple-darwin -mattr=neon -output-asm-variant=1 -show-encoding < %s | FileCheck %s

foo:
;-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/arithmetic-encoding.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llvm-mc -triple arm64-apple-darwin -show-encoding < %s | FileCheck %s
; RUN: llvm-mc -triple arm64-apple-darwin -mattr=neon -show-encoding < %s | FileCheck %s

foo:
;==---------------------------------------------------------------------------==
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/crypto.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llvm-mc -triple arm64-apple-darwin -show-encoding -output-asm-variant=1 < %s | FileCheck %s
; RUN: llvm-mc -triple arm64-apple-darwin -mattr=crypto -show-encoding -output-asm-variant=1 < %s | FileCheck %s

foo:
aese.16b v0, v1
Expand Down
19 changes: 19 additions & 0 deletions llvm/test/MC/ARM64/diagno-predicate.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: not llvm-mc -triple arm64-linux-gnu -mattr=-fp-armv8 < %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ERROR < %t %s


fcvt d0, s0
// CHECK-ERROR: error: instruction requires: fp-armv8
// CHECK-ERROR-NEXT: fcvt d0, s0
// CHECK-ERROR-NEXT: ^

fmla v9.2s, v9.2s, v0.2s
// CHECK-ERROR: error: instruction requires: neon
// CHECK-ERROR-NEXT: fmla v9.2s, v9.2s, v0.2s
// CHECK-ERROR-NEXT: ^

pmull v0.1q, v1.1d, v2.1d
// CHECK-ERROR: error: instruction requires: crypto
// CHECK-ERROR-NEXT: pmull v0.1q, v1.1d, v2.1d
// CHECK-ERROR-NEXT: ^

2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/fp-encoding.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llvm-mc -triple arm64-apple-darwin -show-encoding -output-asm-variant=1 < %s | FileCheck %s
; RUN: llvm-mc -triple arm64-apple-darwin -mattr=neon -show-encoding -output-asm-variant=1 < %s | FileCheck %s

foo:
;-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/nv-cond.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: llvm-mc < %s -triple arm64 -show-encoding | FileCheck %s
// RUN: llvm-mc < %s -triple arm64 -mattr=neon -show-encoding | FileCheck %s

fcsel d28,d31,d31,nv
csel x0,x0,x0,nv
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/simd-ldst.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llvm-mc -triple arm64-apple-darwin -output-asm-variant=1 -show-encoding < %s | FileCheck %s
; RUN: llvm-mc -triple arm64-apple-darwin -mattr=neon -output-asm-variant=1 -show-encoding < %s | FileCheck %s

_ld1st1_multiple:
ld1.8b {v0}, [x1]
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/vector-lists.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: not llvm-mc -triple arm64 -show-encoding < %s 2>%t | FileCheck %s
// RUN: not llvm-mc -triple arm64 -mattr=neon -show-encoding < %s 2>%t | FileCheck %s
// RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s

ST4 {v0.8B-v3.8B}, [x0]
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ARM64/verbose-vector-case.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: llvm-mc -triple arm64 -show-encoding < %s | FileCheck %s
// RUN: llvm-mc -triple arm64 -mattr=crypto -show-encoding < %s | FileCheck %s

pmull v8.8h, v8.8b, v8.8b
pmull2 v8.8h, v8.16b, v8.16b
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/Disassembler/ARM64/advsimd.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -triple arm64-apple-darwin -output-asm-variant=1 --disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple arm64-apple-darwin -mattr=crypto -output-asm-variant=1 --disassemble < %s | FileCheck %s

0x00 0xb8 0x20 0x0e
0x00 0xb8 0x20 0x4e
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/Disassembler/ARM64/canonical-form.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -triple arm64-apple-darwin --disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple arm64-apple-darwin -mattr=neon --disassemble < %s | FileCheck %s

0x00 0x08 0x00 0xc8

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MC/Disassembler/ARM64/crypto.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-mc -triple arm64-apple-darwin --disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple arm64-apple-darwin -output-asm-variant=1 --disassemble < %s | FileCheck %s --check-prefix=CHECK-APPLE
# RUN: llvm-mc -triple arm64-apple-darwin -mattr=crypto --disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple arm64-apple-darwin -mattr=crypto -output-asm-variant=1 --disassemble < %s | FileCheck %s --check-prefix=CHECK-APPLE

0x20 0x48 0x28 0x4e
0x20 0x58 0x28 0x4e
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/Disassembler/ARM64/non-apple-fmov.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -triple arm64 -disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple arm64 -mattr=neon -disassemble < %s | FileCheck %s

0x00 0x00 0xae 0x9e
0x00 0x00 0xaf 0x9e
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/Disassembler/ARM64/scalar-fp.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -triple arm64-apple-darwin --disassemble -output-asm-variant=1 < %s | FileCheck %s
# RUN: llvm-mc -triple arm64-apple-darwin -mattr=neon --disassemble -output-asm-variant=1 < %s | FileCheck %s

#-----------------------------------------------------------------------------
# Floating-point arithmetic
Expand Down