Index: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h +++ lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h @@ -30,11 +30,12 @@ class MipsAsmBackend : public MCAsmBackend { Triple TheTriple; bool IsLittle; // Big or little endian + bool IsN32; public: MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, - StringRef CPU) - : TheTriple(TT), IsLittle(TT.isLittleEndian()) {} + StringRef CPU, bool N32) + : TheTriple(TT), IsLittle(TT.isLittleEndian()), IsN32(N32) {} MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override; Index: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -24,6 +24,7 @@ #include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/MC/MCTargetOptions.h" #include "llvm/MC/MCValue.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" @@ -211,7 +212,7 @@ MCObjectWriter * MipsAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const { - return createMipsELFObjectWriter(OS, TheTriple); + return createMipsELFObjectWriter(OS, TheTriple, IsN32); } // Little-endian fixup data byte ordering: @@ -473,3 +474,10 @@ OW->WriteZeros(Count); return true; } + +MCAsmBackend *llvm::createMipsAsmBackend(const Target &T, + const MCRegisterInfo &MRI, + const Triple &TT, StringRef CPU, + const MCTargetOptions &Options) { + return new MipsAsmBackend(T, MRI, TT, CPU, Options.ABIName == "n32"); +} Index: lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -657,12 +657,10 @@ } MCObjectWriter *llvm::createMipsELFObjectWriter(raw_pwrite_stream &OS, - const Triple &TT) { + const Triple &TT, bool IsN32) { uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS()); - // FIXME: We need to check an actual ABI. mips64/mips64el do not - // always imply the N64 ABI and RELA relocation's format. - bool IsN64 = TT.isArch64Bit(); - bool HasRelocationAddend = IsN64; + bool IsN64 = TT.isArch64Bit() && !IsN32; + bool HasRelocationAddend = TT.isArch64Bit(); auto *MOTW = new MipsELFObjectWriter(OSABI, HasRelocationAddend, IsN64, TT.isLittleEndian()); return createELFObjectWriter(MOTW, OS, TT.isLittleEndian()); Index: lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h +++ lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h @@ -43,8 +43,12 @@ const MCRegisterInfo &MRI, MCContext &Ctx); +MCAsmBackend *createMipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, + const Triple &TT, StringRef CPU, + const MCTargetOptions &Options); + MCObjectWriter *createMipsELFObjectWriter(raw_pwrite_stream &OS, - const Triple &TT); + const Triple &TT, bool IsN32); namespace MIPS_MC { StringRef selectMipsCPU(const Triple &TT, StringRef CPU); Index: lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -183,7 +183,7 @@ *T, createMipsObjectTargetStreamer); // Register the asm backend. - RegisterMCAsmBackend Y(*T); + TargetRegistry::RegisterMCAsmBackend(*T, createMipsAsmBackend); } // Register the MC Code Emitter Index: test/MC/Mips/cpsetup.s =================================================================== --- test/MC/Mips/cpsetup.s +++ test/MC/Mips/cpsetup.s @@ -4,6 +4,8 @@ # RUN: llvm-mc -triple mips-unknown-linux -target-abi o32 %s | \ # RUN: FileCheck -check-prefixes=ALL,ASM,ASM-O32 %s +# FIXME: Now we check .cpsetup expansion for `-mno-shared` case only. +# We also need to implement/check the `-mshared` case. # RUN: llvm-mc -triple mips64-unknown-linux -target-abi n32 -filetype=obj -o - %s | \ # RUN: llvm-objdump -d -r - | \ # RUN: FileCheck -check-prefixes=ALL,NXX,N32 %s @@ -32,10 +34,10 @@ # NXX-NEXT: sd $gp, 8($sp) # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror # NXX-NEXT: addiu $gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror # N64-NEXT: daddu $gp, $gp, $25 @@ -60,10 +62,10 @@ # NXX-NEXT: move $2, $gp # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror # NXX-NEXT: addiu $gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror # N64-NEXT: daddu $gp, $gp, $25 @@ -96,10 +98,10 @@ # NXX-NEXT: move $2, $gp # NXX-NEXT: lui $gp, 0 -# N32-NEXT: {{^ *0+}}38: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: {{^ *0+}}38: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: {{^ *0+}}40: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 .text # NXX-NEXT: addiu $gp, $gp, 0 -# N32-NEXT: {{^ *0+}}3c: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: {{^ *0+}}3c: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: {{^ *0+}}44: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 .text # N64-NEXT: daddu $gp, $gp, $25 # NXX-NEXT: nop @@ -151,10 +153,10 @@ # NXX-NEXT: sd $gp, 8($sp) # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror # NXX-NEXT: addiu $gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror # N64-NEXT: daddu $gp, $gp, $25 @@ -176,10 +178,10 @@ # NXX-NEXT: sd $gp, 8($sp) # NXX-NEXT: lui $gp, 0 -# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_HI16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 __cerror # NXX-NEXT: addiu $gp, $gp, 0 -# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp +# N32-NEXT: R_MIPS_LO16 __gnu_local_gp # N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 __cerror # N64-NEXT: daddu $gp, $gp, $25 Index: test/MC/Mips/elf_header.s =================================================================== --- /dev/null +++ test/MC/Mips/elf_header.s @@ -0,0 +1,136 @@ +# Default ABI for MIPS32 is O32. +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips1 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS1 %s +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips2 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS2 %s +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips3 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS3,32BITMODE %s +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips4 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS4,32BITMODE %s +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips5 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS5,32BITMODE %s +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS32R1 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r2 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R2 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r3 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R3 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r5 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R5 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r2 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R2 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r3 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R3 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r5 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R5 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips32r6 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R6 %s + +# Selected ABI O32 takes precedence over target triple. +# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips1 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS1 %s +# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips2 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS2 %s +# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips3 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS3,32BITMODE %s +# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS4,32BITMODE %s +# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips5 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS5,32BITMODE %s +# FIXME: llvm-mc -filetype=obj -triple mips64-unknown-linux -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,O32,NAN1985,MIPS32R1 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R1 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r2 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R2 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r3 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R3 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r5 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN1985,MIPS32R5 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r2 -target-abi=o32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R2 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r3 -target-abi=o32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R3 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r5 -target-abi=o32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R5 %s +# FIXME: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips32r6 -target-abi=o32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,O32,NAN2008,MIPS32R6 %s + +# Default ABI for MIPS64 is N64 as opposed to GCC/GAS (N32). +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS3 %s +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips4 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS4 %s +# RUN: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS5 %s +# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS64R1 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R1 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R2 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R3 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R5 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R2 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R3 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R5 %s +# RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r6 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R6 %s +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS3 %s +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS4 %s +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS5 %s +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,BE,N32,NAN1985,MIPS64R1 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R1 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R2 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R3 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN1985,MIPS64R5 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R2 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R3 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 -target-abi=n32 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R5 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r6 -target-abi=n32 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF32,LE,N32,NAN2008,MIPS64R6 %s + +# Default ABI for MIPS64 is N64 as opposed to GCC/GAS (N32). +# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips3 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS3 %s +# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips4 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS4 %s +# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -mcpu=mips5 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS5 %s +# FIXME: llvm-mc -filetype=obj -triple mips-unknown-linux -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS64R1 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R1 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R2 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R3 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R5 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r2 -target-abi=n64 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R2 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r3 -target-abi=n64 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R3 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r5 -target-abi=n64 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R5 %s +# FIXME: llvm-mc -filetype=obj -triple mipsel-unknown-linux -mcpu=mips64r6 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R6 %s +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips3 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS3 %s +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips4 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS4 %s +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux -mcpu=mips5 -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS5 %s + +# RUN: llvm-mc -filetype=obj -triple mips64-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,BE,N64,NAN1985,MIPS64R1 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R1 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R2 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R3 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,MIPS64R5 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r2 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R2 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r3 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R3 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r5 -mattr=+nan2008 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R5 %s +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=mips64r6 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN2008,MIPS64R6 %s + +# RUN: llvm-mc -filetype=obj -triple mips64el-unknown-linux -mcpu=octeon -target-abi=n64 %s -o - | llvm-readobj -h | FileCheck --check-prefixes=ALL,ELF64,LE,N64,NAN1985,OCTEON %s + +# ALL: ElfHeader { +# ALL-NEXT: Ident { +# ALL-NEXT: Magic: (7F 45 4C 46) +# ELF32-NEXT: Class: 32-bit (0x1) +# ELF64-NEXT: Class: 64-bit (0x2) +# LE-NEXT: DataEncoding: LittleEndian (0x1) +# BE-NEXT: DataEncoding: BigEndian (0x2) +# ALL-NEXT: FileVersion: 1 +# ALL-NEXT: OS/ABI: SystemV (0x0) +# ALL-NEXT: ABIVersion: 0 +# ALL-NEXT: Unused: (00 00 00 00 00 00 00) +# ALL-NEXT: } +# ALL-NEXT: Type: Relocatable (0x1) +# ALL-NEXT: Machine: EM_MIPS (0x8) +# ALL-NEXT: Version: 1 +# ALL-NEXT: Entry: 0x0 +# ALL-NEXT: ProgramHeaderOffset: 0x0 +# ALL-NEXT: SectionHeaderOffset: +# ALL-NEXT: Flags [ +# 32BITMODE-NEXT: EF_MIPS_32BITMODE (0x100) +# N32-NEXT: EF_MIPS_ABI2 (0x20) +# O32-NEXT: EF_MIPS_ABI_O32 (0x1000) + +# MIPS2-NEXT: EF_MIPS_ARCH_2 (0x10000000) +# MIPS3-NEXT: EF_MIPS_ARCH_3 (0x20000000) +# MIPS4-NEXT: EF_MIPS_ARCH_4 (0x30000000) +# MIPS5-NEXT: EF_MIPS_ARCH_5 (0x40000000) +# MIPS32R1-NEXT: EF_MIPS_ARCH_32 (0x50000000) +# MIPS32R2-NEXT: EF_MIPS_ARCH_32R2 (0x70000000) +# The R2 flag is reused for R3 and R5. +# MIPS32R3-NEXT: EF_MIPS_ARCH_32R2 (0x70000000) +# MIPS32R5-NEXT: EF_MIPS_ARCH_32R2 (0x70000000) +# MIPS32R6-NEXT: EF_MIPS_ARCH_32R6 (0x90000000) +# MIPS64R1-NEXT: EF_MIPS_ARCH_64 (0x60000000) +# MIPS64R2-NEXT: EF_MIPS_ARCH_64R2 (0x80000000) +# The R2 flag is reused for R3 and R5. +# MIPS64R3-NEXT: EF_MIPS_ARCH_64R2 (0x80000000) +# MIPS64R5-NEXT: EF_MIPS_ARCH_64R2 (0x80000000) +# MIPS64R6-NEXT: EF_MIPS_ARCH_64R6 (0xA0000000) +# OCTEON-NEXT: EF_MIPS_ARCH_64R2 (0x80000000) + +# ALL-NEXT: EF_MIPS_CPIC (0x4) + +# OCTEON-NEXT: EF_MIPS_MACH_OCTEON (0x8B0000) + +# NAN2008-NEXT: EF_MIPS_NAN2008 (0x400) +# ALL-NEXT: ] Index: test/MC/Mips/expansion-j-sym-pic.s =================================================================== --- test/MC/Mips/expansion-j-sym-pic.s +++ test/MC/Mips/expansion-j-sym-pic.s @@ -21,9 +21,9 @@ # RUN: llvm-mc %s -arch=mips -mcpu=mips32 -filetype=obj | \ # RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-O32 # RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n32 -filetype=obj | \ -# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX +# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX,ELF-N32 # RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -filetype=obj | \ -# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX +# RUN: llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-NXX,ELF-N64 .weak weak_label @@ -61,7 +61,8 @@ # ELF-O32-NEXT: R_MIPS_PC16 weak_label # ELF-NXX: 10 00 00 00 b 4 -# ELF-NXX-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE weak_label +# ELF-N32-NEXT: R_MIPS_PC16 weak_label +# ELF-N64-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE weak_label j global_label nop @@ -76,7 +77,8 @@ # ELF-O32-NEXT: 00000010: R_MIPS_PC16 global_label # ELF-NXX: 10 00 00 00 b 4 -# ELF-NXX-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE global_label +# ELF-N32-NEXT: R_MIPS_PC16 global_label +# ELF-N64-NEXT: R_MIPS_PC16/R_MIPS_NONE/R_MIPS_NONE global_label j .text nop Index: test/MC/Mips/expansion-jal-sym-pic.s =================================================================== --- test/MC/Mips/expansion-jal-sym-pic.s +++ test/MC/Mips/expansion-jal-sym-pic.s @@ -55,7 +55,7 @@ # N32: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_Mips_GOT_DISP # ELF-N32: 8f 99 00 00 lw $25, 0($gp) -# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE local_label +# ELF-N32-NEXT: R_MIPS_GOT_DISP local_label # N64: ld $25, %got_disp(local_label)($gp) # encoding: [0xdf,0x99,A,A] # N64: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_Mips_GOT_DISP @@ -92,7 +92,7 @@ # N32: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_Mips_CALL16 # ELF-N32: 8f 99 00 00 lw $25, 0($gp) -# ELF-N32-NEXT: R_MIPS_CALL16/R_MIPS_NONE/R_MIPS_NONE weak_label +# ELF-N32-NEXT: R_MIPS_CALL16 weak_label # N64: ld $25, %call16(weak_label)($gp) # encoding: [0xdf,0x99,A,A] # N64: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_Mips_CALL16 @@ -127,7 +127,7 @@ # N32: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_Mips_CALL16 # ELF-N32: 8f 99 00 00 lw $25, 0($gp) -# ELF-N32-NEXT: R_MIPS_CALL16/R_MIPS_NONE/R_MIPS_NONE global_label +# ELF-N32-NEXT: R_MIPS_CALL16 global_label # N64: ld $25, %call16(global_label)($gp) # encoding: [0xdf,0x99,A,A] # N64: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_Mips_CALL16 @@ -162,7 +162,7 @@ # N32-NEXT: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP # ELF-N32: 8f 99 00 00 lw $25, 0($gp) -# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE .text +# ELF-N32-NEXT: R_MIPS_GOT_DISP .text # N64: ld $25, %got_disp(.text)($gp) # encoding: [0xdf,0x99,A,A] # N64-NEXT: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP @@ -204,7 +204,7 @@ # N32: # fixup A - offset: 0, value: %got_disp($tmp0), kind: fixup_Mips_GOT_DISP # ELF-N32: 8f 99 00 00 lw $25, 0($gp) -# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE .Ltmp0 +# ELF-N32-NEXT: R_MIPS_GOT_DISP .Ltmp0 # N64: ld $25, %got_disp(.Ltmp0)($gp) # encoding: [0xdf,0x99,A,A] # N64: # fixup A - offset: 0, value: %got_disp(.Ltmp0), kind: fixup_Mips_GOT_DISP @@ -246,7 +246,7 @@ # N32-FIXME: # fixup A - offset: 0, value: %got_disp(forward_local), kind: fixup_Mips_GOT_DISP # ELF-N32: 8f 99 00 00 lw $25, 0($gp) -# ELF-N32-NEXT: R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE forward_local +# ELF-N32-NEXT: R_MIPS_GOT_DISP forward_local # N64-FIXME: ld $25, %got_disp(forward_local)($gp) # encoding: [0xdf,0x99,A,A] # N64-FIXME: # fixup A - offset: 0, value: %got_disp(forward_local), kind: fixup_Mips_GOT_DISP Index: test/MC/Mips/reloc-directive.s =================================================================== --- test/MC/Mips/reloc-directive.s +++ test/MC/Mips/reloc-directive.s @@ -33,28 +33,15 @@ # OBJ-O32: 0x8 R_MIPS_32 .text 0x0 # OBJ-O32: 0xC R_MIPS_NONE - 0x0 -# FIXME: We can't get N32 correct at the moment. If we use a mips-* triple then -# we incorrectly drop the addend. If we use a mips64-* triple then we -# incorrectly use the 3-reloc encoding (and ELF64). mips64-* triples -# are closest to being correct so we use them for now. -# This should be corrected once the triple bugfixes allow us to be ABI -# dependent rather than triple dependent. # OBJ-N32-LABEL: Name: .text # OBJ-N32: 0000: 00000000 00000000 00000000 # OBJ-N32-LABEL: } # OBJ-N32-LABEL: Relocations [ -# OBJ-N32: 0x4 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x0 -# OBJ-N32: 0x0 R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE .text 0x4 -# OBJ-N32: 0x8 R_MIPS_32/R_MIPS_NONE/R_MIPS_NONE .text 0x8 -# OBJ-N32: 0xC R_MIPS_NONE/R_MIPS_NONE/R_MIPS_NONE - 0x0 - -# FIXME:This is the correct output for reference. - -# OBJ-N32-FIXME: 0x4 R_MIPS_NONE .text 0x0 -# OBJ-N32-FIXME: 0x0 R_MIPS_NONE .text 0x4 -# OBJ-N32-FIXME: 0x8 R_MIPS_32 .text 0x8 -# OBJ-N32-FIXME: 0xC R_MIPS_NONE - 0x0 +# OBJ-N32: 0x4 R_MIPS_NONE .text 0x0 +# OBJ-N32: 0x0 R_MIPS_NONE .text 0x4 +# OBJ-N32: 0x8 R_MIPS_32 .text 0x8 +# OBJ-N32: 0xC R_MIPS_NONE - 0x0 # OBJ-N64-LABEL: Name: .text # OBJ-N64: 0000: 00000000 00000000 00000000