mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-30 23:20:54 +00:00
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231465 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
90e6a21e85
commit
25c2850952
@ -236,6 +236,8 @@ class MipsAsmParser : public MCTargetAsmParser {
|
||||
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(AsmToken DirectiveID) {
|
||||
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);
|
||||
|
@ -62,7 +62,7 @@ void MipsTargetStreamer::emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) {
|
||||
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::emitDirectiveSetMips64R2() { forbidModuleDirective(); }
|
||||
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::emitDirectiveModuleOddSPReg(bool Enabled,
|
||||
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::emitDirectiveSetArch(StringRef Arch) {
|
||||
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::emitDirectiveSetNoDsp() {
|
||||
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::emitDirectiveModuleFP(
|
||||
|
||||
void MipsTargetAsmStreamer::emitDirectiveSetFp(
|
||||
MipsABIFlagsSection::FpABIKind Value) {
|
||||
MipsTargetStreamer::emitDirectiveSetFp(Value);
|
||||
|
||||
StringRef ModuleValue;
|
||||
OS << "\t.set\tfp=";
|
||||
OS << ABIFlagsSection.getFpABIString(Value) << "\n";
|
||||
|
@ -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
|
||||
|
@ -21,10 +21,4 @@
|
||||
.module 34
|
||||
# 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: ^
|
||||
|
262
test/MC/Mips/module-directive-bad.s
Normal file
262
test/MC/Mips/module-directive-bad.s
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user