Skip to content

Commit cb2cb14

Browse files
DianaChensys_zuul
authored andcommitted
ZEBinWriter: Fix standalone build and add test option
Change-Id: I3a7b5b253ac5afa0fa3ce90f7a7cc79effe845fd
1 parent d1908ed commit cb2cb14

File tree

6 files changed

+44
-15
lines changed

6 files changed

+44
-15
lines changed

IGC/ZEBinWriter/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ set(VS_DEBUG_COMPILER_OPTIONS
2222
/MTd
2323
)
2424

25+
set (CMAKE_C_FLAGS "-DZEBinStandAloneBuild")
26+
set (CMAKE_CXX_FLAGS "-DZEBinStandAloneBuild")
27+
2528
# Include sub-projects.
2629
add_subdirectory ("zebin")
2730
add_subdirectory ("tools")

IGC/ZEBinWriter/tools/Tester.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ using namespace zebin;
3535

3636
static void getTestZEInfo(zeInfoContainer& ks)
3737
{
38-
zeInfoKernels k1;
38+
zeInfoKernel k1;
3939

4040
k1.name = "kernel_name_1";
4141
k1.execution_env.actual_kernel_start_offset = 0;
@@ -45,32 +45,32 @@ static void getTestZEInfo(zeInfoContainer& ks)
4545
k1.execution_env.required_work_group_size.push_back(2);
4646
k1.execution_env.required_work_group_size.push_back(1);
4747

48-
zeInfoPerThreadPayloadArguments p_arg;
48+
zeInfoPerThreadPayloadArgument p_arg;
4949
p_arg.arg_type = "local_id";
5050
p_arg.offset = 0;
5151
p_arg.size = 96;
5252

5353
k1.per_thread_payload_arguments.push_back(p_arg);
5454

55-
zeInfoPayloadArguments imp_arg1;
55+
zeInfoPayloadArgument imp_arg1;
5656
imp_arg1.arg_type = "local_size";
5757
imp_arg1.offset = 0;
5858
imp_arg1.size = 12;
5959
k1.payload_arguments.push_back(imp_arg1);
6060

61-
zeInfoPayloadArguments imp_arg2;
61+
zeInfoPayloadArgument imp_arg2;
6262
imp_arg2.arg_type = "group_size";
6363
imp_arg2.offset = 12;
6464
imp_arg2.size = 12;
6565
k1.payload_arguments.push_back(imp_arg2);
6666

67-
zeInfoPayloadArguments imp_arg3;
67+
zeInfoPayloadArgument imp_arg3;
6868
imp_arg3.arg_type = "global_id_offset";
6969
imp_arg3.offset = 24;
7070
imp_arg3.size = 12;
7171
k1.payload_arguments.push_back(imp_arg3);
7272

73-
zeInfoPayloadArguments arg1;
73+
zeInfoPayloadArgument arg1;
7474
arg1.arg_type = "arg_pointer";
7575
arg1.offset = 64;
7676
arg1.size = 8;
@@ -80,7 +80,7 @@ static void getTestZEInfo(zeInfoContainer& ks)
8080
arg1.access_type = "readwrite";
8181
k1.payload_arguments.push_back(arg1);
8282

83-
zeInfoPayloadArguments arg2;
83+
zeInfoPayloadArgument arg2;
8484
arg2.arg_type = "arg_pointer";
8585
arg2.offset = 0;
8686
arg2.size = 8;
@@ -90,12 +90,12 @@ static void getTestZEInfo(zeInfoContainer& ks)
9090
arg2.access_type = "readwrite";
9191
k1.payload_arguments.push_back(arg2);
9292

93-
zeInfoBindingTableIndexes bti;
93+
zeInfoBindingTableIndex bti;
9494
bti.bti_value = 0;
9595
bti.arg_index = 0;
9696
k1.binding_table_indexes.push_back(bti);
9797

98-
zeInfoKernels k2;
98+
zeInfoKernel k2;
9999
k2.name = "kernel_name_2";
100100
k2.execution_env.actual_kernel_start_offset = 0;
101101
k2.execution_env.grf_count = 100;
@@ -122,7 +122,7 @@ void Tester::testELFOutput()
122122
// add fake text
123123
uint8_t text_buff[100] = {0x1, 0x2, 0x3, 0x4};
124124
uint32_t text =
125-
builder.addSectionText(".text.kernel", (uint8_t*)text_buff, 10);
125+
builder.addSectionText(".text.kernel", (uint8_t*)text_buff, 10, 0, 0);
126126

127127
// add fake data 1
128128
uint8_t data_buff_1[4] = {0x1, 0x2, 0x3, 0x4};
@@ -142,8 +142,8 @@ void Tester::testELFOutput()
142142
builder.addSymbol("undef_sym", 0, 0, llvm::ELF::STB_GLOBAL, llvm::ELF::STT_OBJECT, -1);
143143

144144
// add fake relocations
145-
builder.addRelocation(4, "data1_sym_at_3", R_TYPE_ZEBIN::R_ZE_SYM_ADDR);
146-
builder.addRelocation(8, "text_sym_at_1", R_TYPE_ZEBIN::R_ZE_SYM_ADDR_32);
145+
builder.addRelocation(4, "data1_sym_at_3", R_TYPE_ZEBIN::R_ZE_SYM_ADDR, text);
146+
builder.addRelocation(8, "text_sym_at_1", R_TYPE_ZEBIN::R_ZE_SYM_ADDR_32, text);
147147

148148
// add fake ze_info
149149
zeInfoContainer ks;

IGC/ZEBinWriter/tools/ZEInfoReader.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,26 @@ static void dumpZEInfo(std::unique_ptr<llvm::object::ObjectFile> object) {
7373

7474
/// ---------------- Command line options --------------------------------- ///
7575
static llvm::cl::opt<string> InputFilename(
76-
llvm::cl::Positional, llvm::cl::desc("<input file>"), llvm::cl::Required);
76+
llvm::cl::Positional, llvm::cl::desc("<input file>"));
7777

7878
static llvm::cl::opt<bool> DumpZEInfo ("info",
7979
llvm::cl::desc("Dump .ze_info section into ze_info.dump file"));
80+
81+
static llvm::cl::opt<bool> RunTestZEInfo ("test-ze-info",
82+
llvm::cl::desc("Run static zeinfo generating tests, print the result to std output"));
8083
/// ----------------------------------------------------------------------- ///
8184

8285
int zeinfo_reader_main(int argc, const char** argv) {
8386
llvm::cl::ParseCommandLineOptions(argc, argv);
8487

85-
// read input file
88+
// run zeinfo generating tests
89+
// FIXME: This is just a static test, need to be enhanced
90+
if (RunTestZEInfo) {
91+
Tester::testZEInfoOutput();
92+
return 0;
93+
}
94+
95+
// read input elf file
8696
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileOrErr =
8797
llvm::MemoryBuffer::getFile(InputFilename);
8898

IGC/ZEBinWriter/zebin/include/ZEELFObjectBuilder.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3636
#include <ZEELF.h>
3737
#include <ZEInfo.hpp>
3838

39+
#ifndef ZEBinStandAloneBuild
3940
#include "common/LLVMWarningsPush.hpp"
41+
#endif
42+
4043
#include "llvm/BinaryFormat/ELF.h"
44+
45+
#ifndef ZEBinStandAloneBuild
4146
#include "common/LLVMWarningsPop.hpp"
47+
#endif
4248

4349
#include <map>
4450
#include <string>

IGC/ZEBinWriter/zebin/include/ZEInfoYAML.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3535

3636
#include <ZEInfo.hpp>
3737

38+
#ifndef ZEBinStandAloneBuild
3839
#include "common/LLVMWarningsPush.hpp"
40+
#endif
41+
3942
#include "llvm/Support/YAMLTraits.h"
43+
#ifndef ZEBinStandAloneBuild
4044
#include "common/LLVMWarningsPop.hpp"
45+
#endif
4146

4247
LLVM_YAML_IS_SEQUENCE_VECTOR(zebin::zeInfoPayloadArgument)
4348
LLVM_YAML_IS_SEQUENCE_VECTOR(zebin::zeInfoPerThreadPayloadArgument)

IGC/ZEBinWriter/zebin/lib/ZEELFObjectBuilder.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2727
#include <ZEInfo.hpp>
2828
#include <ZEInfoYAML.hpp>
2929

30+
#ifndef ZEBinStandAloneBuild
3031
#include "common/LLVMWarningsPush.hpp"
32+
#endif
33+
3134
#include "llvm/MC/StringTableBuilder.h"
3235
#include "llvm/Support/EndianStream.h"
3336
#include "llvm/Support/raw_ostream.h"
34-
#include "common/LLVMWarningsPop.hpp"
3537

38+
#ifndef ZEBinStandAloneBuild
39+
#include "common/LLVMWarningsPop.hpp"
40+
#endif
3641

3742
#include <iostream>
3843

0 commit comments

Comments
 (0)