[llvm] r314943 - AMDGPU: Correctly set EI_OSABI based on the os
Konstantin Zhuravlyov via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 15:44:13 PDT 2017
Author: kzhuravl
Date: Wed Oct 4 15:44:13 2017
New Revision: 314943
URL: http://llvm.org/viewvc/llvm-project?rev=314943&view=rev
Log:
AMDGPU: Correctly set EI_OSABI based on the os
Differential Revision: https://reviews.llvm.org/D38555
Added:
llvm/trunk/test/CodeGen/AMDGPU/elf-header.ll
Modified:
llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h
llvm/trunk/test/CodeGen/AMDGPU/elf.ll
llvm/trunk/test/CodeGen/AMDGPU/elf.r600.ll
Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp?rev=314943&r1=314942&r2=314943&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp Wed Oct 4 15:44:13 2017
@@ -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);
}
};
Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp?rev=314943&r1=314942&r2=314943&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp Wed Oct 4 15:44:13 2017
@@ -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::getReloc
}
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);
}
Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h?rev=314943&r1=314942&r2=314943&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h Wed Oct 4 15:44:13 2017
@@ -48,6 +48,7 @@ MCAsmBackend *createAMDGPUAsmBackend(con
const MCTargetOptions &Options);
MCObjectWriter *createAMDGPUELFObjectWriter(bool Is64Bit,
+ uint8_t OSABI,
bool HasRelocationAddend,
raw_pwrite_stream &OS);
} // End llvm namespace
Added: llvm/trunk/test/CodeGen/AMDGPU/elf-header.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/elf-header.ll?rev=314943&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/elf-header.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/elf-header.ll Wed Oct 4 15:44:13 2017
@@ -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
+}
\ No newline at end of file
Modified: llvm/trunk/test/CodeGen/AMDGPU/elf.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/elf.ll?rev=314943&r1=314942&r2=314943&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/elf.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/elf.ll Wed Oct 4 15:44:13 2017
@@ -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
Modified: llvm/trunk/test/CodeGen/AMDGPU/elf.r600.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/elf.r600.ll?rev=314943&r1=314942&r2=314943&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/elf.r600.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/elf.r600.ll Wed Oct 4 15:44:13 2017
@@ -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
More information about the llvm-commits
mailing list