[llvm] r199851 - [Mips] TargetStreamer Support for .set mips16.
Jack Carter
Jack.Carter at imgtec.com
Fri Jan 24 10:43:33 PST 2014
Missed that.
Yes, I prefer the one with the bool.
Thanks,
Jack
________________________________________
From: Rafael EspĂndola [rafael.espindola at gmail.com]
Sent: Friday, January 24, 2014 7:17 AM
To: Jack Carter
Cc: llvm-commits
Subject: Re: [llvm] r199851 - [Mips] TargetStreamer Support for .set mips16.
With this you now have:
virtual void emitDirectiveSetMips16();
virtual void emitDirectiveSetNoMips16();
....
virtual void emitDirectiveSetMips16(bool IsMips16);
You should probably delete the first two if you prefer the version
with the bool.
On 22 January 2014 18:08, Jack Carter <jack.carter at imgtec.com> wrote:
> Author: jacksprat
> Date: Wed Jan 22 17:08:42 2014
> New Revision: 199851
>
> URL: http://llvm.org/viewvc/llvm-project?rev=199851&view=rev
> Log:
> [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.
>
> 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/elf_eflags.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=199851&r1=199850&r2=199851&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed Jan 22 17:08:42 2014
> @@ -203,6 +203,8 @@ class MipsAsmParser : public MCTargetAsm
> bool parseSetNoMacroDirective();
> bool parseSetReorderDirective();
> bool parseSetNoReorderDirective();
> + bool parseSetMips16Directive();
> + bool parseSetNoMips16Directive();
>
> bool parseSetAssignment();
>
> @@ -2341,6 +2343,30 @@ bool MipsAsmParser::parseSetNoMacroDirec
> return false;
> }
>
> +bool MipsAsmParser::parseSetMips16Directive() {
> + Parser.Lex();
> + // If this is not the end of the statement, report an error.
> + if (getLexer().isNot(AsmToken::EndOfStatement)) {
> + reportParseError("unexpected token in statement");
> + return false;
> + }
> + getTargetStreamer().emitDirectiveSetMips16(true);
> + Parser.Lex(); // Consume the EndOfStatement.
> + return false;
> +}
> +
> +bool MipsAsmParser::parseSetNoMips16Directive() {
> + Parser.Lex();
> + // If this is not the end of the statement, report an error.
> + if (getLexer().isNot(AsmToken::EndOfStatement)) {
> + reportParseError("unexpected token in statement");
> + return false;
> + }
> + // For now do nothing.
> + Parser.Lex(); // Consume the EndOfStatement.
> + return false;
> +}
> +
> bool MipsAsmParser::parseSetAssignment() {
> StringRef Name;
> const MCExpr *Value;
> @@ -2382,10 +2408,10 @@ bool MipsAsmParser::parseDirectiveSet()
> return parseSetMacroDirective();
> } else if (Tok.getString() == "nomacro") {
> return parseSetNoMacroDirective();
> + } else if (Tok.getString() == "mips16") {
> + return parseSetMips16Directive();
> } else if (Tok.getString() == "nomips16") {
> - // Ignore this directive for now.
> - Parser.eatToEndOfStatement();
> - return false;
> + return parseSetNoMips16Directive();
> } else if (Tok.getString() == "nomicromips") {
> getTargetStreamer().emitDirectiveSetNoMicroMips();
> Parser.eatToEndOfStatement();
>
> 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=199851&r1=199850&r2=199851&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Wed Jan 22 17:08:42 2014
> @@ -63,6 +63,12 @@ void MipsTargetAsmStreamer::emitDirectiv
> void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
> OS << "\t.option\tpic0\n";
> }
> +void MipsTargetAsmStreamer::emitDirectiveSetMips16(bool IsMips16) {
> + if (IsMips16)
> + OS << "\t.set\tmips16\n";
> + else
> + OS << "\t.set\tnomips16\n";
> +}
>
> // This part is for ELF object output.
> MipsTargetELFStreamer::MipsTargetELFStreamer() : MicroMipsEnabled(false) {}
> @@ -122,3 +128,13 @@ void MipsTargetELFStreamer::emitDirectiv
> Flags &= ~ELF::EF_MIPS_PIC;
> MCA.setELFHeaderEFlags(Flags);
> }
> +void MipsTargetELFStreamer::emitDirectiveSetMips16(bool IsMips16) {
> + // Don't do anything for .set nomips16
> + if (!IsMips16)
> + return;
> +
> + MCAssembler &MCA = getStreamer().getAssembler();
> + unsigned Flags = MCA.getELFHeaderEFlags();
> + Flags |= ELF::EF_MIPS_ARCH_ASE_M16;
> + MCA.setELFHeaderEFlags(Flags);
> +}
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h?rev=199851&r1=199850&r2=199851&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h Wed Jan 22 17:08:42 2014
> @@ -26,6 +26,7 @@ public:
> virtual void emitDirectiveEnt(const MCSymbol &Symbol) = 0;
> virtual void emitDirectiveAbiCalls() = 0;
> virtual void emitDirectiveOptionPic0() = 0;
> + virtual void emitDirectiveSetMips16(bool IsMips16) = 0;
> };
>
> // This part is for ascii assembly output
> @@ -42,11 +43,13 @@ public:
> virtual void emitDirectiveEnt(const MCSymbol &Symbol);
> virtual void emitDirectiveAbiCalls();
> virtual void emitDirectiveOptionPic0();
> + virtual void emitDirectiveSetMips16(bool IsMips16);
> };
>
> // This part is for ELF object output
> class MipsTargetELFStreamer : public MipsTargetStreamer {
> bool MicroMipsEnabled;
> +
> public:
> bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
> MCELFStreamer &getStreamer();
> @@ -63,6 +66,7 @@ public:
> virtual void emitDirectiveEnt(const MCSymbol &Symbol);
> virtual void emitDirectiveAbiCalls();
> virtual void emitDirectiveOptionPic0();
> + virtual void emitDirectiveSetMips16(bool IsMips16);
> };
> }
> #endif
>
> Modified: llvm/trunk/test/MC/Mips/elf_eflags.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf_eflags.s?rev=199851&r1=199850&r2=199851&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/Mips/elf_eflags.s (original)
> +++ llvm/trunk/test/MC/Mips/elf_eflags.s Wed Jan 22 17:08:42 2014
> @@ -5,8 +5,11 @@
>
> .mips_hack_elf_flags 0x50001003
>
> -// CHECK: Flags [ (0x50001005)
> +// CHECK: Flags [ (0x54001005)
>
> .abicalls
>
> .option pic0
> +
> + // Set EF_MIPS_ARCH_ASE_M16 (0x04000000)
> + .set mips16
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list