[llvm] r231465 - [mips] [IAS] Add missing constraints and improve testing for the .module directive.
Toma Tabacu
toma.tabacu at imgtec.com
Fri Mar 6 04:15:13 PST 2015
Author: tomatabacu
Date: Fri Mar 6 06:15:12 2015
New Revision: 231465
URL: http://llvm.org/viewvc/llvm-project?rev=231465&view=rev
Log:
[mips] [IAS] Add missing constraints and improve testing for the .module directive.
Summary:
None of the .set directives can be used before the .module directives. The .set mips0/pop/push were not triggering this constraint.
Also added testing for all the other implemented directives which are supposed to trigger this constraint.
Reviewers: dsanders
Reviewed By: dsanders
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D7140
Added:
llvm/trunk/test/MC/Mips/module-directive-bad.s
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
llvm/trunk/test/MC/Mips/mips-abi-bad.s
Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=231465&r1=231464&r2=231465&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Fri Mar 6 06:15:12 2015
@@ -236,6 +236,8 @@ class MipsAsmParser : public MCTargetAsm
bool parseFpABIValue(MipsABIFlagsSection::FpABIKind &FpABI,
StringRef Directive);
+ bool parseInternalDirectiveReallowModule();
+
MCSymbolRefExpr::VariantKind getVariantKind(StringRef Symbol);
bool eatComma(StringRef ErrorStr);
@@ -4429,9 +4431,25 @@ bool MipsAsmParser::ParseDirective(AsmTo
if (IDVal == ".module")
return parseDirectiveModule();
+ if (IDVal == ".llvm_internal_mips_reallow_module_directive")
+ return parseInternalDirectiveReallowModule();
+
return true;
}
+bool MipsAsmParser::parseInternalDirectiveReallowModule() {
+ // If this is not the end of the statement, report an error.
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ reportParseError("unexpected token, expected end of statement");
+ return false;
+ }
+
+ getTargetStreamer().reallowModuleDirective();
+
+ getParser().Lex(); // Eat EndOfStatement token.
+ return false;
+}
+
extern "C" void LLVMInitializeMipsAsmParser() {
RegisterMCAsmParser<MipsAsmParser> X(TheMipsTarget);
RegisterMCAsmParser<MipsAsmParser> Y(TheMipselTarget);
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp?rev=231465&r1=231464&r2=231465&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Fri Mar 6 06:15:12 2015
@@ -62,7 +62,7 @@ void MipsTargetStreamer::emitFMask(unsig
void MipsTargetStreamer::emitDirectiveSetArch(StringRef Arch) {
forbidModuleDirective();
}
-void MipsTargetStreamer::emitDirectiveSetMips0() {}
+void MipsTargetStreamer::emitDirectiveSetMips0() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetMips1() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetMips2() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetMips3() { forbidModuleDirective(); }
@@ -78,8 +78,8 @@ void MipsTargetStreamer::emitDirectiveSe
void MipsTargetStreamer::emitDirectiveSetMips64R3() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetMips64R5() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetMips64R6() { forbidModuleDirective(); }
-void MipsTargetStreamer::emitDirectiveSetPop() {}
-void MipsTargetStreamer::emitDirectiveSetPush() {}
+void MipsTargetStreamer::emitDirectiveSetPop() { forbidModuleDirective(); }
+void MipsTargetStreamer::emitDirectiveSetPush() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetDsp() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetNoDsp() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveCpLoad(unsigned RegNo) {}
@@ -91,6 +91,10 @@ void MipsTargetStreamer::emitDirectiveMo
if (!Enabled && !IsO32ABI)
report_fatal_error("+nooddspreg is only valid for O32");
}
+void MipsTargetStreamer::emitDirectiveSetFp(
+ MipsABIFlagsSection::FpABIKind Value) {
+ forbidModuleDirective();
+}
MipsTargetAsmStreamer::MipsTargetAsmStreamer(MCStreamer &S,
formatted_raw_ostream &OS)
@@ -198,7 +202,10 @@ void MipsTargetAsmStreamer::emitDirectiv
MipsTargetStreamer::emitDirectiveSetArch(Arch);
}
-void MipsTargetAsmStreamer::emitDirectiveSetMips0() { OS << "\t.set\tmips0\n"; }
+void MipsTargetAsmStreamer::emitDirectiveSetMips0() {
+ OS << "\t.set\tmips0\n";
+ MipsTargetStreamer::emitDirectiveSetMips0();
+}
void MipsTargetAsmStreamer::emitDirectiveSetMips1() {
OS << "\t.set\tmips1\n";
@@ -285,9 +292,15 @@ void MipsTargetAsmStreamer::emitDirectiv
MipsTargetStreamer::emitDirectiveSetNoDsp();
}
-void MipsTargetAsmStreamer::emitDirectiveSetPop() { OS << "\t.set\tpop\n"; }
+void MipsTargetAsmStreamer::emitDirectiveSetPop() {
+ OS << "\t.set\tpop\n";
+ MipsTargetStreamer::emitDirectiveSetPop();
+}
-void MipsTargetAsmStreamer::emitDirectiveSetPush() { OS << "\t.set\tpush\n"; }
+void MipsTargetAsmStreamer::emitDirectiveSetPush() {
+ OS << "\t.set\tpush\n";
+ MipsTargetStreamer::emitDirectiveSetPush();
+}
// Print a 32 bit hex number with all numbers.
static void printHex32(unsigned Value, raw_ostream &OS) {
@@ -346,6 +359,8 @@ void MipsTargetAsmStreamer::emitDirectiv
void MipsTargetAsmStreamer::emitDirectiveSetFp(
MipsABIFlagsSection::FpABIKind Value) {
+ MipsTargetStreamer::emitDirectiveSetFp(Value);
+
StringRef ModuleValue;
OS << "\t.set\tfp=";
OS << ABIFlagsSection.getFpABIString(Value) << "\n";
Modified: llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h?rev=231465&r1=231464&r2=231465&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h Fri Mar 6 06:15:12 2015
@@ -92,9 +92,10 @@ public:
}
virtual void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI);
- virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value){};
+ virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value);
virtual void emitMipsAbiFlags(){};
void forbidModuleDirective() { ModuleDirectiveAllowed = false; }
+ void reallowModuleDirective() { ModuleDirectiveAllowed = true; }
bool isModuleDirectiveAllowed() { return ModuleDirectiveAllowed; }
// This method enables template classes to set internal abi flags
Modified: llvm/trunk/test/MC/Mips/mips-abi-bad.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/mips-abi-bad.s?rev=231465&r1=231464&r2=231465&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/mips-abi-bad.s (original)
+++ llvm/trunk/test/MC/Mips/mips-abi-bad.s Fri Mar 6 06:15:12 2015
@@ -22,9 +22,3 @@
# CHECK: :[[@LINE-1]]:13: error: expected .module option identifier
# CHECK-NEXT: .module 34
# CHECK-NEXT: ^
-
- .set mips16
- .module fp=32
-# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
-# CHECK-NEXT: .module fp=32
-# CHECK-NEXT: ^
Added: llvm/trunk/test/MC/Mips/module-directive-bad.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/module-directive-bad.s?rev=231465&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/module-directive-bad.s (added)
+++ llvm/trunk/test/MC/Mips/module-directive-bad.s Fri Mar 6 06:15:12 2015
@@ -0,0 +1,262 @@
+# RUN: not llvm-mc -triple mips-unknown-unknown %s 2>%t1
+# RUN: FileCheck %s < %t1
+
+ .set mips0
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips1
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips2
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips3
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips4
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips5
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips32
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips32r2
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips32r6
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips64
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips64r2
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips64r6
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set arch=mips32
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set mips16
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set nomips16
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set micromips
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set nomicromips
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set msa
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set nomsa
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set dsp
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set nodsp
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set push
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set pop
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set reorder
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set noreorder
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set macro
+ .module fp=64
+# FIXME: emitDirectiveSetMacro should call forbidModuleDirective().
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set nomacro
+ .module fp=64
+# FIXME: emitDirectiveSetNoMacro should call forbidModuleDirective().
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set at
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set at=$3
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set noat
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .set fp=32
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .cpload $25
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .llvm_internal_mips_reallow_module_directive
+ .module fp=32
+# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
+ .cpsetup $25, 8, __cerror
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
More information about the llvm-commits
mailing list