diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index 7b10ebd23f2..9448a820bfb 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -807,6 +807,7 @@ enum : unsigned { EF_MIPS_CPIC = 0x00000004, // Call object with Position independent code EF_MIPS_ABI2 = 0x00000020, EF_MIPS_32BITMODE = 0x00000100, + EF_MIPS_NAN2008 = 0x00000400, // Uses IEE 754-2008 NaN encoding EF_MIPS_ABI_O32 = 0x00001000, // This file follows the first MIPS 32 bit ABI //ARCH_ASE diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index e1ebd7661c1..41662d3f973 100644 --- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -144,6 +144,7 @@ class MipsAsmParser : public MCTargetAsmParser { bool isEvaluated(const MCExpr *Expr); bool parseSetFeature(uint64_t Feature); bool parseDirectiveCPSetup(); + bool parseDirectiveNaN(); bool parseDirectiveSet(); bool parseDirectiveOption(); @@ -2383,6 +2384,26 @@ bool MipsAsmParser::parseDirectiveCPSetup() { return false; } +bool MipsAsmParser::parseDirectiveNaN() { + if (getLexer().isNot(AsmToken::EndOfStatement)) { + const AsmToken &Tok = Parser.getTok(); + + if (Tok.getString() == "2008") { + Parser.Lex(); + getTargetStreamer().emitDirectiveNaN2008(); + return false; + } else if (Tok.getString() == "legacy") { + Parser.Lex(); + getTargetStreamer().emitDirectiveNaNLegacy(); + return false; + } + } + // If we don't recognize the option passed to the .nan + // directive (e.g. no option or unknown option), emit an error. + reportParseError("invalid option in .nan directive"); + return false; +} + bool MipsAsmParser::parseDirectiveSet() { // Get the next token. @@ -2566,6 +2587,9 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) { return false; } + if (IDVal == ".nan") + return parseDirectiveNaN(); + if (IDVal == ".gpword") { parseDirectiveGpWord(); return false; diff --git a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index fb6aff2b0df..053e13e5565 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -85,6 +85,13 @@ void MipsTargetAsmStreamer::emitDirectiveEnt(const MCSymbol &Symbol) { } void MipsTargetAsmStreamer::emitDirectiveAbiCalls() { OS << "\t.abicalls\n"; } + +void MipsTargetAsmStreamer::emitDirectiveNaN2008() { OS << "\t.nan\t2008\n"; } + +void MipsTargetAsmStreamer::emitDirectiveNaNLegacy() { + OS << "\t.nan\tlegacy\n"; +} + void MipsTargetAsmStreamer::emitDirectiveOptionPic0() { OS << "\t.option\tpic0\n"; } @@ -180,6 +187,10 @@ MipsTargetELFStreamer::MipsTargetELFStreamer(MCStreamer &S, EFlags |= ELF::EF_MIPS_ABI_O32; } + // Other options. + if (Features & Mips::FeatureNaN2008) + EFlags |= ELF::EF_MIPS_NAN2008; + MCA.setELFHeaderEFlags(EFlags); } @@ -325,6 +336,21 @@ void MipsTargetELFStreamer::emitDirectiveAbiCalls() { Flags |= ELF::EF_MIPS_CPIC | ELF::EF_MIPS_PIC; MCA.setELFHeaderEFlags(Flags); } + +void MipsTargetELFStreamer::emitDirectiveNaN2008() { + MCAssembler &MCA = getStreamer().getAssembler(); + unsigned Flags = MCA.getELFHeaderEFlags(); + Flags |= ELF::EF_MIPS_NAN2008; + MCA.setELFHeaderEFlags(Flags); +} + +void MipsTargetELFStreamer::emitDirectiveNaNLegacy() { + MCAssembler &MCA = getStreamer().getAssembler(); + unsigned Flags = MCA.getELFHeaderEFlags(); + Flags &= ~ELF::EF_MIPS_NAN2008; + MCA.setELFHeaderEFlags(Flags); +} + void MipsTargetELFStreamer::emitDirectiveOptionPic0() { MCAssembler &MCA = getStreamer().getAssembler(); unsigned Flags = MCA.getELFHeaderEFlags(); diff --git a/lib/Target/Mips/Mips.td b/lib/Target/Mips/Mips.td index 7a8198c150d..f0ada2b63fe 100644 --- a/lib/Target/Mips/Mips.td +++ b/lib/Target/Mips/Mips.td @@ -34,6 +34,8 @@ def FeatureGP64Bit : SubtargetFeature<"gp64", "IsGP64bit", "true", "General Purpose Registers are 64-bit wide.">; def FeatureFP64Bit : SubtargetFeature<"fp64", "IsFP64bit", "true", "Support 64-bit FP registers.">; +def FeatureNaN2008 : SubtargetFeature<"nan2008", "IsNaN2008bit", "true", + "IEEE 754-2008 NaN encoding.">; def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat", "true", "Only supports single precision float">; def FeatureO32 : SubtargetFeature<"o32", "MipsABI", "O32", diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp index c9b56aa6352..1ad7e00fdc1 100644 --- a/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/lib/Target/Mips/MipsAsmPrinter.cpp @@ -637,6 +637,12 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) { OutStreamer.SwitchSection(OutContext.getELFSection( SectionName, ELF::SHT_PROGBITS, 0, SectionKind::getDataRel())); + // NaN: At the moment we only support: + // 1. .nan legacy (default) + // 2. .nan 2008 + Subtarget->isNaN2008() ? getTargetStreamer().emitDirectiveNaN2008() + : getTargetStreamer().emitDirectiveNaNLegacy(); + // TODO: handle O64 ABI if (Subtarget->isABI_EABI()) { diff --git a/lib/Target/Mips/MipsSubtarget.cpp b/lib/Target/Mips/MipsSubtarget.cpp index ffc3d2f46df..601467b72e4 100644 --- a/lib/Target/Mips/MipsSubtarget.cpp +++ b/lib/Target/Mips/MipsSubtarget.cpp @@ -77,17 +77,16 @@ void MipsSubtarget::anchor() { } MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU, const std::string &FS, bool little, - Reloc::Model _RM, MipsTargetMachine *_TM) : - MipsGenSubtargetInfo(TT, CPU, FS), - MipsArchVersion(Mips32), MipsABI(UnknownABI), IsLittle(little), - IsSingleFloat(false), IsFP64bit(false), IsGP64bit(false), HasVFPU(false), - HasCnMips(false), IsLinux(true), HasSEInReg(false), HasCondMov(false), - HasSwap(false), HasBitCount(false), HasFPIdx(false), - InMips16Mode(false), InMips16HardFloat(Mips16HardFloat), - InMicroMipsMode(false), HasDSP(false), HasDSPR2(false), - AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16), HasMSA(false), - RM(_RM), OverrideMode(NoOverride), TM(_TM), TargetTriple(TT) -{ + Reloc::Model _RM, MipsTargetMachine *_TM) + : MipsGenSubtargetInfo(TT, CPU, FS), MipsArchVersion(Mips32), + MipsABI(UnknownABI), IsLittle(little), IsSingleFloat(false), + IsFP64bit(false), IsNaN2008bit(false), IsGP64bit(false), HasVFPU(false), + HasCnMips(false), IsLinux(true), HasSEInReg(false), HasCondMov(false), + HasSwap(false), HasBitCount(false), HasFPIdx(false), InMips16Mode(false), + InMips16HardFloat(Mips16HardFloat), InMicroMipsMode(false), HasDSP(false), + HasDSPR2(false), AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16), + HasMSA(false), RM(_RM), OverrideMode(NoOverride), TM(_TM), + TargetTriple(TT) { std::string CPUName = CPU; CPUName = selectMipsCPU(TT, CPUName); diff --git a/lib/Target/Mips/MipsSubtarget.h b/lib/Target/Mips/MipsSubtarget.h index a4246e980b2..c739f91817f 100644 --- a/lib/Target/Mips/MipsSubtarget.h +++ b/lib/Target/Mips/MipsSubtarget.h @@ -56,6 +56,9 @@ protected: // IsFP64bit - The target processor has 64-bit floating point registers. bool IsFP64bit; + // IsNan2008 - IEEE 754-2008 NaN encoding. + bool IsNaN2008bit; + // IsFP64bit - General-purpose registers are 64 bits wide bool IsGP64bit; @@ -158,6 +161,7 @@ public: bool isLittle() const { return IsLittle; } bool isFP64bit() const { return IsFP64bit; } + bool isNaN2008() const { return IsNaN2008bit; } bool isNotFP64bit() const { return !IsFP64bit; } bool isGP64bit() const { return IsGP64bit; } bool isGP32bit() const { return !IsGP64bit; } diff --git a/lib/Target/Mips/MipsTargetStreamer.h b/lib/Target/Mips/MipsTargetStreamer.h index 5f4b74b3ba0..198888cf526 100644 --- a/lib/Target/Mips/MipsTargetStreamer.h +++ b/lib/Target/Mips/MipsTargetStreamer.h @@ -34,6 +34,8 @@ public: virtual void emitDirectiveEnt(const MCSymbol &Symbol) = 0; virtual void emitDirectiveAbiCalls() = 0; + virtual void emitDirectiveNaN2008() = 0; + virtual void emitDirectiveNaNLegacy() = 0; virtual void emitDirectiveOptionPic0() = 0; virtual void emitDirectiveOptionPic2() = 0; virtual void emitFrame(unsigned StackReg, unsigned StackSize, @@ -68,6 +70,8 @@ public: virtual void emitDirectiveEnt(const MCSymbol &Symbol); virtual void emitDirectiveAbiCalls(); + virtual void emitDirectiveNaN2008(); + virtual void emitDirectiveNaNLegacy(); virtual void emitDirectiveOptionPic0(); virtual void emitDirectiveOptionPic2(); virtual void emitFrame(unsigned StackReg, unsigned StackSize, @@ -111,6 +115,8 @@ public: virtual void emitDirectiveEnt(const MCSymbol &Symbol); virtual void emitDirectiveAbiCalls(); + virtual void emitDirectiveNaN2008(); + virtual void emitDirectiveNaNLegacy(); virtual void emitDirectiveOptionPic0(); virtual void emitDirectiveOptionPic2(); virtual void emitFrame(unsigned StackReg, unsigned StackSize, diff --git a/test/CodeGen/Mips/start-asm-file.ll b/test/CodeGen/Mips/start-asm-file.ll new file mode 100644 index 00000000000..88724643166 --- /dev/null +++ b/test/CodeGen/Mips/start-asm-file.ll @@ -0,0 +1,91 @@ +; Check the emission of directives at the start of an asm file. +; This test is XFAILED until we fix the emission of '.option pic0' on +; N32. At the moment we check if subtarget is Mips64 when we should be +; checking the Subtarget's ABI. + +; ### O32 ABI ### +; RUN: llc -filetype=asm -mtriple mips-unknown-linux -mcpu=mips32 \ +; RUN: -relocation-model=static %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-STATIC-O32 -check-prefix=CHECK-STATIC-O32-NLEGACY %s + +; RUN: llc -filetype=asm -mtriple mips-unknown-linux -mcpu=mips32 \ +; RUN: -relocation-model=pic %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-PIC-O32 -check-prefix=CHECK-PIC-O32-NLEGACY %s + +; RUN: llc -filetype=asm -mtriple mips-unknown-linux -mcpu=mips32 \ +; RUN: -relocation-model=static -mattr=+nan2008 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-STATIC-O32 -check-prefix=CHECK-STATIC-O32-N2008 %s + +; RUN: llc -filetype=asm -mtriple mips-unknown-linux -mcpu=mips32 \ +; RUN: -relocation-model=pic -mattr=+nan2008 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-PIC-O32 -check-prefix=CHECK-PIC-O32-N2008 %s + +; ### N32 ABI ### +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=static -mattr=-n64,+n32 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-STATIC-N32 -check-prefix=CHECK-STATIC-N32-NLEGACY %s + +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=pic -mattr=-n64,+n32 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-PIC-N32 -check-prefix=CHECK-PIC-N32-NLEGACY %s + +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=static -mattr=-n64,+n32,+nan2008 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-STATIC-N32 -check-prefix=CHECK-STATIC-N32-N2008 %s + +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=pic -mattr=-n64,+n32,+nan2008 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-PIC-N32 -check-prefix=CHECK-PIC-N32-N2008 %s + +; ### N64 ABI ### +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=static -mattr=+n64 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-STATIC-N64 -check-prefix=CHECK-STATIC-N64-NLEGACY %s + +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=pic -mattr=+n64 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-PIC-N64 -check-prefix=CHECK-PIC-N64-NLEGACY %s + +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=static -mattr=+n64,+nan2008 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-STATIC-N64 -check-prefix=CHECK-STATIC-N64-N2008 %s + +; RUN: llc -filetype=asm -mtriple mips64-unknown-linux -mcpu=mips64 \ +; RUN: -relocation-model=pic -mattr=+n64,+nan2008 %s -o - | \ +; RUN: FileCheck -check-prefix=CHECK-PIC-N64 -check-prefix=CHECK-PIC-N64-N2008 %s + +; CHECK-STATIC-O32: .abicalls +; CHECK-STATIC-O32: .option pic0 +; CHECK-STATIC-O32: .section .mdebug.abi32 +; CHECK-STATIC-O32-NLEGACY: .nan legacy +; CHECK-STATIC-O32-N2008: .nan 2008 + +; CHECK-PIC-O32: .abicalls +; CHECK-PIC-O32-NOT: .option pic0 +; CHECK-PIC-O32: .section .mdebug.abi32 +; CHECK-PIC-O32-NLEGACY: .nan legacy +; CHECK-PIC-O32-N2008: .nan 2008 + +; CHECK-STATIC-N32: .abicalls +; CHECK-STATIC-N32: .option pic0 +; CHECK-STATIC-N32: .section .mdebug.abiN32 +; CHECK-STATIC-N32-NLEGACY: .nan legacy +; CHECK-STATIC-N32-N2008: .nan 2008 + +; CHECK-PIC-N32: .abicalls +; CHECK-PIC-N32-NOT: .option pic0 +; CHECK-PIC-N32: .section .mdebug.abiN32 +; CHECK-PIC-N32-NLEGACY: .nan legacy +; CHECK-PIC-N32-N2008: .nan 2008 + +; CHECK-STATIC-N64: .abicalls +; CHECK-STATIC-N64-NOT: .option pic0 +; CHECK-STATIC-N64: .section .mdebug.abi64 +; CHECK-STATIC-N64-NLEGACY: .nan legacy +; CHECK-STATIC-N64-N2008: .nan 2008 + +; CHECK-PIC-N64: .abicalls +; CHECK-PIC-N64-NOT: .option pic0 +; CHECK-PIC-N64: .section .mdebug.abi64 +; CHECK-PIC-N64-NLEGACY: .nan legacy +; CHECK-PIC-N64-N2008: .nan 2008 diff --git a/test/MC/Mips/elf_eflags.s b/test/MC/Mips/elf_eflags.s index c789428b423..8cf4960e174 100644 --- a/test/MC/Mips/elf_eflags.s +++ b/test/MC/Mips/elf_eflags.s @@ -4,40 +4,79 @@ # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64R2 %s # MIPSEL-MIPS64R2: Flags [ (0x80001100) +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64R2-NAN2008 %s +# MIPSEL-MIPS64R2-NAN2008: Flags [ (0x80001500) + # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64 %s # MIPSEL-MIPS64: Flags [ (0x60001100) +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS64-NAN2008 %s +# MIPSEL-MIPS64-NAN2008: Flags [ (0x60001500) + # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r2 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS32R2 %s # MIPSEL-MIPS32R2: Flags [ (0x70001000) +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS32R2-NAN2008 %s +# MIPSEL-MIPS32R2-NAN2008: Flags [ (0x70001400) + # RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS32 %s # MIPSEL-MIPS32: Flags [ (0x50001000) +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPSEL-MIPS32-NAN2008 %s +# MIPSEL-MIPS32-NAN2008: Flags [ (0x50001400) + # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=-n64,n32 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-N32 %s # MIPS64EL-MIPS64R2-N32: Flags [ (0x80000020) +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=-n64,n32,+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-N32-NAN2008 %s +# MIPS64EL-MIPS64R2-N32-NAN2008: Flags [ (0x80000420) + # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 -mattr=-n64,n32 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64-N32 %s # MIPS64EL-MIPS64-N32: Flags [ (0x60000020) +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 -mattr=-n64,n32,+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64-N32-NAN2008 %s +# MIPS64EL-MIPS64-N32-NAN2008: Flags [ (0x60000420) + # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=n64 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-N64 %s # MIPS64EL-MIPS64R2-N64: Flags [ (0x80000000) +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=n64,+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-N64-NAN2008 %s +# MIPS64EL-MIPS64R2-N64-NAN2008: Flags [ (0x80000400) + # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 %s -mattr=n64 -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64-N64 %s # MIPS64EL-MIPS64-N64: Flags [ (0x60000000) +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 %s -mattr=n64,+nan2008 -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64-N64-NAN2008 %s +# MIPS64EL-MIPS64-N64-NAN2008: Flags [ (0x60000400) + # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=-n64,o32 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-O32 %s # MIPS64EL-MIPS64R2-O32: Flags [ (0x80001100) +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=-n64,o32,+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-O32-NAN2008 %s +# MIPS64EL-MIPS64R2-O32-NAN2008: Flags [ (0x80001500) + # RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS4 %s # MIPS4: Flags [ (0x30000000) + # RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS4-NAN2008 %s +# MIPS4-NAN2008: Flags [ (0x30000400) + # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 %s -mattr=-n64,o32 -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64-O32 %s # MIPS64EL-MIPS64-O32: Flags [ (0x60001100) - + +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 %s -mattr=-n64,o32,+nan2008 -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64-O32-NAN2008 %s +# MIPS64EL-MIPS64-O32-NAN2008: Flags [ (0x60001500) + # Default ABI for MIPS64 is N64 as opposed to GCC/GAS (N32) # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2 %s # MIPS64EL-MIPS64R2: Flags [ (0x80000000) +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64R2-NAN2008 %s +# MIPS64EL-MIPS64R2-NAN2008: Flags [ (0x80000400) + # Default ABI for MIPS64 is N64 as opposed to GCC/GAS (N32) # RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64 %s # MIPS64EL-MIPS64: Flags [ (0x60000000) + +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64 -mattr=+nan2008 %s -o -| llvm-readobj -h | FileCheck --check-prefix=MIPS64EL-MIPS64-NAN2008 %s +# MIPS64EL-MIPS64-NAN2008: Flags [ (0x60000400) diff --git a/test/MC/Mips/elf_eflags_nan2008.s b/test/MC/Mips/elf_eflags_nan2008.s new file mode 100644 index 00000000000..71a22be2b41 --- /dev/null +++ b/test/MC/Mips/elf_eflags_nan2008.s @@ -0,0 +1,12 @@ +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 %s -o - | \ +# RUN: llvm-readobj -h | \ +# RUN: FileCheck %s -check-prefix=CHECK-OBJ +# RUN: llvm-mc -triple mipsel-unknown-linux -mcpu=mips32 %s -o -| \ +# RUN: FileCheck %s -check-prefix=CHECK-ASM + +# This *MUST* match the output of gas compiled with the same triple. +# CHECK-OBJ: Flags [ (0x50001400) + +# CHECK-ASM: .nan 2008 + +.nan 2008 diff --git a/test/MC/Mips/elf_eflags_nanlegacy.s b/test/MC/Mips/elf_eflags_nanlegacy.s new file mode 100644 index 00000000000..6897ad2bda4 --- /dev/null +++ b/test/MC/Mips/elf_eflags_nanlegacy.s @@ -0,0 +1,15 @@ +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32 %s -o - | \ +# RUN: llvm-readobj -h | \ +# RUN: FileCheck %s -check-prefix=CHECK-OBJ +# RUN: llvm-mc -triple mipsel-unknown-linux -mcpu=mips32 %s -o -| \ +# RUN: FileCheck %s -check-prefix=CHECK-ASM + +# This *MUST* match the output of gas compiled with the same triple. +# CHECK-OBJ: Flags [ (0x50001000) + +# CHECK-ASM: .nan 2008 +# CHECK-ASM: .nan legacy + +.nan 2008 +// Let's override the previous directive! +.nan legacy