1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

AMDGPU: Add ELFOSABI_AMDGPU_PAL

llvm-svn: 314843
This commit is contained in:
Konstantin Zhuravlyov 2017-10-03 20:54:07 +00:00
parent ad0810fc5c
commit faac723406
9 changed files with 65 additions and 26 deletions

View File

@ -359,18 +359,20 @@ The AMDGPU backend uses the following ELF header:
.. table:: AMDGPU ELF Header
:name: amdgpu-elf-header-table
========================== =========================
========================== ===============================
Field Value
========================== =========================
========================== ===============================
``e_ident[EI_CLASS]`` ``ELFCLASS64``
``e_ident[EI_DATA]`` ``ELFDATA2LSB``
``e_ident[EI_OSABI]`` ``ELFOSABI_AMDGPU_HSA``
``e_ident[EI_ABIVERSION]`` ``ELFABIVERSION_AMDGPU_HSA``
``e_ident[EI_OSABI]`` ``ELFOSABI_AMDGPU_HSA`` or
``ELFOSABI_AMDGPU_PAL``
``e_ident[EI_ABIVERSION]`` ``ELFABIVERSION_AMDGPU_HSA`` or
``ELFABIVERSION_AMDGPU_PAL``
``e_type`` ``ET_REL`` or ``ET_DYN``
``e_machine`` ``EM_AMDGPU``
``e_entry`` 0
``e_flags`` 0
========================== =========================
========================== ===============================
..
@ -382,24 +384,36 @@ The AMDGPU backend uses the following ELF header:
============================ =====
``EM_AMDGPU`` 224
``ELFOSABI_AMDGPU_HSA`` 64
``ELFOSABI_AMDGPU_PAL`` 65
``ELFABIVERSION_AMDGPU_HSA`` 1
``ELFABIVERSION_AMDGPU_PAL`` 0
============================ =====
``e_ident[EI_CLASS]``
The ELF class is always ``ELFCLASS64``. The AMDGPU backend only supports 64 bit
applications.
The ELF class is always ``ELFCLASS64``. The AMDGPU backend only supports 64
bit applications.
``e_ident[EI_DATA]``
All AMDGPU targets use ELFDATA2LSB for little-endian byte ordering.
``e_ident[EI_OSABI]``
The AMD GPU architecture specific OS ABI of ``ELFOSABI_AMDGPU_HSA`` is used to
specify that the code object conforms to the AMD HSA runtime ABI [HSA]_.
One of two AMD GPU architecture specific OS ABI:
* ``ELFOSABI_AMDGPU_HSA`` is used to specify that the code object conforms to
the AMD HSA runtime ABI [HSA]_.
* ``ELFOSABI_AMDGPU_PAL`` is used to specify that the code object conforms to
the AMD PAL runtime ABI.
``e_ident[EI_ABIVERSION]``
The AMD GPU architecture specific OS ABI version of
``ELFABIVERSION_AMDGPU_HSA`` is used to specify the version of AMD HSA runtime
ABI to which the code object conforms.
The ABI version of the AMD GPU architecture specific OS ABI to which the code
object conforms:
* ``ELFABIVERSION_AMDGPU_HSA`` is used to specify the version of AMD HSA
runtime ABI.
* ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
runtime ABI.
``e_type``
Can be one of the following values:

View File

@ -355,9 +355,10 @@ enum {
ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
ELFOSABI_FIRST_ARCH = 64, // First architecture-specific OS ABI
ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
ELFOSABI_AMDGPU_PAL = 65, // AMD PAL runtime
ELFOSABI_ARM = 97, // ARM
ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
ELFOSABI_ARM = 97, // ARM
ELFOSABI_STANDALONE = 255, // Standalone (embedded) application
ELFOSABI_LAST_ARCH = 255 // Last Architecture-specific OS ABI
};

View File

@ -995,9 +995,7 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
case ELF::EM_WEBASSEMBLY:
return "ELF64-wasm";
case ELF::EM_AMDGPU:
return (EF.getHeader()->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA
&& IsLittleEndian) ?
"ELF64-amdgpu-hsacobj" : "ELF64-amdgpu";
return "ELF64-amdgpu";
case ELF::EM_BPF:
return "ELF64-BPF";
default:
@ -1066,10 +1064,13 @@ unsigned ELFObjectFile<ELFT>::getArch() const {
}
case ELF::EM_AMDGPU:
return (EF.getHeader()->e_ident[ELF::EI_CLASS] == ELF::ELFCLASS64
&& EF.getHeader()->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA
&& IsLittleEndian) ?
Triple::amdgcn : Triple::UnknownArch;
if (EF.getHeader()->e_ident[ELF::EI_CLASS] != ELF::ELFCLASS64)
return Triple::UnknownArch;
if (!IsLittleEndian)
return Triple::UnknownArch;
// TODO: Determine r600/amdgcn architecture based e_flags.
return Triple::amdgcn;
case ELF::EM_BPF:
return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;

View File

@ -260,10 +260,11 @@ void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
ECase(ELFOSABI_AROS);
ECase(ELFOSABI_FENIXOS);
ECase(ELFOSABI_CLOUDABI);
ECase(ELFOSABI_C6000_ELFABI);
ECase(ELFOSABI_AMDGPU_HSA);
ECase(ELFOSABI_C6000_LINUX);
ECase(ELFOSABI_AMDGPU_PAL);
ECase(ELFOSABI_ARM);
ECase(ELFOSABI_C6000_ELFABI);
ECase(ELFOSABI_C6000_LINUX);
ECase(ELFOSABI_STANDALONE);
#undef ECase
}

View File

@ -1,7 +1,7 @@
# RUN: yaml2obj %s > %t.o
# RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
# CHECK: Format: ELF64-amdgpu-hsacobj
# CHECK: Format: ELF64-amdgpu
# CHECK: Arch: amdgcn
# CHECK: ElfHeader {
# CHECK: Ident {

View File

@ -0,0 +1,21 @@
# RUN: yaml2obj %s > %t.o
# RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
# CHECK: Format: ELF64-amdgpu
# CHECK: Arch: amdgcn
# CHECK: ElfHeader {
# CHECK: Ident {
# CHECK: OS/ABI: AMDGPU_PAL (0x41)
# CHECK: ABIVersion: 0
# CHECK: }
# CHECK: Machine: EM_AMDGPU (0xE0)
# CHECK: }
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AMDGPU
OSABI: ELFOSABI_AMDGPU_PAL
...

View File

@ -45,7 +45,7 @@ BB5:
v_lshlrev_b32_e32 v7, 2, v7
s_endpgm
// CHECK: file format ELF64-amdgpu-hsacobj
// CHECK: file format ELF64-amdgpu
// CHECK: Disassembly of section .text:
// CHECK: hello_world:
// CHECK: s_mov_b32 m0, 0x10000 // 000000000100: BEFC00FF 00010000

View File

@ -1,6 +1,6 @@
RUN: llvm-readobj -file-headers -program-headers -sections -symbols %p/Inputs/trivial.obj.elf-amdhsa-gfx803 | FileCheck %s
CHECK: Format: ELF64-amdgpu-hsacobj
CHECK: Format: ELF64-amdgpu
CHECK: Arch: amdgcn
CHECK: ElfHeader {
CHECK: Ident {

View File

@ -825,7 +825,8 @@ static const EnumEntry<unsigned> ElfOSABI[] = {
};
static const EnumEntry<unsigned> AMDGPUElfOSABI[] = {
{"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA}
{"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA},
{"AMDGPU_PAL", "AMDGPU - PAL", ELF::ELFOSABI_AMDGPU_PAL}
};
static const EnumEntry<unsigned> ARMElfOSABI[] = {