llvm.org GIT mirror llvm / 0ce5e21
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307716 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Dardis 2 years ago
6 changed file(s) with 118 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
342342 bool parseSetPushDirective();
343343 bool parseSetSoftFloatDirective();
344344 bool parseSetHardFloatDirective();
345 bool parseSetMtDirective();
346 bool parseSetNoMtDirective();
345347
346348 bool parseSetAssignment();
347349
63326334 return false;
63336335 }
63346336
6337 bool MipsAsmParser::parseSetMtDirective() {
6338 MCAsmParser &Parser = getParser();
6339 Parser.Lex(); // Eat "mt".
6340
6341 // If this is not the end of the statement, report an error.
6342 if (getLexer().isNot(AsmToken::EndOfStatement)) {
6343 reportParseError("unexpected token, expected end of statement");
6344 return false;
6345 }
6346
6347 setFeatureBits(Mips::FeatureMT, "mt");
6348 getTargetStreamer().emitDirectiveSetMt();
6349 Parser.Lex(); // Consume the EndOfStatement.
6350 return false;
6351 }
6352
6353 bool MipsAsmParser::parseSetNoMtDirective() {
6354 MCAsmParser &Parser = getParser();
6355 Parser.Lex(); // Eat "nomt".
6356
6357 // If this is not the end of the statement, report an error.
6358 if (getLexer().isNot(AsmToken::EndOfStatement)) {
6359 reportParseError("unexpected token, expected end of statement");
6360 return false;
6361 }
6362
6363 clearFeatureBits(Mips::FeatureMT, "mt");
6364
6365 getTargetStreamer().emitDirectiveSetNoMt();
6366 Parser.Lex(); // Consume the EndOfStatement.
6367 return false;
6368 }
6369
63356370 bool MipsAsmParser::parseSetPopDirective() {
63366371 MCAsmParser &Parser = getParser();
63376372 SMLoc Loc = getLexer().getLoc();
68326867 return parseSetMsaDirective();
68336868 } else if (Tok.getString() == "nomsa") {
68346869 return parseSetNoMsaDirective();
6870 } else if (Tok.getString() == "mt") {
6871 return parseSetMtDirective();
6872 } else if (Tok.getString() == "nomt") {
6873 return parseSetNoMtDirective();
68356874 } else if (Tok.getString() == "softfloat") {
68366875 return parseSetSoftFloatDirective();
68376876 } else if (Tok.getString() == "hardfloat") {
70817120 /// ::= .module fp=value
70827121 /// ::= .module softfloat
70837122 /// ::= .module hardfloat
7123 /// ::= .module mt
70847124 bool MipsAsmParser::parseDirectiveModule() {
70857125 MCAsmParser &Parser = getParser();
70867126 MCAsmLexer &Lexer = getLexer();
71727212 // If generating ELF, don't do anything (the .MIPS.abiflags section gets
71737213 // emitted later).
71747214 getTargetStreamer().emitDirectiveModuleHardFloat();
7215
7216 // If this is not the end of the statement, report an error.
7217 if (getLexer().isNot(AsmToken::EndOfStatement)) {
7218 reportParseError("unexpected token, expected end of statement");
7219 return false;
7220 }
7221
7222 return false; // parseDirectiveModule has finished successfully.
7223 } else if (Option == "mt") {
7224 setModuleFeatureBits(Mips::FeatureMT, "mt");
7225
7226 // Synchronize the ABI Flags information with the FeatureBits information we
7227 // updated above.
7228 getTargetStreamer().updateABIInfo(*this);
7229
7230 // If priniing assembly, use the recently updated ABI Flags information.
7231 // If generating ELF, don't do anything (the .MIPS.abiflags section gets
7232 // emitted later).
7233 getTargetStreamer().emitDirectiveModuleMT();
71757234
71767235 // If this is not the end of the statement, report an error.
71777236 if (getLexer().isNot(AsmToken::EndOfStatement)) {
4949 void MipsTargetStreamer::emitDirectiveSetNoMacro() { forbidModuleDirective(); }
5050 void MipsTargetStreamer::emitDirectiveSetMsa() { forbidModuleDirective(); }
5151 void MipsTargetStreamer::emitDirectiveSetNoMsa() { forbidModuleDirective(); }
52 void MipsTargetStreamer::emitDirectiveSetMt() {}
53 void MipsTargetStreamer::emitDirectiveSetNoMt() { forbidModuleDirective(); }
5254 void MipsTargetStreamer::emitDirectiveSetAt() { forbidModuleDirective(); }
5355 void MipsTargetStreamer::emitDirectiveSetAtWithArg(unsigned RegNo) {
5456 forbidModuleDirective();
117119 }
118120 void MipsTargetStreamer::emitDirectiveModuleSoftFloat() {}
119121 void MipsTargetStreamer::emitDirectiveModuleHardFloat() {}
122 void MipsTargetStreamer::emitDirectiveModuleMT() {}
120123 void MipsTargetStreamer::emitDirectiveSetFp(
121124 MipsABIFlagsSection::FpABIKind Value) {
122125 forbidModuleDirective();
391394 MipsTargetStreamer::emitDirectiveSetNoMsa();
392395 }
393396
397 void MipsTargetAsmStreamer::emitDirectiveSetMt() {
398 OS << "\t.set\tmt\n";
399 MipsTargetStreamer::emitDirectiveSetMt();
400 }
401
402 void MipsTargetAsmStreamer::emitDirectiveSetNoMt() {
403 OS << "\t.set\tnomt\n";
404 MipsTargetStreamer::emitDirectiveSetNoMt();
405 }
406
394407 void MipsTargetAsmStreamer::emitDirectiveSetAt() {
395408 OS << "\t.set\tat\n";
396409 MipsTargetStreamer::emitDirectiveSetAt();
653666
654667 void MipsTargetAsmStreamer::emitDirectiveModuleHardFloat() {
655668 OS << "\t.module\thardfloat\n";
669 }
670
671 void MipsTargetAsmStreamer::emitDirectiveModuleMT() {
672 OS << "\t.module\tmt\n";
656673 }
657674
658675 // This part is for ELF object output.
3939 virtual void emitDirectiveSetNoMacro();
4040 virtual void emitDirectiveSetMsa();
4141 virtual void emitDirectiveSetNoMsa();
42 virtual void emitDirectiveSetMt();
43 virtual void emitDirectiveSetNoMt();
4244 virtual void emitDirectiveSetAt();
4345 virtual void emitDirectiveSetAtWithArg(unsigned RegNo);
4446 virtual void emitDirectiveSetNoAt();
9597 virtual void emitDirectiveModuleOddSPReg();
9698 virtual void emitDirectiveModuleSoftFloat();
9799 virtual void emitDirectiveModuleHardFloat();
100 virtual void emitDirectiveModuleMT();
98101 virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value);
99102 virtual void emitDirectiveSetOddSPReg();
100103 virtual void emitDirectiveSetNoOddSPReg();
203206 void emitDirectiveSetNoMacro() override;
204207 void emitDirectiveSetMsa() override;
205208 void emitDirectiveSetNoMsa() override;
209 void emitDirectiveSetMt() override;
210 void emitDirectiveSetNoMt() override;
206211 void emitDirectiveSetAt() override;
207212 void emitDirectiveSetAtWithArg(unsigned RegNo) override;
208213 void emitDirectiveSetNoAt() override;
266271 void emitDirectiveModuleOddSPReg() override;
267272 void emitDirectiveModuleSoftFloat() override;
268273 void emitDirectiveModuleHardFloat() override;
274 void emitDirectiveModuleMT() override;
269275 void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override;
270276 void emitDirectiveSetOddSPReg() override;
271277 void emitDirectiveSetNoOddSPReg() override;
0 # RUN: not llvm-mc -arch=mips -mcpu=mips32r5 < %s 2>&1 | FileCheck %s
1
2 # CHECK: error: .module directive must appear before any code
3 .set nomips16
4 .module mt
5 nop
0 # RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=obj -o - | \
1 # RUN: llvm-readobj -mips-abi-flags | FileCheck --check-prefix=CHECK-OBJ %s
2 # RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=asm -o - | \
3 # RUN: FileCheck --check-prefix=CHECK-ASM %s
4
5 # Test that the .module directive sets the MT flag in .MIPS.abiflags when
6 # assembling to boject files.
7
8 # Test that the .moodule directive is re-emitted when expanding assembly.
9
10 # CHECK-OBJ: ASEs
11 # CHECK-OBJ-NEXT: MT (0x40)
12
13 # CHECK-ASM: .module mt
14 .module mt
15 nop
0 # RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=obj -o - | \
1 # RUN: llvm-readobj -mips-abi-flags | FileCheck %s --check-prefix=CHECK-OBJ
2 # RUN: llvm-mc < %s -arch=mips -mcpu=mips32r2 -filetype=asm -o - | \
3 # RUN: FileCheck %s --check-prefix=CHECK-ASM
4
5 # Test that the MT ASE flag in .MIPS.abiflags is _not_ set by .set.
6 # Test that '.set mt' is emitted by the asm target streamer.
7
8 # CHECK-OBJ: ASEs
9 # CHECK-OBJ-NOT: MT (0x40)
10
11 # CHECK-ASM: .set mt
12 .set mt
13 nop