mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
AMDGPU: Correctly set EI_OSABI based on the os
Differential Revision: https://reviews.llvm.org/D38555 llvm-svn: 314943
This commit is contained in:
parent
6d68e5d516
commit
298e3abdb4
@ -11,6 +11,7 @@
|
||||
#include "MCTargetDesc/AMDGPUFixupKinds.h"
|
||||
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/BinaryFormat/ELF.h"
|
||||
#include "llvm/MC/MCAsmBackend.h"
|
||||
#include "llvm/MC/MCAssembler.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
@ -167,14 +168,29 @@ namespace {
|
||||
class ELFAMDGPUAsmBackend : public AMDGPUAsmBackend {
|
||||
bool Is64Bit;
|
||||
bool HasRelocationAddend;
|
||||
uint8_t OSABI = ELF::ELFOSABI_NONE;
|
||||
|
||||
public:
|
||||
ELFAMDGPUAsmBackend(const Target &T, const Triple &TT) :
|
||||
AMDGPUAsmBackend(T), Is64Bit(TT.getArch() == Triple::amdgcn),
|
||||
HasRelocationAddend(TT.getOS() == Triple::AMDHSA) { }
|
||||
HasRelocationAddend(TT.getOS() == Triple::AMDHSA) {
|
||||
switch (TT.getOS()) {
|
||||
case Triple::AMDHSA:
|
||||
OSABI = ELF::ELFOSABI_AMDGPU_HSA;
|
||||
break;
|
||||
case Triple::AMDPAL:
|
||||
OSABI = ELF::ELFOSABI_AMDGPU_PAL;
|
||||
break;
|
||||
case Triple::Mesa3D:
|
||||
OSABI = ELF::ELFOSABI_AMDGPU_MESA3D;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override {
|
||||
return createAMDGPUELFObjectWriter(Is64Bit, HasRelocationAddend, OS);
|
||||
return createAMDGPUELFObjectWriter(Is64Bit, OSABI, HasRelocationAddend, OS);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace {
|
||||
|
||||
class AMDGPUELFObjectWriter : public MCELFObjectTargetWriter {
|
||||
public:
|
||||
AMDGPUELFObjectWriter(bool Is64Bit, bool HasRelocationAddend);
|
||||
AMDGPUELFObjectWriter(bool Is64Bit, uint8_t OSABI, bool HasRelocationAddend);
|
||||
|
||||
protected:
|
||||
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
|
||||
@ -33,10 +33,9 @@ protected:
|
||||
} // end anonymous namespace
|
||||
|
||||
AMDGPUELFObjectWriter::AMDGPUELFObjectWriter(bool Is64Bit,
|
||||
uint8_t OSABI,
|
||||
bool HasRelocationAddend)
|
||||
: MCELFObjectTargetWriter(Is64Bit,
|
||||
ELF::ELFOSABI_AMDGPU_HSA,
|
||||
ELF::EM_AMDGPU,
|
||||
: MCELFObjectTargetWriter(Is64Bit, OSABI, ELF::EM_AMDGPU,
|
||||
HasRelocationAddend) {}
|
||||
|
||||
unsigned AMDGPUELFObjectWriter::getRelocType(MCContext &Ctx,
|
||||
@ -83,9 +82,10 @@ unsigned AMDGPUELFObjectWriter::getRelocType(MCContext &Ctx,
|
||||
}
|
||||
|
||||
MCObjectWriter *llvm::createAMDGPUELFObjectWriter(bool Is64Bit,
|
||||
uint8_t OSABI,
|
||||
bool HasRelocationAddend,
|
||||
raw_pwrite_stream &OS) {
|
||||
MCELFObjectTargetWriter *MOTW =
|
||||
new AMDGPUELFObjectWriter(Is64Bit, HasRelocationAddend);
|
||||
new AMDGPUELFObjectWriter(Is64Bit, OSABI, HasRelocationAddend);
|
||||
return createELFObjectWriter(MOTW, OS, true);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ MCAsmBackend *createAMDGPUAsmBackend(const Target &T, const MCRegisterInfo &MRI,
|
||||
const MCTargetOptions &Options);
|
||||
|
||||
MCObjectWriter *createAMDGPUELFObjectWriter(bool Is64Bit,
|
||||
uint8_t OSABI,
|
||||
bool HasRelocationAddend,
|
||||
raw_pwrite_stream &OS);
|
||||
} // End llvm namespace
|
||||
|
43
test/CodeGen/AMDGPU/elf-header.ll
Normal file
43
test/CodeGen/AMDGPU/elf-header.ll
Normal file
@ -0,0 +1,43 @@
|
||||
; RUN: llc -march=r600 -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=R600 --check-prefix=R600-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=r600-- -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=R600 --check-prefix=R600-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=r600-amd- -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=R600 --check-prefix=R600-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=r600-amd-unknown -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=R600 --check-prefix=R600-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=r600-unknown-unknown -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=R600 --check-prefix=R600-OSABI-NONE %s
|
||||
|
||||
; RUN: llc -march=amdgcn -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=amdgcn-- -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=amdgcn-amd- -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-unknown -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-NONE %s
|
||||
; RUN: llc -mtriple=amdgcn-unknown-unknown -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-NONE %s
|
||||
|
||||
; RUN: llc -mtriple=amdgcn--amdhsa -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-HSA %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-HSA %s
|
||||
; RUN: llc -mtriple=amdgcn-unknown-amdhsa -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-HSA %s
|
||||
|
||||
; RUN: llc -mtriple=amdgcn--amdpal -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-PAL %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-amdpal -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-PAL %s
|
||||
; RUN: llc -mtriple=amdgcn-unknown-amdpal -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-PAL %s
|
||||
|
||||
; RUN: llc -mtriple=amdgcn--mesa3d -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-MESA3D %s
|
||||
; RUN: llc -mtriple=amdgcn-amd-mesa3d -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-MESA3D %s
|
||||
; RUN: llc -mtriple=amdgcn-unknown-mesa3d -filetype=obj < %s | llvm-readobj -file-headers - | FileCheck --check-prefix=GCN --check-prefix=GCN-OSABI-MESA3D %s
|
||||
|
||||
; R600: Format: ELF32-amdgpu
|
||||
; R600: Arch: unknown
|
||||
; R600: AddressSize: 32bit
|
||||
; GCN: Format: ELF64-amdgpu
|
||||
; GCN: Arch: amdgcn
|
||||
; GCN: AddressSize: 64bit
|
||||
|
||||
; R600-OSABI-NONE: OS/ABI: SystemV (0x0)
|
||||
; GCN-OSABI-NONE: OS/ABI: SystemV (0x0)
|
||||
; GCN-OSABI-HSA: OS/ABI: AMDGPU_HSA (0x40)
|
||||
; GCN-OSABI-PAL: OS/ABI: AMDGPU_PAL (0x41)
|
||||
; GCN-OSABI-MESA3D: OS/ABI: AMDGPU_MESA3D (0x42)
|
||||
|
||||
; R600: Machine: EM_AMDGPU (0xE0)
|
||||
; GCN: Machine: EM_AMDGPU (0xE0)
|
||||
|
||||
define amdgpu_kernel void @elf_header() {
|
||||
ret void
|
||||
}
|
@ -8,8 +8,8 @@
|
||||
; Test that we don't try to produce a COFF file on windows
|
||||
; RUN: llc < %s -mtriple=amdgcn-pc-mingw -verify-machineinstrs -filetype=obj | llvm-readobj -s -symbols -file-headers - | FileCheck --check-prefix=ELF %s
|
||||
|
||||
; ELF: Format: ELF64
|
||||
; ELF: OS/ABI: AMDGPU_HSA (0x40)
|
||||
; ELF: Format: ELF64-amdgpu
|
||||
; ELF: OS/ABI: SystemV (0x0)
|
||||
; ELF: Machine: EM_AMDGPU (0xE0)
|
||||
; ELF: Name: .AMDGPU.config
|
||||
; ELF: Type: SHT_PROGBITS
|
||||
|
@ -1,7 +1,7 @@
|
||||
; RUN: llc < %s -march=r600 -mcpu=redwood -filetype=obj | llvm-readobj -s - | FileCheck --check-prefix=ELF %s
|
||||
; RUN: llc < %s -march=r600 -mcpu=redwood -o - | FileCheck --check-prefix=CONFIG %s
|
||||
|
||||
; ELF: Format: ELF32
|
||||
; ELF: Format: ELF32-amdgpu
|
||||
; ELF: Name: .AMDGPU.config
|
||||
|
||||
; CONFIG: .section .AMDGPU.config
|
||||
|
Loading…
Reference in New Issue
Block a user