Skip to content

Commit 418c1d8

Browse files
authored
[MIPS] Reland Add FeatureMSA to i6400 and i6500 cores (#134985) (#141730)
Note: This relands #134985 with a fix. Original PR resulted in test fail for msan builds. Fix: Initialize MipsSubtarget::ProcImpl to ProcImpl::CPU::Others [MIPS] Reland Add FeatureMSA to i6400 and i6500 cores (#134985) - Enable 'FeatureMSA' for MIPS i6400 and i6500 cpu. - Enable -mmsa option if mcpu is set to either i6400 or i6500 - added clang driver test to validate msa feature - added llvm codegen test to validate msa instructions for cpu i6500 and i6400 MIPS i6400 and i6500 cores implements and enables MSA (MIPS SIMD ARCHITECTURE) by default.
1 parent ed14e0d commit 418c1d8

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

clang/lib/Driver/ToolChains/Arch/Mips.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
254254
D.Diag(diag::err_drv_unsupported_noabicalls_pic);
255255
}
256256

257+
if (CPUName == "i6500" || CPUName == "i6400") {
258+
// MIPS cpu i6400 and i6500 support MSA (Mips SIMD Architecture)
259+
// by default.
260+
Features.push_back("+msa");
261+
}
262+
257263
if (!UseAbiCalls)
258264
Features.push_back("+noabicalls");
259265
else

clang/test/Driver/mips-cpus.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Check target CPUs are correctly passed.
2+
3+
// RUN: %clang --target=mips64 -### -c %s 2>&1 -mcpu=i6400 | FileCheck -check-prefix=MCPU-I6400 %s
4+
// MCPU-I6400: "-target-cpu" "i6400"
5+
// MCPU-I6400: "-target-feature" "+msa" "-target-feature" "-noabicalls"
6+
7+
// RUN: %clang --target=mips64 -### -c %s 2>&1 -mcpu=i6500 | FileCheck -check-prefix=MCPU-I6500 %s
8+
// MCPU-I6500: "-target-cpu" "i6500"
9+
// MCPU-I6500: "-target-feature" "+msa" "-target-feature" "-noabicalls"

llvm/lib/Target/Mips/Mips.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
243243
// same CPU architecture.
244244
def ImplI6400
245245
: SubtargetFeature<"i6400", "ProcImpl", "MipsSubtarget::CPU::I6400",
246-
"MIPS I6400 Processor", [FeatureMips64r6]>;
246+
"MIPS I6400 Processor", [FeatureMips64r6, FeatureMSA]>;
247247

248248
def ImplI6500
249249
: SubtargetFeature<"i6500", "ProcImpl", "MipsSubtarget::CPU::I6500",
250-
"MIPS I6500 Processor", [FeatureMips64r6]>;
250+
"MIPS I6500 Processor", [FeatureMips64r6, FeatureMSA]>;
251251

252252
class Proc<string Name, list<SubtargetFeature> Features>
253253
: ProcessorModel<Name, MipsGenericModel, Features>;

llvm/lib/Target/Mips/MipsSubtarget.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
4343
Mips3, Mips4, Mips5, Mips64, Mips64r2, Mips64r3, Mips64r5, Mips64r6
4444
};
4545

46-
enum class CPU { P5600, I6400, I6500 };
46+
enum class CPU { Others, P5600, I6400, I6500 };
4747

4848
// Used to avoid printing dsp warnings multiple times.
4949
static bool DspWarningPrinted;
@@ -66,9 +66,8 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
6666
// Mips architecture version
6767
MipsArchEnum MipsArchVersion;
6868

69-
// Processor implementation (unused but required to exist by
70-
// tablegen-erated code).
71-
CPU ProcImpl;
69+
// Processor implementation
70+
CPU ProcImpl = CPU::Others;
7271

7372
// IsLittle - The target is Little Endian
7473
bool IsLittle;

llvm/test/CodeGen/Mips/msa/arithmetic.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -mtriple=mips -mattr=+msa,+fp64,+mips32r2 < %s | FileCheck %s --check-prefixes=ALL,MIPS
33
; RUN: llc -mtriple=mipsel -mattr=+msa,+fp64,+mips32r2 < %s | FileCheck %s --check-prefixes=ALL,MIPSEL
4+
; RUN: llc -mtriple=mips64 -mcpu=i6500 < %s | FileCheck %s --check-prefixes=ALL
5+
; RUN: llc -mtriple=mips64 -mcpu=i6400 < %s | FileCheck %s --check-prefixes=ALL
46

57
define void @add_v16i8(ptr %c, ptr %a, ptr %b) nounwind {
68
; ALL-LABEL: add_v16i8:

0 commit comments

Comments
 (0)