llvm.org GIT mirror llvm / 2ccf523
[Mips] TargetStreamer Support for .set mips16. This patch updates .set mips16 support which affects the ELF ABI and its flags. In addition the patch uses a common interface for both the MipsTargetSteamer and MipsObjectStreamer that the assembler uses for both ELF and ASCII output for these directives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199851 91177308-0d34-0410-b5e6-96231b3b80d8 Jack Carter 6 years ago
4 changed file(s) with 53 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
202202 bool parseSetNoMacroDirective();
203203 bool parseSetReorderDirective();
204204 bool parseSetNoReorderDirective();
205 bool parseSetMips16Directive();
206 bool parseSetNoMips16Directive();
205207
206208 bool parseSetAssignment();
207209
23402342 return false;
23412343 }
23422344
2345 bool MipsAsmParser::parseSetMips16Directive() {
2346 Parser.Lex();
2347 // If this is not the end of the statement, report an error.
2348 if (getLexer().isNot(AsmToken::EndOfStatement)) {
2349 reportParseError("unexpected token in statement");
2350 return false;
2351 }
2352 getTargetStreamer().emitDirectiveSetMips16(true);
2353 Parser.Lex(); // Consume the EndOfStatement.
2354 return false;
2355 }
2356
2357 bool MipsAsmParser::parseSetNoMips16Directive() {
2358 Parser.Lex();
2359 // If this is not the end of the statement, report an error.
2360 if (getLexer().isNot(AsmToken::EndOfStatement)) {
2361 reportParseError("unexpected token in statement");
2362 return false;
2363 }
2364 // For now do nothing.
2365 Parser.Lex(); // Consume the EndOfStatement.
2366 return false;
2367 }
2368
23432369 bool MipsAsmParser::parseSetAssignment() {
23442370 StringRef Name;
23452371 const MCExpr *Value;
23812407 return parseSetMacroDirective();
23822408 } else if (Tok.getString() == "nomacro") {
23832409 return parseSetNoMacroDirective();
2410 } else if (Tok.getString() == "mips16") {
2411 return parseSetMips16Directive();
23842412 } else if (Tok.getString() == "nomips16") {
2385 // Ignore this directive for now.
2386 Parser.eatToEndOfStatement();
2387 return false;
2413 return parseSetNoMips16Directive();
23882414 } else if (Tok.getString() == "nomicromips") {
23892415 getTargetStreamer().emitDirectiveSetNoMicroMips();
23902416 Parser.eatToEndOfStatement();
6262 void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
6363 OS << "\t.option\tpic0\n";
6464 }
65 void MipsTargetAsmStreamer::emitDirectiveSetMips16(bool IsMips16) {
66 if (IsMips16)
67 OS << "\t.set\tmips16\n";
68 else
69 OS << "\t.set\tnomips16\n";
70 }
6571
6672 // This part is for ELF object output.
6773 MipsTargetELFStreamer::MipsTargetELFStreamer() : MicroMipsEnabled(false) {}
121127 Flags &= ~ELF::EF_MIPS_PIC;
122128 MCA.setELFHeaderEFlags(Flags);
123129 }
130 void MipsTargetELFStreamer::emitDirectiveSetMips16(bool IsMips16) {
131 // Don't do anything for .set nomips16
132 if (!IsMips16)
133 return;
134
135 MCAssembler &MCA = getStreamer().getAssembler();
136 unsigned Flags = MCA.getELFHeaderEFlags();
137 Flags |= ELF::EF_MIPS_ARCH_ASE_M16;
138 MCA.setELFHeaderEFlags(Flags);
139 }
2525 virtual void emitDirectiveEnt(const MCSymbol &Symbol) = 0;
2626 virtual void emitDirectiveAbiCalls() = 0;
2727 virtual void emitDirectiveOptionPic0() = 0;
28 virtual void emitDirectiveSetMips16(bool IsMips16) = 0;
2829 };
2930
3031 // This part is for ascii assembly output
4142 virtual void emitDirectiveEnt(const MCSymbol &Symbol);
4243 virtual void emitDirectiveAbiCalls();
4344 virtual void emitDirectiveOptionPic0();
45 virtual void emitDirectiveSetMips16(bool IsMips16);
4446 };
4547
4648 // This part is for ELF object output
4749 class MipsTargetELFStreamer : public MipsTargetStreamer {
4850 bool MicroMipsEnabled;
51
4952 public:
5053 bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
5154 MCELFStreamer &getStreamer();
6265 virtual void emitDirectiveEnt(const MCSymbol &Symbol);
6366 virtual void emitDirectiveAbiCalls();
6467 virtual void emitDirectiveOptionPic0();
68 virtual void emitDirectiveSetMips16(bool IsMips16);
6569 };
6670 }
6771 #endif
44
55 .mips_hack_elf_flags 0x50001003
66
7 // CHECK: Flags [ (0x50001005)
7 // CHECK: Flags [ (0x54001005)
88
99 .abicalls
1010
1111 .option pic0
12
13 // Set EF_MIPS_ARCH_ASE_M16 (0x04000000)
14 .set mips16