[AMDGPU] add AMDGPU target support to ELFObjectFile.h header

Differential Revision: http://reviews.llvm.org/D17144

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263026 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Valery Pykhtin 2016-03-09 17:08:19 +00:00
parent 591e1d2c57
commit 4915c55094
5 changed files with 38 additions and 0 deletions

View File

@ -846,6 +846,8 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
return "ELF32-sparc";
case ELF::EM_WEBASSEMBLY:
return "ELF32-wasm";
case ELF::EM_AMDGPU:
return "ELF32-amdgpu";
default:
return "ELF32-unknown";
}
@ -867,6 +869,10 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
return "ELF64-mips";
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";
default:
return "ELF64-unknown";
}
@ -923,6 +929,12 @@ unsigned ELFObjectFile<ELFT>::getArch() const {
default: return Triple::UnknownArch;
}
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;
default:
return Triple::UnknownArch;
}

View File

@ -239,6 +239,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
ECase(ELFOSABI_FENIXOS)
ECase(ELFOSABI_CLOUDABI)
ECase(ELFOSABI_C6000_ELFABI)
ECase(ELFOSABI_AMDGPU_HSA)
ECase(ELFOSABI_C6000_LINUX)
ECase(ELFOSABI_ARM)
ECase(ELFOSABI_STANDALONE)

View File

@ -1,6 +1,8 @@
# RUN: yaml2obj -format=elf %s > %t.o
# RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
# CHECK: Format: ELF64-amdgpu-hsacobj
# CHECK: Arch: amdgcn
# CHECK: Machine: EM_AMDGPU (0xE0)
# CHECK: Sections [
# CHECK: Section {
@ -18,6 +20,7 @@ FileHeader:
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AMDGPU
OSABI: ELFOSABI_AMDGPU_HSA
Sections:
- Name: .shf_amdgpu

View File

@ -0,0 +1,11 @@
# RUN: yaml2obj -format=elf %s > %t.o
# RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
# CHECK: Format: ELF32-amdgpu
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AMDGPU

View File

@ -0,0 +1,11 @@
# RUN: yaml2obj -format=elf %s > %t.o
# RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
# CHECK: Format: ELF64-amdgpu
---
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_AMDGPU