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

Commit 4378ff0

Browse files
author
Toma Tabacu
committed
[mips] Add assembler support for the .set nodsp directive.
Summary: This directive is used to tell the assembler to reject DSP-specific instructions. Reviewers: dsanders Reviewed By: dsanders Differential Revision: http://reviews.llvm.org/D5142 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217946 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 217ab20 commit 4378ff0

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class MipsAsmParser : public MCTargetAsmParser {
192192
bool parseSetNoMacroDirective();
193193
bool parseSetMsaDirective();
194194
bool parseSetNoMsaDirective();
195+
bool parseSetNoDspDirective();
195196
bool parseSetReorderDirective();
196197
bool parseSetNoReorderDirective();
197198
bool parseSetNoMips16Directive();
@@ -2654,6 +2655,20 @@ bool MipsAsmParser::parseSetNoMsaDirective() {
26542655
return false;
26552656
}
26562657

2658+
bool MipsAsmParser::parseSetNoDspDirective() {
2659+
Parser.Lex(); // Eat "nodsp".
2660+
2661+
// If this is not the end of the statement, report an error.
2662+
if (getLexer().isNot(AsmToken::EndOfStatement)) {
2663+
reportParseError("unexpected token, expected end of statement");
2664+
return false;
2665+
}
2666+
2667+
clearFeatureBits(Mips::FeatureDSP, "dsp");
2668+
getTargetStreamer().emitDirectiveSetNoDsp();
2669+
return false;
2670+
}
2671+
26572672
bool MipsAsmParser::parseSetNoMips16Directive() {
26582673
Parser.Lex();
26592674
// If this is not the end of the statement, report an error.
@@ -3037,6 +3052,8 @@ bool MipsAsmParser::parseDirectiveSet() {
30373052
return parseSetFeature(Mips::FeatureMips64r6);
30383053
} else if (Tok.getString() == "dsp") {
30393054
return parseSetFeature(Mips::FeatureDSP);
3055+
} else if (Tok.getString() == "nodsp") {
3056+
return parseSetNoDspDirective();
30403057
} else if (Tok.getString() == "msa") {
30413058
return parseSetMsaDirective();
30423059
} else if (Tok.getString() == "nomsa") {

lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void MipsTargetStreamer::emitDirectiveSetMips64R6() { forbidModuleDirective(); }
7474
void MipsTargetStreamer::emitDirectiveSetPop() {}
7575
void MipsTargetStreamer::emitDirectiveSetPush() {}
7676
void MipsTargetStreamer::emitDirectiveSetDsp() { forbidModuleDirective(); }
77+
void MipsTargetStreamer::emitDirectiveSetNoDsp() { forbidModuleDirective(); }
7778
void MipsTargetStreamer::emitDirectiveCpload(unsigned RegNo) {}
7879
void MipsTargetStreamer::emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
7980
const MCSymbol &Sym, bool IsReg) {
@@ -247,6 +248,11 @@ void MipsTargetAsmStreamer::emitDirectiveSetDsp() {
247248
MipsTargetStreamer::emitDirectiveSetDsp();
248249
}
249250

251+
void MipsTargetAsmStreamer::emitDirectiveSetNoDsp() {
252+
OS << "\t.set\tnodsp\n";
253+
MipsTargetStreamer::emitDirectiveSetNoDsp();
254+
}
255+
250256
void MipsTargetAsmStreamer::emitDirectiveSetPop() { OS << "\t.set\tpop\n"; }
251257

252258
void MipsTargetAsmStreamer::emitDirectiveSetPush() { OS << "\t.set\tpush\n"; }

lib/Target/Mips/MipsTargetStreamer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class MipsTargetStreamer : public MCTargetStreamer {
6262
virtual void emitDirectiveSetMips64R2();
6363
virtual void emitDirectiveSetMips64R6();
6464
virtual void emitDirectiveSetDsp();
65+
virtual void emitDirectiveSetNoDsp();
6566
virtual void emitDirectiveSetPop();
6667
virtual void emitDirectiveSetPush();
6768

@@ -165,6 +166,7 @@ class MipsTargetAsmStreamer : public MipsTargetStreamer {
165166
void emitDirectiveSetMips64R2() override;
166167
void emitDirectiveSetMips64R6() override;
167168
void emitDirectiveSetDsp() override;
169+
void emitDirectiveSetNoDsp() override;
168170
void emitDirectiveSetPop() override;
169171
void emitDirectiveSetPush() override;
170172

test/MC/Mips/set-nodsp.s

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# RUN: not llvm-mc %s -mcpu=mips32 -mattr=+dsp -triple mips-unknown-linux 2>%t1
2+
# RUN: FileCheck %s < %t1
3+
4+
lbux $7, $10($11)
5+
6+
.set nodsp
7+
lbux $6, $10($11)
8+
# CHECK: error: instruction requires a CPU feature not currently enabled
9+
10+
.set dsp
11+
lbux $5, $10($11)
12+
# CHECK-NOT: error: instruction requires a CPU feature not currently enabled

0 commit comments

Comments
 (0)