Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit d9fb399

Browse files
[mips] add warnings for using dsp and msa flags with inappropriate revisions
Dsp and dspr2 require MIPS revision 2, while msa requires revision 5. Adding warnings for cases when these flags are used with earlier revision. Patch by Milos Stojanovic. Differential Revision: https://reviews.llvm.org/D40490 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323131 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9052f33 commit d9fb399

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

lib/Target/Mips/MipsSubtarget.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ static cl::opt<bool>
5757
GPOpt("mgpopt", cl::Hidden,
5858
cl::desc("Enable gp-relative addressing of mips small data items"));
5959

60+
bool MipsSubtarget::DspWarningPrinted = false;
61+
62+
bool MipsSubtarget::MSAWarningPrinted = false;
63+
6064
void MipsSubtarget::anchor() {}
6165

6266
MipsSubtarget::MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
@@ -129,6 +133,40 @@ MipsSubtarget::MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
129133
<< "\n";
130134
UseSmallSection = false;
131135
}
136+
137+
if (hasDSPR2() && !DspWarningPrinted) {
138+
if (hasMips64() && !hasMips64r2()) {
139+
errs() << "warning: the 'dspr2' ASE requires MIPS64 revision 2 or "
140+
<< "greater\n";
141+
DspWarningPrinted = true;
142+
} else if (hasMips32() && !hasMips32r2()) {
143+
errs() << "warning: the 'dspr2' ASE requires MIPS32 revision 2 or "
144+
<< "greater\n";
145+
DspWarningPrinted = true;
146+
}
147+
} else if (hasDSP() && !DspWarningPrinted) {
148+
if (hasMips64() && !hasMips64r2()) {
149+
errs() << "warning: the 'dsp' ASE requires MIPS64 revision 2 or "
150+
<< "greater\n";
151+
DspWarningPrinted = true;
152+
} else if (hasMips32() && !hasMips32r2()) {
153+
errs() << "warning: the 'dsp' ASE requires MIPS32 revision 2 or "
154+
<< "greater\n";
155+
DspWarningPrinted = true;
156+
}
157+
}
158+
159+
if (hasMSA() && !MSAWarningPrinted) {
160+
if (hasMips64() && !hasMips64r5()) {
161+
errs() << "warning: the 'msa' ASE requires MIPS64 revision 5 or "
162+
<< "greater\n";
163+
MSAWarningPrinted = true;
164+
} else if (hasMips32() && !hasMips32r5()) {
165+
errs() << "warning: the 'msa' ASE requires MIPS32 revision 5 or "
166+
<< "greater\n";
167+
MSAWarningPrinted = true;
168+
}
169+
}
132170
}
133171

134172
bool MipsSubtarget::isPositionIndependent() const {

lib/Target/Mips/MipsSubtarget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ class MipsSubtarget : public MipsGenSubtargetInfo {
4444

4545
enum class CPU { P5600 };
4646

47+
// Used to avoid printing dsp warnings multiple times.
48+
static bool DspWarningPrinted;
49+
50+
// Used to avoid printing msa warnings multiple times.
51+
static bool MSAWarningPrinted;
52+
4753
// Mips architecture version
4854
MipsArchEnum MipsArchVersion;
4955

test/CodeGen/Mips/dsp_msa_warning.ll

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; Check msa warnings.
2+
; RUN: llc -march=mips -mattr=+mips32r2 -mattr=+msa -mattr=+fp64 < %s 2>&1 | \
3+
; RUN: FileCheck %s -check-prefix=MSA_32
4+
; RUN: llc -march=mips64 -mattr=+mips64r2 -mattr=+msa < %s 2>&1 | \
5+
; RUN: FileCheck %s -check-prefix=MSA_64
6+
; RUN: llc -march=mips -mattr=+mips32r5 -mattr=+msa -mattr=+fp64 < %s 2>&1 | \
7+
; RUN: FileCheck %s -check-prefix=MSA_32_NO_WARNING
8+
; RUN: llc -march=mips64 -mattr=+mips64r5 -mattr=+msa < %s 2>&1 | \
9+
; RUN: FileCheck %s -check-prefix=MSA_64_NO_WARNING
10+
11+
; Check dspr2 warnings.
12+
; RUN: llc -march=mips -mattr=+mips32 -mattr=+dspr2 < %s 2>&1 | \
13+
; RUN: FileCheck %s -check-prefix=DSPR2_32
14+
; RUN: llc -march=mips64 -mattr=+mips64 -mattr=+dspr2 < %s 2>&1 | \
15+
; RUN: FileCheck %s -check-prefix=DSPR2_64
16+
; RUN: llc -march=mips64 -mattr=+mips64r3 -mattr=+dspr2 < %s 2>&1 | \
17+
; RUN: FileCheck %s -check-prefix=DSPR2_64_NO_WARNING
18+
; RUN: llc -march=mips -mattr=+mips32r2 -mattr=+dspr2 < %s 2>&1 | \
19+
; RUN: FileCheck %s -check-prefix=DSPR2_32_NO_WARNING
20+
21+
; Check dsp warnings.
22+
; RUN: llc -march=mips -mattr=+mips32 -mattr=+dsp < %s 2>&1 | \
23+
; RUN: FileCheck %s -check-prefix=DSP_32
24+
; RUN: llc -march=mips64 -mattr=+mips64 -mattr=+dsp < %s 2>&1 | \
25+
; RUN: FileCheck %s -check-prefix=DSP_64
26+
; RUN: llc -march=mips -mattr=+mips32r5 -mattr=+dsp < %s 2>&1 | \
27+
; RUN: FileCheck %s -check-prefix=DSP_32_NO_WARNING
28+
; RUN: llc -march=mips64 -mattr=+mips64r2 -mattr=+dsp < %s 2>&1 | \
29+
; RUN: FileCheck %s -check-prefix=DSP_64_NO_WARNING
30+
31+
; MSA_32: warning: the 'msa' ASE requires MIPS32 revision 5 or greater
32+
; MSA_64: warning: the 'msa' ASE requires MIPS64 revision 5 or greater
33+
; MSA_32_NO_WARNING-NOT: warning: the 'msa' ASE requires MIPS32 revision 5 or greater
34+
; MSA_64_NO_WARNING-NOT: warning: the 'msa' ASE requires MIPS64 revision 5 or greater
35+
36+
; DSPR2_32: warning: the 'dspr2' ASE requires MIPS32 revision 2 or greater
37+
; DSPR2_64: warning: the 'dspr2' ASE requires MIPS64 revision 2 or greater
38+
; DSPR2_32_NO_WARNING-NOT: warning: the 'dspr2' ASE requires MIPS32 revision 2 or greater
39+
; DSPR2_64_NO_WARNING-NOT: warning: the 'dspr2' ASE requires MIPS64 revision 2 or greater
40+
41+
; DSP_32: warning: the 'dsp' ASE requires MIPS32 revision 2 or greater
42+
; DSP_64: warning: the 'dsp' ASE requires MIPS64 revision 2 or greater
43+
; DSP_32_NO_WARNING-NOT: warning: the 'dsp' ASE requires MIPS32 revision 2 or greater
44+
; DSP_64_NO_WARNING-NOT: warning: the 'dsp' ASE requires MIPS64 revision 2 or greater

0 commit comments

Comments
 (0)