/*========================== begin_copyright_notice ============================
Copyright (C) 2021-2023 Intel Corporation

SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/

#ifndef GTREPLAY_H
#define GTREPLAY_H

#include "gtreplay_crt.h"
#include "gtreplay_types.h"
#include "gtreplay_callbacks.h"

extern "C"
{
/*************************************************************************
 *
 * General runtime API
 *
 ************************************************************************/

/*!
 * Start GTReplay
 * \ingroup GTREPLAY_GENERAL
 */    
GTREPLAY_API
void GTReplay_Start();

/*!
 * Report the specified message to the GTReplay user, and terminate the process
 * @ingroup GTREPLAY_GENERAL
 * @param[in]        msg            the message to be reported
 * @par Availability:
 * - All
 */
GTREPLAY_API
void GTReplay_Abort(const char* msg);

/*!
 * @return GTReplay version string
 * @ingroup GTREPLAY_GENERAL
 * @par Availability:
 * - All
 */
GTREPLAY_API
const char* GTReplay_GetVersion();

/*!
 * @return GTReplay revision string
 * @ingroup GTREPLAY_GENERAL
 * @par Availability:
 * - All
 */
GTREPLAY_API
const char* GTReplay_GetRevision();

/*!
 * Load a trace and return a handle to corresponding kernel
 * @return a handle to corresponding kernel
 * @ingroup GTREPLAY_GENERAL
 * @param[in] path to a directory containing the trace
 * @par Availability:
 * - initialization
 */
GTREPLAY_API
GTReplayKernel GTReplay_LoadTrace(const char* pathToTrace);

/*************************************************************************
 *
 * Execution API
 *
 ************************************************************************/

/*!
 * Replay a given kernel (trace)
 * @ingroup GTREPLAY_EXECUTION
 * @param[in] kernel  a kernel handle
 * @par Availability:
 * - execution
 */
GTREPLAY_API
void GTReplay_Run(GTReplayKernel kernel);

/*!
 * Associate state of a hardware thread with a given data
 * @ingroup GTREPLAY_EXECUTION
 * @param[in] state  handle to a hardware thread state
 * @param[in] data   a pointer to associated data
 * @par Availability:
 * - execution
 */
GTREPLAY_API
void GTReplay_SetThreadData(GTReplayState state, void* data);

/*!
 * @return data associated with a hardware thread state
 * @ingroup GTREPLAY_EXECUTION
 * @param[in] state  handle to a hardware thread state
 * @par Availability:
 * - execution
 */
GTREPLAY_API
void* GTReplay_GetThreadData(GTReplayState state);

/*!
 * @return Shared Local Memory base index of the current SW thread
 * @ingroup GTREPLAY_EXECUTION
 * @param[in]  state  handle to a hardware thread state
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_GetSlmId(GTReplayState state);

/*!
 * @return barrier index of the current SW thread
 * @ingroup GTREPLAY_EXECUTION
 * @param[in]  state  handle to a hardware thread state
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_GetBarrierId(GTReplayState state);

/*!
 * @return binding table base pointer of the current SW thread
 * @ingroup GTREPLAY_EXECUTION
 * @param[in]  state  handle to a hardware thread state
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_GetBindingTablePointer(GTReplayState state);

/*!
 * Return thread group ID of the current SW thread
 * @ingroup GTREPLAY_EXECUTION
 * @param[in]  state  handle to a hardware thread state
 * @param[out] x      pointer to X component
 * @param[out] y      pointer to Y component
 * @param[out] z      pointer to Z component
 * @par Availability:
 * - execution
 */
GTREPLAY_API
void GTReplay_GetThreadGroupId(GTReplayState state, uint32_t* x, uint32_t* y, uint32_t* z);

/*!
 * @return thread group size of the given kernel
 * @ingroup GTREPLAY_EXECUTION
 * @param[in] kernel  a kernel handle
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_GetGroupSize(GTReplayKernel kernel);

/*!
 * @return GEN model of the given kernel (trace) (enum GED_MODEL)
 * @ingroup GTREPLAY_EXECUTION
 * @param[in] kernel  a kernel handle
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_GetModel(GTReplayKernel kernel);

/*!
 * Copies an array of chars containing the kernel name to the provided buffer
 * @ingroup GTREPLAY_EXECUTION
 * @param[in]        kernel  a kernel handle
 * @param[in,out]    size pointer to a uint32_t to return the name size in characters
 * @param[in,out]    pointer to the buffer of the size "size" allocated by the caller. if NULL, only the size is returned.
 * @par Availability:
 * - execution
 */
 GTREPLAY_API
void GTReplay_GetKernelName(GTReplayKernel kernel, uint32_t* size, char* buf);

/*!
 * @return max number of HW threads supported for given model
 * @ingroup GTREPLAY_EXECUTION
 * @param[in] model  GEN model ID
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_MaxNumOfHWThreads(uint32_t model);

/*!
 * @return max number of tiles
 * @ingroup GTREPLAY_EXECUTION
 * @param[in]        kernel  a kernel handle
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_MaxNumOfTiles(GTReplayKernel kernel);

/*!
 * @return register width supported for given model
 * @ingroup GTREPLAY_EXECUTION
 * @param[in] model  GEN model ID
 * @par Availability:
 * - execution
 */
GTREPLAY_API
uint32_t GTReplay_RegisterWidth(uint32_t model);

/*!
 * Convert a packed TID value to components - slice, dual-sub-slice, sub-slice, euid, id
 * @ingroup GTREPLAY_EXECUTION
 * @param[in]  model        GEN model ID
 * @param[in]  tid          packed TID value to be unpacked
 * @param[out] slice        slice ID
 * @param[out] dualSubSlice dual sub-slice ID (0xFFFFFFFF if not applicable)
 * @param[out] subSlice     sub-slice ID
 * @param[out] euid         EU ID
 * @param[out] id           thread ID within EU
 * @par Availability:
 * - execution
 */
GTREPLAY_API
void GTReplay_ConvertTidToComponents(
    uint32_t  model,
    uint32_t  tid,
    uint32_t* slice,
    uint32_t* dualSubSlice,
    uint32_t* subSlice,
    uint32_t* euid,
    uint32_t* id);

/*************************************************************************
 *
 * Instruction inspection API
 *
 ************************************************************************/

/*!
 * @return opcode ID of a given instruction
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_Opcode(GTReplayIns ins);

/*!
 * @return opcode name string
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   opcode   an opcode ID
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
const char* GTReplay_OpcodeName(uint32_t opcode);

/*!
 * @return disasm string of the instruction
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
const char* GTReplay_Disasm(GTReplayIns ins);

/*!
 * @return data type of the instruction. Data type of the instruction 
 * is considered as the type of src0 operand or type of the dst operand if no sources
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_DataType(GTReplayIns ins);

/*!
 * @return data type name string
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   type   data type ID
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
const char* GTReplay_DataTypeName(uint32_t type);

/*!
 * @return number of existing opcodes
 * @ingroup GTREPLAY_INS_INSPECTION
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_NumOpcodes();

/*!
 * @return number of existing data types
 * @ingroup GTREPLAY_INS_INSPECTION
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_NumDataTypes();

/*!
 * @return true if the given instruction performs an operation on elements
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsOperational(GTReplayIns ins);

/*!
 * @return true if the given instruction is WAIT
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsWait(GTReplayIns ins);
/// Return true if the given instruction is SEND

/*!
 * @return true if the given instruction is SEND
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsSend(GTReplayIns ins);

/*!
 * @return true if the given instruction is SEND of BarierMsg to Gateway
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsBarrierMsgSend(GTReplayIns ins);

/*!
 * @return true if the given instruction is SEND to memory
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsSendToMemory(GTReplayIns ins);

/*!
 * @return true if the given instruction is read SEND to memory
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsMemoryRead(GTReplayIns ins);

/*!
 * @return true if the given instruction is write SEND to memory
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsMemoryWrite(GTReplayIns ins);

/*!
 * @return true if the given instruction is a memory fence message
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsMemoryFence(GTReplayIns ins);

/*!
 * @return memory surface ID (BTI index) for memory SEND instruction
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetMemorySurfaceId(GTReplayIns ins);

/*!
 * @return number of memory accesses for SEND instruction
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetNumOfMemoryAccesses(GTReplayIns ins);

/*!
 * @return size of a single memory access for a SEND instruction
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetMemoryAccessSize(GTReplayIns ins);

/*!
 * @return true if the given instruction is atomic SEND
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsAtomicSend(GTReplayIns ins);

/*!
 * @return true if the given instruction is a SEND to Shared Local Memory (SLM)
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsSlmSend(GTReplayIns ins);

/*!
 * @return true if the given instruction is a SEND with Binding Table Surface (BTS) accessing mode
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsBtsSend(GTReplayIns ins);

/*!
 * @return true if the given instruction is an End-Of-Thread (EOT) SEND
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_IsEOT(GTReplayIns ins);

/*!
 * @return true if the given instruction has destination operand
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_HasDestination(GTReplayIns ins);

/*!
 * @return a 32bit instruction pointer of the instruction
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins   an instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetInsIp(GTReplayIns ins);

/*************************************************************************
 *
 * Dynamic state observe API
 *
 ************************************************************************/

/*!
 * @return instruction dynamic exec_mask: exec_mask[0:exec_size-1] 
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   ins     an instruction handle.
 * @param[in]   state   a state handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_DynamicExecMask(GTReplayIns ins, GTReplayState state);

/*!
 * @return memory access address
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   ins       an instruction handle.
 * @param[in]   state     a state handle.
 * @param[in]   accessId  an access ID
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint64_t GTReplay_GetMemoryAccessAddr(GTReplayIns ins, GTReplayState state, uint32_t accessId);

/*!
 * Get memory write value
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   ins       an instruction handle.
 * @param[in]   state     a state handle.
 * @param[in]   accessId  an access ID
 * @param[out]  data      pointer to the data buffer for return value
 *                        (it is responsibility of the caller to allocate enough space)
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
void GTReplay_GetMemoryWriteValue(GTReplayIns ins, GTReplayState state, uint32_t accessId, uint8_t* data);

/*!
 * Return destination operand
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   ins                 an instruction handle.
 * @param[in]   state               a state handle.
 * @param[in]   currentExecMask     current execution mask
 * @param[out]  dst                 pointer to the data buffer for return value
 *                                  (it is responsibility of the caller to allocate enough space)
 * @param[out]  numOfElements       pointer to a buffer where the number of elements is returned
 * @param[out]  elementWidth        pointer to a buffer where the element width is returned
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
void GTReplay_GetDestination(GTReplayIns ins, GTReplayState state, uint32_t currentExecMask, uint8_t* dst, uint32_t* numOfElements, uint32_t* elementWidth);

/*!
 * Return source operand
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   ins                 an instruction handle.
 * @param[in]   state               a state handle.
 * @param[in]   srcId               the ID of the source operand (0, 1, or 2)
 * @param[out]  src                 pointer to the data buffer for return value
 *                                  (it is responsibility of the caller to allocate enough space)
 * @param[out]  numOfElements       pointer to a buffer where the number of elements is returned
 * @param[out]  elementWidth        pointer to a buffer where the element width is returned
 *
 * @par Availability:
 * - execution
 */
GTREPLAY_API
void GTReplay_GetSrcOperand(GTReplayIns ins, GTReplayState state, uint32_t srcId, uint8_t* src, uint32_t* numOfElements, uint32_t* elementWidth);

/*!
 * Return destination operand o fSEND instruction
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   ins                 an instruction handle.
 * @param[in]   state               a state handle.
 * @param[out]  dst                 pointer to the data buffer for return value
 *                                  (it is responsibility of the caller to allocate enough space)
 * @param[out]  numOfElements       pointer to a buffer where the number of elements is returned
 * @param[out]  elementWidth        pointer to a buffer where the element width is returned
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
void GTReplay_GetSendDestination(GTReplayIns ins, GTReplayState state, uint8_t* dst, uint32_t* numOfElements, uint32_t* elementWidth);

/*!
 * Return specified GRF register
 * -1 is returned in case of wrong parameters
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   state               a state handle.
 * @param[in]   regNum              register num
 * @param[out]  dst                 pointer to the data buffer for return value
 *                                  (it is responsibility of the caller to allocate enough space)
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetGrfReg(GTReplayState state, uint32_t regNum, uint8_t* dst);

/*!
 * Return single one-byte register value
 * -1 is returned in case of wrong parameters
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   state               a state handle.
 * @param[in]   regNum              register num
 * @param[in]   regSubNum           register sub num
 * @param[out]  reg                 pointer to a location where to return register value
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetGrfRegByte(GTReplayState state, uint32_t regNum, uint32_t regSubNum, uint8_t* reg);

/*!
 * Return single one-word register value
 * -1 is returned in case of wrong parameters
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   state               a state handle.
 * @param[in]   regNum              register num
 * @param[in]   regSubNum           register sub num
 * @param[out]  reg                 pointer to a location where to return register value
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetGrfRegWord(GTReplayState state, uint32_t regNum, uint32_t regSubNum, uint16_t* reg);

/*!
 * Return single one-dword register value
 * -1 is returned in case of wrong parameters
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   state               a state handle.
 * @param[in]   regNum              register num
 * @param[in]   regSubNum           register sub num
 * @param[out]  reg                 pointer to a location where to return register value
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetGrfRegDword(GTReplayState state, uint32_t regNum, uint32_t regSubNum, uint32_t* reg);

/*!
 * Return single one-qword register value
 * -1 is returned in case of wrong parameters
 * @ingroup GTREPLAY_STATE_INSPECTION
 * @param[in]   state               a state handle.
 * @param[in]   regNum              register num
 * @param[in]   regSubNum           register sub num
 * @param[out]  reg                 pointer to a location where to return register value
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetGrfRegQword(GTReplayState state, uint32_t regNum, uint32_t regSubNum, uint64_t* reg);

/*************************************************************************
 *
 * Kernel traversing API
 *
 ************************************************************************/

 /*!
  * @return 32-bit entry address of the kernel
  * @ingroup GTREPLAY_TRAVERSE
  * @param[in]   kernel  the target kernel.
  *
  * @par Availability:
  * - OnKernelBuild
  */
GTREPLAY_API
uint32_t GTReplay_GetKernelEntryAddress(GTReplayKernel kernel);

/*!
 * @return a handle to the head basic block of the kernel
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   kernel  the target kernel.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayBbl GTReplay_BblHead(GTReplayKernel kernel);

/*!
 * @return a handle to the next basic block after bbl
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   bbl  the target basic block handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayBbl GTReplay_BblNext(GTReplayBbl bbl);

/*!
 * Check whether the basic block handle is valid
 * @return TRUE if a given basic block is valid and FALSE otherwise
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   bbl     the basic block handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_BblValid(GTReplayBbl bbl);

/*!
 * @return a handle to the head instruction of the basic block
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   bbl     the basic block handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayIns GTReplay_InsHead(GTReplayBbl bbl);

/*!
 * @return a handle to the tail instruction of the basic block
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   bbl     the basic block handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayIns GTReplay_InsTail(GTReplayBbl bbl);

/*!
 * @return a handle to the next instruction after ins
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   ins the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayIns GTReplay_InsNext(GTReplayIns ins);

/*!
 * @return a handle to the instruction before ins in the same bbl
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   ins the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayIns GTReplay_InsPrev(GTReplayIns ins);

/*!
 * Check whether the instruction handle is valid
 * @return TRUE if a given instrcution is valid and FALSE otherwise
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   ins the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
bool GTReplay_InsValid(GTReplayIns ins);

/*!
 * @return the offset of the instruction relative to the beginning of the original kernel's binary
 * -1 is returned in case of an error
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_InsOffset(GTReplayIns ins);

/*!
 * Return the ID of the given basic block
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   bbl  the basic block handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_BblId(GTReplayBbl bbl);

/*!
 * @return instruction handle from id
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   kernel   a kernel handle
 * @param[in]   id       id of the instruction
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayIns GTReplay_Ins(GTReplayKernel kernel, uint32_t id);

/*!
 * @return the ID of the given instruction
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   ins   the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_InsId(GTReplayIns ins);

/*!
 * @return the ID of the corresponding basic block from given instruction
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   ins   the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_BblIdFromIns(GTReplayIns ins);

/*!
 * @return kernel handle from given instruction
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   ins   the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
GTReplayKernel GTReplay_Kernel(GTReplayIns ins);

/*!
 * @return the amount of instructions within given kernel
 * @ingroup GTREPLAY_TRAVERSE
 * @param[in]   kernel   a kernel handle
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_NumOfInstructions(GTReplayKernel kernel);

/*!
 * @return the opcode of an intruction
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetOpcode(GTReplayIns ins);

/*!
 * @return data type of the required source operand on success or GED_DATA_TYPE_INVAID if failed
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins the instruction handle.
 * @param[in]   srcId the source operand ID.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetSrcDataType(GTReplayIns ins, uint32_t srcId);

/*!
 * @return data type of the detstination operand on success or GED_DATA_TYPE_INVAID if failed
 * @ingroup GTREPLAY_INS_INSPECTION
 * @param[in]   ins the instruction handle.
 *
 * @par Availability:
 * - OnKernelBuild
 */
GTREPLAY_API
uint32_t GTReplay_GetDstDataType(GTReplayIns ins);

/// Entry point into GTraceReplay tool DLL    
GTREPLAY_API
void FASTCALL GTReplay_Entry(int argc, const char *argv[]);
}


#endif // GTREPLAY_H
