1 /*
2  * Copyright (C) 2020-2021 Intel Corporation
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  */
7 
8 // Abstract: Defines the types used for ELF headers/sections.
9 #pragma once
10 
11 #include "shared/source/device_binary_format/elf/elf.h"
12 #include "shared/source/utilities/const_stringref.h"
13 
14 #include <inttypes.h>
15 #include <stddef.h>
16 
17 namespace NEO {
18 
19 namespace Elf {
20 
21 enum ELF_TYPE_OPENCL : uint16_t {
22     ET_OPENCL_SOURCE = 0xff01,     // format used to pass CL text sections to FE
23     ET_OPENCL_OBJECTS = 0xff02,    // format used to pass LLVM objects / store LLVM binary output
24     ET_OPENCL_LIBRARY = 0xff03,    // format used to store LLVM archive output
25     ET_OPENCL_EXECUTABLE = 0xff04, // format used to store executable output
26     ET_OPENCL_DEBUG = 0xff05,      // format used to store debug output
27 };
28 static_assert(sizeof(ELF_TYPE_OPENCL) == sizeof(ELF_TYPE), "");
29 static_assert(static_cast<uint16_t>(ET_OPENCL_SOURCE) == static_cast<uint16_t>(ET_OPENCL_RESERVED_START), "");
30 static_assert(static_cast<uint16_t>(ET_OPENCL_DEBUG) == static_cast<uint16_t>(ET_OPENCL_RESERVED_END), "");
31 
32 enum SHT_OPENCL : uint32_t {
33     SHT_OPENCL_SOURCE = 0xff000000,                  // CL source to link into LLVM binary
34     SHT_OPENCL_HEADER = 0xff000001,                  // CL header to link into LLVM binary
35     SHT_OPENCL_LLVM_TEXT = 0xff000002,               // LLVM text
36     SHT_OPENCL_LLVM_BINARY = 0xff000003,             // LLVM byte code
37     SHT_OPENCL_LLVM_ARCHIVE = 0xff000004,            // LLVM archives(s)
38     SHT_OPENCL_DEV_BINARY = 0xff000005,              // Device binary (coherent by default)
39     SHT_OPENCL_OPTIONS = 0xff000006,                 // CL Options
40     SHT_OPENCL_PCH = 0xff000007,                     // PCH (pre-compiled headers)
41     SHT_OPENCL_DEV_DEBUG = 0xff000008,               // Device debug
42     SHT_OPENCL_SPIRV = 0xff000009,                   // SPIRV
43     SHT_OPENCL_NON_COHERENT_DEV_BINARY = 0xff00000a, // Non-coherent Device binary
44     SHT_OPENCL_SPIRV_SC_IDS = 0xff00000b,            // Specialization Constants IDs
45     SHT_OPENCL_SPIRV_SC_VALUES = 0xff00000c          // Specialization Constants values
46 };
47 static_assert(sizeof(SHT_OPENCL) == sizeof(SECTION_HEADER_TYPE), "");
48 static_assert(static_cast<uint32_t>(SHT_OPENCL_SOURCE) == static_cast<uint32_t>(SHT_OPENCL_RESERVED_START), "");
49 static_assert(static_cast<uint32_t>(SHT_OPENCL_SPIRV_SC_VALUES) == static_cast<uint32_t>(SHT_OPENCL_RESERVED_END), "");
50 
51 namespace SectionNamesOpenCl {
52 static constexpr ConstStringRef buildOptions = "BuildOptions";
53 static constexpr ConstStringRef spirvObject = "SPIRV Object";
54 static constexpr ConstStringRef llvmObject = "Intel(R) OpenCL LLVM Object";
55 static constexpr ConstStringRef deviceDebug = "Intel(R) OpenCL Device Debug";
56 static constexpr ConstStringRef deviceBinary = "Intel(R) OpenCL Device Binary";
57 static constexpr ConstStringRef spirvSpecConstIds = "SPIRV Specialization Constants Ids";
58 static constexpr ConstStringRef spirvSpecConstValues = "SPIRV Specialization Constants Values";
59 } // namespace SectionNamesOpenCl
60 
61 } // namespace Elf
62 
63 } // namespace NEO
64