Commit 7ce82d9d authored by Chen, Weiyu's avatar Chen, Weiyu Committed by gbsbuild

Remove dependency on vISA binary header when printing a vISA instruction

Change-Id: I2d53196cef17be2608d112259c89775d37b10c39
parent 952d4d1f
......@@ -292,7 +292,7 @@ static VISA_RawOpnd* readRawOperandNG(unsigned& bytePos, const char* buf, Routin
VISAKernelImpl* kernelBuilderImpl = ((VISAKernelImpl*)container.kernelBuilder);
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count(majorVersion, minorVersion);
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count();
VISA_GenVar* decl = NULL;
VISA_RawOpnd* opnd = NULL;
......@@ -388,7 +388,7 @@ static VISA_VectorOpnd* readVectorOperandNG(unsigned& bytePos, const char* buf,
uint16_t width = Get_Common_ISA_Region_Value((Common_ISA_Region_Val)((region >> 4 ) & 0xF));
uint16_t h_stride = Get_Common_ISA_Region_Value((Common_ISA_Region_Val)((region >> 8 ) & 0xF));
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count(majorVersion, minorVersion);
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count();
VISA_Modifier mod = modifier;
VISA_VectorOpnd* opnd = NULL;
......@@ -2257,7 +2257,7 @@ static void readRoutineNG(unsigned& bytePos, const char* buf, vISA::Mem_Manager&
readVarBytes(majorVersion, minorVersion, header.name_index, bytePos, buf);
/// read general variables
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count(majorVersion, minorVersion);
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count();
readVarBytes(majorVersion, minorVersion, header.variable_count, bytePos, buf);
header.variables = (var_info_t*)mem.alloc(sizeof(var_info_t) * (header.variable_count + numPreDefinedVars));
container.generalVarDecls = (VISA_GenVar**)mem.alloc(sizeof(VISA_GenVar*) * (header.variable_count + numPreDefinedVars));
......@@ -2489,7 +2489,7 @@ static void readRoutineNG(unsigned& bytePos, const char* buf, vISA::Mem_Manager&
// read surface variables
READ_CISA_FIELD(header.surface_count, uint8_t, bytePos, buf);
unsigned num_pred_surf = Get_CISA_PreDefined_Surf_Count(majorVersion, minorVersion);
unsigned num_pred_surf = Get_CISA_PreDefined_Surf_Count();
header.surface_count += (uint8_t) num_pred_surf;
header.surface_attrs = (bool*)mem.alloc(sizeof(bool) * header.surface_count);
memset(header.surface_attrs, 0, sizeof(bool) * header.surface_count);
......
......@@ -657,7 +657,7 @@ void CisaBinary::isaDumpVerify(
{
CisaFramework::CisaInst * cisa_inst = *inst_iter;
CISA_INST * inst = cisa_inst->getCISAInst();
sstr << printInstruction(m_header, header, inst, kTemp->getOptions()) << endl;
sstr << printInstruction(header, inst, kTemp->getOptions()) << endl;
}
writeIsaAsmFile(asmName.str(), sstr.str());
......
......@@ -1434,14 +1434,14 @@ VISA_Modifier Get_Common_ISA_SrcMod_From_G4_Mod(G4_SrcModifier mod )
VISA_Type getVectorOperandType(const common_isa_header& isaHeader, const kernel_format_t* header, const vector_opnd& opnd)
{
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count(isaHeader.major_version, isaHeader.minor_version);
unsigned numPreDefinedVars = Get_CISA_PreDefined_Var_Count();
switch (opnd.getOperandClass())
{
case OPERAND_GENERAL:
if (opnd.opnd_val.gen_opnd.index < numPreDefinedVars)
{
// One of the pre-defined variables
return getPredefinedVarType(mapExternalToInternalPreDefVar(opnd.getOperandIndex(), isaHeader.major_version, isaHeader.minor_version));
return getPredefinedVarType(mapExternalToInternalPreDefVar(opnd.getOperandIndex()));
}
else
{
......
......@@ -95,7 +95,7 @@ inline uint32_t getVersionAsInt(uint32_t major, uint32_t minor)
return major * 100 + minor;
}
inline unsigned int Get_CISA_PreDefined_Var_Count( unsigned char major_v, unsigned char minor_v )
inline unsigned int Get_CISA_PreDefined_Var_Count()
{
return COMMON_ISA_NUM_PREDEFINED_VAR_VER_3;
}
......@@ -104,17 +104,10 @@ extern const char* createStringCopy(const char* name, vISA::Mem_Manager &m_mem);
extern std::string sanitizeString(std::string& str);
inline unsigned int Get_CISA_PreDefined_Surf_Count( unsigned char major_v, unsigned char minor_v )
inline unsigned int Get_CISA_PreDefined_Surf_Count()
{
uint32_t version = getVersionAsInt(major_v, minor_v);
if (version <= 300)
{
return COMMON_ISA_NUM_PREDEFINED_SURF_VER_2_1;
}
else
{
return COMMON_ISA_NUM_PREDEFINED_SURF_VER_3_1;
}
return COMMON_ISA_NUM_PREDEFINED_SURF_VER_3_1;
}
inline unsigned
......
This diff is collapsed.
......@@ -37,7 +37,7 @@ extern std::string printKernelHeader(const common_isa_header& isaHeader, const k
///
/// - Takes an isa header, a kernel/function header, and isa instruction and returns a string contraining the instruction's isaasm.
///
extern std::string printInstruction(const common_isa_header& isaHeader, const kernel_format_t* header, const CISA_INST* instruction, Options *opt);
extern std::string printInstruction(const kernel_format_t* header, const CISA_INST* instruction, Options *opt);
///
/// - Takes a isa header, a kernel header, and a instruction lists and returns a string contraining the kernel's entire isaasm.
......@@ -50,7 +50,7 @@ extern std::string printKernel(const common_isa_header& isaHeader, const kernel_
extern std::string printFunction(const common_isa_header& isaHeader, const function_format_t* header, std::list<CISA_INST*>& instructions, int funcionId, Options *opt);
/// Exposing these declare print functions for use by verifier diagnostics code or for disassembly output.
extern std::string printPredicateDecl(const common_isa_header& isaHeader, const kernel_format_t* header, unsigned declID);
extern std::string printPredicateDecl(const kernel_format_t* header, unsigned declID);
extern std::string printVariableDecl (const common_isa_header& isaHeader, const kernel_format_t* header, unsigned declID, bool isKernel, unsigned int funcId, Options *options);
extern std::string printAddressDecl (const common_isa_header& isaHeader, const kernel_format_t* header, unsigned declID);
extern const char* printAsmName(const kernel_format_t* header);
......
This diff is collapsed.
This diff is collapsed.
......@@ -70,7 +70,7 @@ typedef struct
const char* str;
} PreDefinedVarInfo;
extern PreDefinedVarsInternal mapExternalToInternalPreDefVar(int id, uint32_t majorVersion, uint32_t minorVersion);
extern PreDefinedVarsInternal mapExternalToInternalPreDefVar(int id);
extern VISA_Type getPredefinedVarType(PreDefinedVarsInternal id);
extern const char * getPredefinedVarString(PreDefinedVarsInternal id);
......
......@@ -508,7 +508,7 @@ int VISAKernelImpl::InitializeKernel(const char *kernel_name)
{
int status = CM_SUCCESS;
m_num_pred_vars = Get_CISA_PreDefined_Var_Count(m_major_version, m_minor_version);
m_num_pred_vars = Get_CISA_PreDefined_Var_Count();
setName(kernel_name);
if( IS_GEN_BOTH_PATH && m_isKernel)
{
......@@ -559,7 +559,7 @@ int VISAKernelImpl::CISABuildPreDefinedDecls()
for( unsigned int i = 0; i < m_num_pred_vars; i++ )
{
auto predefId = mapExternalToInternalPreDefVar(i, m_major_version, m_minor_version);
auto predefId = mapExternalToInternalPreDefVar(i);
CISA_GEN_VAR* decl = (CISA_GEN_VAR *)m_mem.alloc(sizeof(CISA_GEN_VAR));
decl->type = GENERAL_VAR;
decl->index = m_var_info_count++;
......@@ -597,7 +597,7 @@ int VISAKernelImpl::CISABuildPreDefinedDecls()
}
//SLM T0/Global Vars
for(int i = 0; i < (int) Get_CISA_PreDefined_Surf_Count(m_major_version, m_minor_version); i++)
for(int i = 0; i < (int) Get_CISA_PreDefined_Surf_Count(); i++)
{
//string_pool_lookup_and_insert(name, SURFACE_VAR, ISA_TYPE_ADDR);
VISA_SurfaceVar* decl = (VISA_SurfaceVar *)m_mem.alloc(sizeof(CISA_GEN_VAR));
......@@ -803,9 +803,9 @@ int VISAKernelImpl::CreateVISAGenVar(VISA_GenVar *& decl, const char *varName, i
info->dcl->setAliasDeclare(aliasDcl->dcl, aliasOffset);
// check if parent declare is one of the predefined
if (parentDecl->index < Get_CISA_PreDefined_Var_Count(m_major_version, m_minor_version))
if (parentDecl->index < Get_CISA_PreDefined_Var_Count())
{
m_builder->preDefVars.setHasPredefined(mapExternalToInternalPreDefVar(parentDecl->index, m_major_version, m_minor_version), true);
m_builder->preDefVars.setHasPredefined(mapExternalToInternalPreDefVar(parentDecl->index), true);
}
}
}
......@@ -1939,7 +1939,7 @@ int VISAKernelImpl::CreateVISASrcOperand(VISA_VectorOpnd *& cisa_opnd, VISA_GenV
cisa_opnd = (VISA_VectorOpnd *)getOpndFromPool();
if(IS_GEN_BOTH_PATH)
{
if( cisa_decl->index < Get_CISA_PreDefined_Var_Count(m_major_version, m_minor_version) )
if( cisa_decl->index < Get_CISA_PreDefined_Var_Count() )
{
cisa_opnd->g4opnd = CommonISABuildPreDefinedSrc(cisa_decl->index, vStride, width, hStride, rowOffset, colOffset, mod);
}
......@@ -2160,7 +2160,7 @@ int VISAKernelImpl::CreateVISAStateOperand(VISA_VectorOpnd *&cisa_opnd, CISA_GEN
{
// pre-defined surface
if( opndClass == STATE_OPND_SURFACE &&
decl->index < Get_CISA_PreDefined_Surf_Count( m_major_version, m_minor_version ) )
decl->index < Get_CISA_PreDefined_Surf_Count() )
{
int64_t immVal = Get_PreDefined_Surf_Index(decl->index);
if (immVal == PREDEF_SURF_252)
......@@ -2377,7 +2377,7 @@ int VISAKernelImpl::CreateStateInstUseFastPath(VISA_StateOpndHandle *&cisa_opnd,
case SURFACE_VAR:
{
uint16_t surf_id = (uint16_t)decl->index;
if (surf_id >= Get_CISA_PreDefined_Surf_Count(m_major_version, m_minor_version))
if (surf_id >= Get_CISA_PreDefined_Surf_Count())
{
cisa_opnd->g4opnd = m_builder->createSrcRegRegion(Mod_src_undef, Direct, dcl->getRegVar(), 0, 0,
m_builder->getRegionScalar(), Type_UD);
......@@ -7735,11 +7735,11 @@ void VISAKernelImpl::finalizeKernel()
DEBUG_PRINT_SIZE("size after samplers: ", SIZE_VALUE);
/*****SURFACES******/
unsigned int adjSurfaceCount = m_surface_count - Get_CISA_PreDefined_Surf_Count(m_major_version, m_minor_version);
unsigned int adjSurfaceCount = m_surface_count - Get_CISA_PreDefined_Surf_Count();
m_cisa_kernel.surface_count = (uint8_t) adjSurfaceCount;
m_cisa_kernel.surfaces = (state_info_t * ) m_mem.alloc(sizeof(state_info_t) * adjSurfaceCount);
for(unsigned int i = 0, j = Get_CISA_PreDefined_Surf_Count(m_major_version, m_minor_version); i < adjSurfaceCount; i++, j++)
for(unsigned int i = 0, j = Get_CISA_PreDefined_Surf_Count(); i < adjSurfaceCount; i++, j++)
{
state_info_t * temp = &m_surface_info_list.at(j)->stateVar;
m_cisa_kernel.surfaces[i] = *temp;
......@@ -8192,7 +8192,7 @@ G4_Operand* VISAKernelImpl::CommonISABuildPreDefinedSrc(int index, uint16_t vStr
{
RegionDesc *rd = m_builder->createRegionDesc( vStride, width, hStride );
G4_Operand* tmpsrc = NULL;
PreDefinedVarsInternal internalIndex = mapExternalToInternalPreDefVar(index, m_major_version, m_minor_version);
PreDefinedVarsInternal internalIndex = mapExternalToInternalPreDefVar(index);
switch (internalIndex)
{
case PreDefinedVarsInternal::X:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment