From 0233715d7441fca39634655caca8a17b31514fe1 Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Tue, 19 Nov 2013 20:53:28 +0000 Subject: [PATCH] reverts 195057 per request git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195152 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 36 +++++++++++++++++++ .../Mips/MCTargetDesc/MipsMCTargetDesc.cpp | 2 +- .../Mips/MCTargetDesc/MipsTargetStreamer.cpp | 28 +++++++++++++-- lib/Target/Mips/MipsAsmPrinter.cpp | 4 +-- lib/Target/Mips/MipsTargetStreamer.h | 9 +++-- test/MC/Mips/elf_eflags.ll | 24 ++++++------- test/MC/Mips/elf_eflags.s | 2 +- test/MC/Mips/elf_st_other.ll | 4 +-- test/MC/Mips/elf_st_other.s | 2 -- 9 files changed, 83 insertions(+), 28 deletions(-) diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 6e1402610b3..cdae6c2f37e 100644 --- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -193,6 +193,8 @@ class MipsAsmParser : public MCTargetAsmParser { bool isEvaluated(const MCExpr *Expr); bool parseDirectiveSet(); + bool parseDirectiveMipsHackStocg(); + bool parseDirectiveMipsHackELFFlags(); bool parseSetAtDirective(); bool parseSetNoAtDirective(); @@ -2368,6 +2370,34 @@ bool MipsAsmParser::parseDirectiveSet() { return true; } +bool MipsAsmParser::parseDirectiveMipsHackStocg() { + MCAsmParser &Parser = getParser(); + StringRef Name; + if (Parser.parseIdentifier(Name)) + reportParseError("expected identifier"); + + MCSymbol *Sym = getContext().GetOrCreateSymbol(Name); + if (getLexer().isNot(AsmToken::Comma)) + return TokError("unexpected token"); + Lex(); + + int64_t Flags = 0; + if (Parser.parseAbsoluteExpression(Flags)) + return TokError("unexpected token"); + + getTargetStreamer().emitMipsHackSTOCG(Sym, Flags); + return false; +} + +bool MipsAsmParser::parseDirectiveMipsHackELFFlags() { + int64_t Flags = 0; + if (Parser.parseAbsoluteExpression(Flags)) + return TokError("unexpected token"); + + getTargetStreamer().emitMipsHackELFFlags(Flags); + return false; +} + /// parseDirectiveWord /// ::= .word [ expression (, expression)* ] bool MipsAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) { @@ -2458,6 +2488,12 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) { return false; } + if (IDVal == ".mips_hack_stocg") + return parseDirectiveMipsHackStocg(); + + if (IDVal == ".mips_hack_elf_flags") + return parseDirectiveMipsHackELFFlags(); + return true; } diff --git a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp index c81e9c05e00..5548aaa9a6d 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -141,7 +141,7 @@ createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, bool isVerboseAsm, bool useLoc, bool useCFI, bool useDwarfDirectory, MCInstPrinter *InstPrint, MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) { - MipsTargetAsmStreamer *S = new MipsTargetAsmStreamer(); + MipsTargetAsmStreamer *S = new MipsTargetAsmStreamer(OS); return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI, useDwarfDirectory, InstPrint, CE, TAB, diff --git a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index 04692a53c9e..5e90bbc635a 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -20,11 +20,33 @@ using namespace llvm; +static cl::opt PrintHackDirectives("print-hack-directives", + cl::init(false), cl::Hidden); + // pin vtable to this file void MipsTargetStreamer::anchor() {} -void MipsTargetAsmStreamer::emitMipsHackELFFlags(unsigned Flags) { return; } -void MipsTargetAsmStreamer::emitSymSTO(MCSymbol *Sym, unsigned Val) { return; } +MipsTargetAsmStreamer::MipsTargetAsmStreamer(formatted_raw_ostream &OS) + : OS(OS) {} + +void MipsTargetAsmStreamer::emitMipsHackELFFlags(unsigned Flags) { + if (!PrintHackDirectives) + return; + + OS << "\t.mips_hack_elf_flags 0x"; + OS.write_hex(Flags); + OS << '\n'; +} +void MipsTargetAsmStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) { + if (!PrintHackDirectives) + return; + + OS << "\t.mips_hack_stocg "; + OS << Sym->getName(); + OS << ", "; + OS << Val; + OS << '\n'; +} MCELFStreamer &MipsTargetELFStreamer::getStreamer() { return static_cast(*Streamer); @@ -36,7 +58,7 @@ void MipsTargetELFStreamer::emitMipsHackELFFlags(unsigned Flags) { } // Set a symbol's STO flags -void MipsTargetELFStreamer::emitSymSTO(MCSymbol *Sym, unsigned Val) { +void MipsTargetELFStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) { MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Sym); // The "other" values are stored in the last 6 bits of the second byte // The traditional defines for STO values assume the full byte and thus diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp index f517c0b5f06..45c43982642 100644 --- a/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/lib/Target/Mips/MipsAsmPrinter.cpp @@ -276,8 +276,8 @@ void MipsAsmPrinter::EmitFunctionEntryLabel() { } if (Subtarget->inMicroMipsMode()) - getTargetStreamer().emitSymSTO(CurrentFnSym, - (unsigned)ELF::STO_MIPS_MICROMIPS); + getTargetStreamer().emitMipsHackSTOCG(CurrentFnSym, + (unsigned)ELF::STO_MIPS_MICROMIPS); OutStreamer.EmitLabel(CurrentFnSym); } diff --git a/lib/Target/Mips/MipsTargetStreamer.h b/lib/Target/Mips/MipsTargetStreamer.h index 4edecc4cd11..96966fd7cbc 100644 --- a/lib/Target/Mips/MipsTargetStreamer.h +++ b/lib/Target/Mips/MipsTargetStreamer.h @@ -19,14 +19,17 @@ class MipsTargetStreamer : public MCTargetStreamer { public: virtual void emitMipsHackELFFlags(unsigned Flags) = 0; - virtual void emitSymSTO(MCSymbol *Sym, unsigned Val) = 0; + virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) = 0; }; // This part is for ascii assembly output class MipsTargetAsmStreamer : public MipsTargetStreamer { + formatted_raw_ostream &OS; + public: + MipsTargetAsmStreamer(formatted_raw_ostream &OS); virtual void emitMipsHackELFFlags(unsigned Flags); - virtual void emitSymSTO(MCSymbol *Sym, unsigned Val); + virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val); }; // This part is for ELF object output @@ -34,7 +37,7 @@ class MipsTargetELFStreamer : public MipsTargetStreamer { public: MCELFStreamer &getStreamer(); virtual void emitMipsHackELFFlags(unsigned Flags); - virtual void emitSymSTO(MCSymbol *Sym, unsigned Val); + virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val); }; } diff --git a/test/MC/Mips/elf_eflags.ll b/test/MC/Mips/elf_eflags.ll index 052f4a75d08..9432dcf59c3 100644 --- a/test/MC/Mips/elf_eflags.ll +++ b/test/MC/Mips/elf_eflags.ll @@ -1,5 +1,3 @@ -; XFAIL: * - ; This tests ELF EFLAGS setting with direct object. ; When the assembler is ready a .s file for it will ; be created. @@ -18,19 +16,19 @@ ; Note that EF_MIPS_CPIC is set by -mabicalls which is the default on Linux ; TODO need to support -mno-abicalls -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32 -relocation-model=static %s -o - | FileCheck -check-prefix=CHECK-BE32 %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o - | FileCheck -check-prefix=CHECK-BE32_PIC %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -relocation-model=static %s -o - | FileCheck -check-prefix=CHECK-BE32R2 %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 %s -o - | FileCheck -check-prefix=CHECK-BE32R2_PIC %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+micromips -relocation-model=static %s -o - | FileCheck -check-prefix=CHECK-BE32R2-MICROMIPS %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+micromips %s -o - | FileCheck -check-prefix=CHECK-BE32R2-MICROMIPS_PIC %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32 -relocation-model=static %s -print-hack-directives -o - | FileCheck -check-prefix=CHECK-BE32 %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32 -print-hack-directives %s -o - | FileCheck -check-prefix=CHECK-BE32_PIC %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -relocation-model=static %s -print-hack-directives -o - | FileCheck -check-prefix=CHECK-BE32R2 %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -print-hack-directives %s -o - | FileCheck -check-prefix=CHECK-BE32R2_PIC %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+micromips -relocation-model=static -print-hack-directives %s -o - | FileCheck -check-prefix=CHECK-BE32R2-MICROMIPS %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+micromips -print-hack-directives %s -o - | FileCheck -check-prefix=CHECK-BE32R2-MICROMIPS_PIC %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64 -relocation-model=static %s -o - | FileCheck -check-prefix=CHECK-BE64 %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64 %s -o - | FileCheck -check-prefix=CHECK-BE64_PIC %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64r2 -relocation-model=static %s -o - | FileCheck -check-prefix=CHECK-BE64R2 %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64r2 %s -o - | FileCheck -check-prefix=CHECK-BE64R2_PIC %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64 -relocation-model=static %s -print-hack-directives -o - | FileCheck -check-prefix=CHECK-BE64 %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64 %s -print-hack-directives -o - | FileCheck -check-prefix=CHECK-BE64_PIC %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64r2 -relocation-model=static -print-hack-directives %s -o - | FileCheck -check-prefix=CHECK-BE64R2 %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips64r2 -print-hack-directives %s -o - | FileCheck -check-prefix=CHECK-BE64R2_PIC %s -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+mips16 -relocation-model=pic %s -o - | FileCheck -check-prefix=CHECK-LE32R2-MIPS16 %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+mips16 -relocation-model=pic -print-hack-directives %s -o - | FileCheck -check-prefix=CHECK-LE32R2-MIPS16 %s ; 32(R1) bit with NO_REORDER and static ; CHECK-BE32: .mips_hack_elf_flags 0x50001005 diff --git a/test/MC/Mips/elf_eflags.s b/test/MC/Mips/elf_eflags.s index 67d67a4617b..c56596444ae 100644 --- a/test/MC/Mips/elf_eflags.s +++ b/test/MC/Mips/elf_eflags.s @@ -1,5 +1,5 @@ -; XFAIL: * // RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o -| llvm-readobj -h | FileCheck %s + .mips_hack_elf_flags 0x50001005 // CHECK: Flags [ (0x50001005) diff --git a/test/MC/Mips/elf_st_other.ll b/test/MC/Mips/elf_st_other.ll index 67088b8e192..31294c88f87 100644 --- a/test/MC/Mips/elf_st_other.ll +++ b/test/MC/Mips/elf_st_other.ll @@ -1,9 +1,7 @@ -; XFAIL: * - ; This tests value of ELF st_other field for function symbol table entries. ; For microMIPS value should be equal to STO_MIPS_MICROMIPS. -; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+micromips %s -o - | FileCheck %s +; RUN: llc -mtriple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+micromips -print-hack-directives %s -o - | FileCheck %s define i32 @main() nounwind { entry: diff --git a/test/MC/Mips/elf_st_other.s b/test/MC/Mips/elf_st_other.s index 678bedae085..2d632887799 100644 --- a/test/MC/Mips/elf_st_other.s +++ b/test/MC/Mips/elf_st_other.s @@ -1,5 +1,3 @@ -; XFAIL: * - // RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o -| llvm-readobj -t | FileCheck %s .text -- 2.34.1