mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[mips][mt][2/7] Implement .module and .set directives for the MT ASE.
This patch implements the .module and .set directives for the MT ASE, notably that .module sets the relevant flags in .MIPS.abiflags and .set doesn't. Reviewers: slthakur, atanasyan Differential Revision: https://reviews.llvm.org/D35249 llvm-svn: 307716
This commit is contained in:
parent
694c95253b
commit
c8fe6b02b4
@ -343,6 +343,8 @@ class MipsAsmParser : public MCTargetAsmParser {
|
||||
bool parseSetPushDirective();
|
||||
bool parseSetSoftFloatDirective();
|
||||
bool parseSetHardFloatDirective();
|
||||
bool parseSetMtDirective();
|
||||
bool parseSetNoMtDirective();
|
||||
|
||||
bool parseSetAssignment();
|
||||
|
||||
@ -6333,6 +6335,39 @@ bool MipsAsmParser::parseSetNoOddSPRegDirective() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MipsAsmParser::parseSetMtDirective() {
|
||||
MCAsmParser &Parser = getParser();
|
||||
Parser.Lex(); // Eat "mt".
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
setFeatureBits(Mips::FeatureMT, "mt");
|
||||
getTargetStreamer().emitDirectiveSetMt();
|
||||
Parser.Lex(); // Consume the EndOfStatement.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MipsAsmParser::parseSetNoMtDirective() {
|
||||
MCAsmParser &Parser = getParser();
|
||||
Parser.Lex(); // Eat "nomt".
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
clearFeatureBits(Mips::FeatureMT, "mt");
|
||||
|
||||
getTargetStreamer().emitDirectiveSetNoMt();
|
||||
Parser.Lex(); // Consume the EndOfStatement.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MipsAsmParser::parseSetPopDirective() {
|
||||
MCAsmParser &Parser = getParser();
|
||||
SMLoc Loc = getLexer().getLoc();
|
||||
@ -6833,6 +6868,10 @@ bool MipsAsmParser::parseDirectiveSet() {
|
||||
return parseSetMsaDirective();
|
||||
} else if (Tok.getString() == "nomsa") {
|
||||
return parseSetNoMsaDirective();
|
||||
} else if (Tok.getString() == "mt") {
|
||||
return parseSetMtDirective();
|
||||
} else if (Tok.getString() == "nomt") {
|
||||
return parseSetNoMtDirective();
|
||||
} else if (Tok.getString() == "softfloat") {
|
||||
return parseSetSoftFloatDirective();
|
||||
} else if (Tok.getString() == "hardfloat") {
|
||||
@ -7082,6 +7121,7 @@ bool MipsAsmParser::parseSSectionDirective(StringRef Section, unsigned Type) {
|
||||
/// ::= .module fp=value
|
||||
/// ::= .module softfloat
|
||||
/// ::= .module hardfloat
|
||||
/// ::= .module mt
|
||||
bool MipsAsmParser::parseDirectiveModule() {
|
||||
MCAsmParser &Parser = getParser();
|
||||
MCAsmLexer &Lexer = getLexer();
|
||||
@ -7180,6 +7220,25 @@ bool MipsAsmParser::parseDirectiveModule() {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // parseDirectiveModule has finished successfully.
|
||||
} else if (Option == "mt") {
|
||||
setModuleFeatureBits(Mips::FeatureMT, "mt");
|
||||
|
||||
// Synchronize the ABI Flags information with the FeatureBits information we
|
||||
// updated above.
|
||||
getTargetStreamer().updateABIInfo(*this);
|
||||
|
||||
// If priniing assembly, use the recently updated ABI Flags information.
|
||||
// If generating ELF, don't do anything (the .MIPS.abiflags section gets
|
||||
// emitted later).
|
||||
getTargetStreamer().emitDirectiveModuleMT();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
return false; // parseDirectiveModule has finished successfully.
|
||||
} else {
|
||||
return Error(L, "'" + Twine(Option) + "' is not a valid .module option.");
|
||||
|
@ -50,6 +50,8 @@ void MipsTargetStreamer::emitDirectiveSetMacro() { forbidModuleDirective(); }
|
||||
void MipsTargetStreamer::emitDirectiveSetNoMacro() { forbidModuleDirective(); }
|
||||
void MipsTargetStreamer::emitDirectiveSetMsa() { forbidModuleDirective(); }
|
||||
void MipsTargetStreamer::emitDirectiveSetNoMsa() { forbidModuleDirective(); }
|
||||
void MipsTargetStreamer::emitDirectiveSetMt() {}
|
||||
void MipsTargetStreamer::emitDirectiveSetNoMt() { forbidModuleDirective(); }
|
||||
void MipsTargetStreamer::emitDirectiveSetAt() { forbidModuleDirective(); }
|
||||
void MipsTargetStreamer::emitDirectiveSetAtWithArg(unsigned RegNo) {
|
||||
forbidModuleDirective();
|
||||
@ -118,6 +120,7 @@ void MipsTargetStreamer::emitDirectiveModuleOddSPReg() {
|
||||
}
|
||||
void MipsTargetStreamer::emitDirectiveModuleSoftFloat() {}
|
||||
void MipsTargetStreamer::emitDirectiveModuleHardFloat() {}
|
||||
void MipsTargetStreamer::emitDirectiveModuleMT() {}
|
||||
void MipsTargetStreamer::emitDirectiveSetFp(
|
||||
MipsABIFlagsSection::FpABIKind Value) {
|
||||
forbidModuleDirective();
|
||||
@ -392,6 +395,16 @@ void MipsTargetAsmStreamer::emitDirectiveSetNoMsa() {
|
||||
MipsTargetStreamer::emitDirectiveSetNoMsa();
|
||||
}
|
||||
|
||||
void MipsTargetAsmStreamer::emitDirectiveSetMt() {
|
||||
OS << "\t.set\tmt\n";
|
||||
MipsTargetStreamer::emitDirectiveSetMt();
|
||||
}
|
||||
|
||||
void MipsTargetAsmStreamer::emitDirectiveSetNoMt() {
|
||||
OS << "\t.set\tnomt\n";
|
||||
MipsTargetStreamer::emitDirectiveSetNoMt();
|
||||
}
|
||||
|
||||
void MipsTargetAsmStreamer::emitDirectiveSetAt() {
|
||||
OS << "\t.set\tat\n";
|
||||
MipsTargetStreamer::emitDirectiveSetAt();
|
||||
@ -656,6 +669,10 @@ void MipsTargetAsmStreamer::emitDirectiveModuleHardFloat() {
|
||||
OS << "\t.module\thardfloat\n";
|
||||
}
|
||||
|
||||
void MipsTargetAsmStreamer::emitDirectiveModuleMT() {
|
||||
OS << "\t.module\tmt\n";
|
||||
}
|
||||
|
||||
// This part is for ELF object output.
|
||||
MipsTargetELFStreamer::MipsTargetELFStreamer(MCStreamer &S,
|
||||
const MCSubtargetInfo &STI)
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
virtual void emitDirectiveSetNoMacro();
|
||||
virtual void emitDirectiveSetMsa();
|
||||
virtual void emitDirectiveSetNoMsa();
|
||||
virtual void emitDirectiveSetMt();
|
||||
virtual void emitDirectiveSetNoMt();
|
||||
virtual void emitDirectiveSetAt();
|
||||
virtual void emitDirectiveSetAtWithArg(unsigned RegNo);
|
||||
virtual void emitDirectiveSetNoAt();
|
||||
@ -96,6 +98,7 @@ public:
|
||||
virtual void emitDirectiveModuleOddSPReg();
|
||||
virtual void emitDirectiveModuleSoftFloat();
|
||||
virtual void emitDirectiveModuleHardFloat();
|
||||
virtual void emitDirectiveModuleMT();
|
||||
virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value);
|
||||
virtual void emitDirectiveSetOddSPReg();
|
||||
virtual void emitDirectiveSetNoOddSPReg();
|
||||
@ -204,6 +207,8 @@ public:
|
||||
void emitDirectiveSetNoMacro() override;
|
||||
void emitDirectiveSetMsa() override;
|
||||
void emitDirectiveSetNoMsa() override;
|
||||
void emitDirectiveSetMt() override;
|
||||
void emitDirectiveSetNoMt() override;
|
||||
void emitDirectiveSetAt() override;
|
||||
void emitDirectiveSetAtWithArg(unsigned RegNo) override;
|
||||
void emitDirectiveSetNoAt() override;
|
||||
@ -267,6 +272,7 @@ public:
|
||||
void emitDirectiveModuleOddSPReg() override;
|
||||
void emitDirectiveModuleSoftFloat() override;
|
||||
void emitDirectiveModuleHardFloat() override;
|
||||
void emitDirectiveModuleMT() override;
|
||||
void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override;
|
||||
void emitDirectiveSetOddSPReg() override;
|
||||
void emitDirectiveSetNoOddSPReg() override;
|
||||
|
6
test/MC/Mips/mt/module-directive-invalid.s
Normal file
6
test/MC/Mips/mt/module-directive-invalid.s
Normal file
@ -0,0 +1,6 @@
|
||||
# RUN: not llvm-mc -arch=mips -mcpu=mips32r5 < %s 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: error: .module directive must appear before any code
|
||||
.set nomips16
|
||||
.module mt
|
||||
nop
|
16
test/MC/Mips/mt/module-directive.s
Normal file
16
test/MC/Mips/mt/module-directive.s
Normal file
@ -0,0 +1,16 @@
|
||||
# RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=obj -o - | \
|
||||
# RUN: llvm-readobj -mips-abi-flags | FileCheck --check-prefix=CHECK-OBJ %s
|
||||
# RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=asm -o - | \
|
||||
# RUN: FileCheck --check-prefix=CHECK-ASM %s
|
||||
|
||||
# Test that the .module directive sets the MT flag in .MIPS.abiflags when
|
||||
# assembling to boject files.
|
||||
|
||||
# Test that the .moodule directive is re-emitted when expanding assembly.
|
||||
|
||||
# CHECK-OBJ: ASEs
|
||||
# CHECK-OBJ-NEXT: MT (0x40)
|
||||
|
||||
# CHECK-ASM: .module mt
|
||||
.module mt
|
||||
nop
|
14
test/MC/Mips/mt/set-directive.s
Normal file
14
test/MC/Mips/mt/set-directive.s
Normal file
@ -0,0 +1,14 @@
|
||||
# RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=obj -o - | \
|
||||
# RUN: llvm-readobj -mips-abi-flags | FileCheck %s --check-prefix=CHECK-OBJ
|
||||
# RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=asm -o - | \
|
||||
# RUN: FileCheck %s --check-prefix=CHECK-ASM
|
||||
|
||||
# Test that the MT ASE flag in .MIPS.abiflags is _not_ set by .set.
|
||||
# Test that '.set mt' is emitted by the asm target streamer.
|
||||
|
||||
# CHECK-OBJ: ASEs
|
||||
# CHECK-OBJ-NOT: MT (0x40)
|
||||
|
||||
# CHECK-ASM: .set mt
|
||||
.set mt
|
||||
nop
|
Loading…
x
Reference in New Issue
Block a user