Skip to content

Latest commit

 

History

History
58 lines (45 loc) · 2.5 KB

GenBinaryDecoding.md

File metadata and controls

58 lines (45 loc) · 2.5 KB

GEN Binary Decoding

Overview

This chapter describes Intel(R) Processor Graphics Assembler (IGA) library - a part of Intel(R) Processor Graphics Compiler. The IGA is designed to decode and disassemble GEN binaries, including getting instruction properties, like opcode, instruction size, arguments, execution size, etc.

Supported OS:

  • Linux
  • Windows

Supported HW:

  • Intel(R) Processor Graphics GEN9+

Needed Headers:

  • Intel(R) Processor Graphics Assembler (IGA) library headers

Needed Libraries:

How To Use

An example below demonstrates how to split raw GEN binary into separate instructions and disassemble them using KernelView interface of IGA:

#include <kv.hpp>

std::vector< std::pair<uint32_t, std::string> > Disassemble(
    const std::vector<uint8_t>& binary) {
  std::vector< std::pair<uint32_t, std::string> > instruction_list;

  KernelView kv(IGA_GEN9, binary.data(), binary.size(),
                iga::SWSB_ENCODE_MODE::SingleDistPipe);
  assert(kv.decodeSucceeded());

  char text[MAX_STR_SIZE] = { 0 };
  int32_t offset = 0, size = 0;
  while (true) {
    size = kv.getInstSize(offset);
    if (size == 0) {
      break;
    }

    size_t lenght = kv.getInstSyntax(offset, text, MAX_STR_SIZE);
    assert(lenght > 0);
    instruction_list.push_back(std::make_pair(offset, text));

    offset += size;
  }

  return instruction_list;
}

Usage Details

  • refer to the paper Introduction to GEN Assembly to learn more on Intel(R) Processor Graphics instruction set
  • look into Intel(R) Processor Graphics Assembler (IGA) library headers to learn more on GEN binary decoding/disassembling interfaces

Samples