Skip to content

Commit 491d9a7

Browse files
committed
Remove vISA file-scope variables feature as it's no longer supported
Change-Id: Ide0141cc50034a2a96e7ef7604da9efc7114e8f7
1 parent 36256fe commit 491d9a7

25 files changed

+41
-962
lines changed

visa/BuildCISAIR.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ class CISA_IR_Builder : public VISABuilder
102102
CM_BUILDER_API virtual int AddKernel(VISAKernel *& kernel, const char* kernelName);
103103
CM_BUILDER_API virtual int AddFunction(VISAFunction *& function, const char* functionName);
104104
CM_BUILDER_API virtual int Compile(const char * isaFileNameint);
105-
CM_BUILDER_API virtual int CreateVISAFileVar(VISA_FileVar *& decl, char *name, unsigned int numElements, VISA_Type dataType,
106-
VISA_Align varAlign);
107105

108106
CM_BUILDER_API void SetOption(vISAOptions option, bool val) { m_options.setOption(option, val); }
109107
CM_BUILDER_API void SetOption(vISAOptions option, uint32_t val) { m_options.setOption(option, val); }
@@ -135,14 +133,6 @@ class CISA_IR_Builder : public VISABuilder
135133

136134
//CISA Build Functions
137135
bool CISA_IR_initialization(char *kernel_name, int line_no);
138-
bool CISA_general_variable_decl(char * var_name,
139-
unsigned int var_elemts_num,
140-
VISA_Type data_type,
141-
VISA_Align var_align,
142-
char * var_alias_name,
143-
int var_alias_offset,
144-
int line_no,
145-
vISA::G4_Declare *dcl);
146136
bool CISA_general_variable_decl(char * var_name,
147137
unsigned int var_elemts_num,
148138
VISA_Type data_type,
@@ -151,17 +141,7 @@ class CISA_IR_Builder : public VISABuilder
151141
int var_alias_offset,
152142
attr_gen_struct scope,
153143
int line_no);
154-
bool CISA_file_variable_decl(char * var_name,
155-
unsigned int var_elemts_num,
156-
VISA_Type data_type,
157-
VISA_Align var_align,
158-
int line_no,
159-
vISA::G4_Declare *dcl);
160-
bool CISA_file_variable_decl(char * var_name,
161-
unsigned int var_elemts_num,
162-
VISA_Type data_type,
163-
VISA_Align var_align,
164-
int line_no);
144+
165145
bool CISA_addr_variable_decl(char *var_name, unsigned int var_elements, VISA_Type data_type, attr_gen_struct scope, int line_no);
166146

167147
bool CISA_predicate_variable_decl(char *var_name,
@@ -176,8 +156,6 @@ class CISA_IR_Builder : public VISABuilder
176156

177157
bool CISA_surface_variable_decl(char *var_name, int num_elts, char* name, attr_gen_struct attr, int line_no);
178158

179-
bool CISA_vme_variable_decl(char *var_name, int num_elts, char* name, int line_no);
180-
181159
bool CISA_input_directive(char* var_name, short offset, unsigned short size, int line_no);
182160

183161
bool CISA_implicit_input_directive(char * argName, char * varName, short offset, unsigned short size, int line_no);
@@ -769,10 +747,6 @@ class CISA_IR_Builder : public VISABuilder
769747
//keeps track of functions for stitching purposes, after compilation.
770748
std::vector<VISAFunction *> m_functionsVector;
771749

772-
std::map<std::string, CISA_GEN_VAR *> m_file_var_name_to_decl_map;
773-
CISA_GEN_VAR * getFileVarDeclFromName(const std::string &name);
774-
bool setFileVarNameDeclMap(const std::string &name, CISA_GEN_VAR * genDecl);
775-
776750
// the current kernel being compiled. It is updated in the ::compile() function
777751
VISAKernelImpl* m_currentKernel;
778752

visa/BuildCISAIRImpl.cpp

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -388,19 +388,6 @@ int CISA_IR_Builder::AddKernel(VISAKernel *& kernel, const char* kernelName)
388388
m_kernel->SetGTPinInit(getGtpinInit());
389389
this->m_kernel_count++;
390390

391-
if(IS_GEN_BOTH_PATH)
392-
{
393-
// Append all globals in CISA_IR_Builder instance to new kernel
394-
unsigned int numFileScopeVars = this->m_cisaBinary->getNumFileVars();
395-
396-
for( unsigned int i = 0; i < numFileScopeVars; i++ )
397-
{
398-
VISA_FileVar* fileScopeVar = this->m_cisaBinary->getFileVar(i);
399-
400-
kerneltemp->addFileScopeVar(fileScopeVar, i);
401-
}
402-
}
403-
404391
return CM_SUCCESS;
405392
}
406393

@@ -1012,33 +999,6 @@ int CISA_IR_Builder::Compile( const char* nameInput)
1012999
return status;
10131000
}
10141001

1015-
CISA_GEN_VAR * CISA_IR_Builder::getFileVarDeclFromName(const std::string &name)
1016-
{
1017-
std::map<std::string, CISA_GEN_VAR *>::iterator it;
1018-
it = m_file_var_name_to_decl_map.find(name);
1019-
if(m_file_var_name_to_decl_map.end() == it)
1020-
{
1021-
return NULL;
1022-
}else
1023-
{
1024-
return it->second;
1025-
}
1026-
}
1027-
1028-
bool CISA_IR_Builder::setFileVarNameDeclMap(const std::string &name, CISA_GEN_VAR * genDecl)
1029-
{
1030-
bool succeeded = true;
1031-
1032-
//make sure mapping doesn't already exist
1033-
if( getFileVarDeclFromName(name) != NULL )
1034-
{
1035-
return false;
1036-
}
1037-
m_file_var_name_to_decl_map[name] = genDecl;
1038-
return succeeded;
1039-
}
1040-
1041-
10421002
bool CISA_IR_Builder::CISA_general_variable_decl(char * var_name,
10431003
unsigned int var_elemts_num,
10441004
VISA_Type data_type,
@@ -1052,14 +1012,9 @@ bool CISA_IR_Builder::CISA_general_variable_decl(char * var_name,
10521012

10531013
VISA_GenVar *parentDecl = NULL;
10541014

1055-
if( var_alias_name != NULL && strcmp(var_alias_name, "") != 0 )
1015+
if (var_alias_name && strcmp(var_alias_name, "") != 0)
10561016
{
10571017
parentDecl = (VISA_GenVar *)m_kernel->getDeclFromName(var_alias_name);
1058-
1059-
if( parentDecl == NULL )
1060-
{
1061-
parentDecl = (VISA_GenVar *)this->getFileVarDeclFromName(var_alias_name);
1062-
}
10631018
}
10641019

10651020
m_kernel->CreateVISAGenVar(genVar, var_name, var_elemts_num, data_type, var_align, parentDecl, var_alias_offset);
@@ -1072,61 +1027,6 @@ bool CISA_IR_Builder::CISA_general_variable_decl(char * var_name,
10721027
return true;
10731028
}
10741029

1075-
int CISA_IR_Builder::CreateVISAFileVar(VISA_FileVar *& decl, char *varName, unsigned int numberElements, VISA_Type dataType,
1076-
VISA_Align varAlign)
1077-
{
1078-
decl = (VISA_FileVar*)m_mem.alloc(sizeof(VISA_FileVar));
1079-
1080-
decl->type = FILESCOPE_VAR;
1081-
filescope_var_info_t *file_info = &decl->fileVar;
1082-
1083-
size_t len = strlen(varName);
1084-
file_info->bit_properties = dataType;
1085-
file_info->linkage = 2;
1086-
file_info->bit_properties += varAlign << 4;
1087-
file_info->bit_properties += STORAGE_REG << 7;
1088-
file_info->num_elements = (unsigned short)numberElements;
1089-
file_info->attribute_count = 0;
1090-
file_info->attributes = NULL;
1091-
file_info->name = (unsigned char *)m_mem.alloc(len + 1);
1092-
file_info->name_len = (unsigned short) len;
1093-
memcpy_s(file_info->name, len + 1, varName, file_info->name_len+1);
1094-
file_info->scratch = NULL;
1095-
1096-
decl->index = this->m_cisaBinary->setFileScopeVar(decl);
1097-
1098-
if( IS_GEN_BOTH_PATH )
1099-
{
1100-
// Append file var to all kernel/function objects in CISA_IR_Builder
1101-
for( std::list<VISAKernelImpl*>::iterator it = m_kernels.begin(), kend = m_kernels.end();
1102-
it != kend;
1103-
it++ )
1104-
{
1105-
VISAKernelImpl* kernel = (*it);
1106-
1107-
kernel->addFileScopeVar(decl, decl->index - 1);
1108-
}
1109-
}
1110-
1111-
return CM_SUCCESS;
1112-
}
1113-
1114-
bool CISA_IR_Builder::CISA_file_variable_decl(char * var_name,
1115-
unsigned int var_num_elements,
1116-
VISA_Type data_type,
1117-
VISA_Align var_align,
1118-
int line_no)
1119-
{
1120-
VISA_FileVar * decl;
1121-
if(getFileVarDeclFromName(var_name) != NULL)
1122-
{
1123-
return true;
1124-
}
1125-
this->CreateVISAFileVar(decl, var_name, var_num_elements, data_type, var_align);
1126-
this->setFileVarNameDeclMap(std::string(var_name), (CISA_GEN_VAR*) decl);
1127-
return true;
1128-
}
1129-
11301030
bool CISA_IR_Builder::CISA_addr_variable_decl(char *var_name, unsigned int var_elements, VISA_Type data_type, attr_gen_struct scope, int line_no)
11311031
{
11321032

visa/ByteCodeReaderNG.cpp

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ using namespace std;
6868
struct RoutineContainer
6969
{
7070
RoutineContainer():
71-
fileVarDecls(NULL),
7271
generalVarDecls(NULL), generalVarsCount(0),
7372
addressVarDecls(NULL), addressVarsCount(0),
7473
predicateVarDecls(NULL), predicateVarsCount(0),
@@ -84,7 +83,6 @@ struct RoutineContainer
8483
{
8584
stringPool.clear();
8685
}
87-
VISA_FileVar** fileVarDecls; unsigned fileVarsCount;
8886
VISA_GenVar** generalVarDecls; unsigned generalVarsCount;
8987
VISA_AddrVar** addressVarDecls; unsigned addressVarsCount;
9088
VISA_PredVar** predicateVarDecls; unsigned predicateVarsCount;
@@ -2226,7 +2224,8 @@ static void readRoutineNG(unsigned& bytePos, const char* buf, vISA::Mem_Manager&
22262224
uint8_t aliasScopeSpecifier = header.variables[declID].alias_scope_specifier;
22272225
int status = CM_SUCCESS;
22282226

2229-
if (aliasScopeSpecifier == 0)
2227+
assert(aliasScopeSpecifier == 0 && "file scope variables are no longer supported");
2228+
22302229
{
22312230
VISA_GenVar* parentDecl = NULL;
22322231
uint16_t aliasOffset = 0;
@@ -2251,23 +2250,6 @@ static void readRoutineNG(unsigned& bytePos, const char* buf, vISA::Mem_Manager&
22512250
ASSERT_USER(CM_SUCCESS == status,
22522251
"Failed to add VISA general variable.");
22532252
}
2254-
else
2255-
{
2256-
uint32_t aliasIndex = header.variables[declID].alias_index;
2257-
uint16_t aliasOffset = header.variables[declID].alias_offset;
2258-
2259-
// else assume resolved index = symbolic index
2260-
// This happens when builder API is used instead of reading from CISA file.
2261-
// The assumption here is that when builder API is used, variable and function
2262-
// resolution is done by caller of builder API already.
2263-
2264-
VISA_FileVar* parentDecl = container.fileVarDecls[aliasIndex];
2265-
status = kernelBuilderImpl->CreateVISAGenVar(
2266-
decl, header.strings[var->name_index], var->num_elements, varType,
2267-
varAlign, parentDecl, aliasOffset);
2268-
ASSERT_USER(CM_SUCCESS == status,
2269-
"Failed to add VISA general variable.");
2270-
}
22712253

22722254
for (unsigned ai = 0; ai < var->attribute_count; ai++)
22732255
{
@@ -2604,22 +2586,6 @@ extern bool readIsaBinaryNG(const char* buf, CISA_IR_Builder* builder, vector<VI
26042586
// would not work correctly
26052587
builder->CISA_IR_setVersion(isaHeader.major_version, isaHeader.minor_version);
26062588

2607-
unsigned fileVarsCount = 0;
2608-
VISA_FileVar** fileVarDecls = NULL;
2609-
2610-
fileVarsCount = isaHeader.num_filescope_variables;
2611-
fileVarDecls = (VISA_FileVar**)mem.alloc(sizeof(VISA_FileVar*)* isaHeader.num_filescope_variables);
2612-
for (unsigned i = 0; i < isaHeader.num_filescope_variables; i++)
2613-
{
2614-
filescope_var_info_t* filescope_variable = &isaHeader.filescope_variables[i];
2615-
VISA_Type type = (VISA_Type)((filescope_variable->bit_properties) & 0xF);
2616-
VISA_Align align = (VISA_Align)((filescope_variable->bit_properties >> 4) & 0x7);
2617-
2618-
VISA_FileVar* fileVar = NULL;
2619-
builder->CreateVISAFileVar(fileVar, (char*)filescope_variable->name, filescope_variable->num_elements, type, align);
2620-
fileVarDecls[i] = fileVar;
2621-
}
2622-
26232589
if (kernelName)
26242590
{
26252591
int kernelIndex = -1;
@@ -2641,8 +2607,6 @@ extern bool readIsaBinaryNG(const char* buf, CISA_IR_Builder* builder, vector<VI
26412607

26422608
RoutineContainer container;
26432609
container.builder = builder;
2644-
container.fileVarDecls = fileVarDecls;
2645-
container.fileVarsCount = fileVarsCount;
26462610
container.kernelBuilder = NULL;
26472611
container.majorVersion = isaHeader.major_version;
26482612
container.minorVersion = isaHeader.minor_version;
@@ -2678,8 +2642,6 @@ extern bool readIsaBinaryNG(const char* buf, CISA_IR_Builder* builder, vector<VI
26782642

26792643
RoutineContainer container;
26802644
container.builder = builder;
2681-
container.fileVarDecls = fileVarDecls;
2682-
container.fileVarsCount = fileVarsCount;
26832645
container.kernelBuilder = NULL;
26842646
container.majorVersion = isaHeader.major_version;
26852647
container.minorVersion = isaHeader.minor_version;
@@ -2697,8 +2659,6 @@ extern bool readIsaBinaryNG(const char* buf, CISA_IR_Builder* builder, vector<VI
26972659
RoutineContainer container;
26982660

26992661
container.builder = builder;
2700-
container.fileVarDecls = fileVarDecls;
2701-
container.fileVarsCount = fileVarsCount;
27022662
container.majorVersion = isaHeader.major_version;
27032663
container.minorVersion = isaHeader.minor_version;
27042664

visa/CISA.y

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ DirectiveVersion : DIRECTIVE_VERSION NUMBER DOT NUMBER
613613
}
614614

615615
/* ----- .decl ----- */
616-
DirectiveDecl : DeclFileScopeVariable
617-
| DeclVariable
616+
DirectiveDecl : DeclVariable
618617
| DeclAddress
619618
| DeclPredicate
620619
| DeclSampler
@@ -625,16 +624,6 @@ DeclFunctions: FUNC_DIRECTIVE_DECL STRING_LITERAL NUMBER
625624
{
626625
pCisaBuilder->CISA_create_func_decl($2, (int)$3, CISAlineno);
627626
}
628-
DeclFileScopeVariable: DIRECTIVE_DECL VAR F_CLASS DECL_DATA_TYPE NUM_ELTS NUMBER AlignType GEN_ATTR
629-
{
630-
attr_gen_struct temp_struct;
631-
temp_struct.value = $8.value;
632-
temp_struct.name = $8.name;
633-
temp_struct.string_val = $8.string_val;
634-
temp_struct.isInt = $8.isInt;
635-
temp_struct.attr_set = $8.attr_set;
636-
pCisaBuilder->CISA_file_variable_decl($2, (unsigned int)$6, $4, $7, CISAlineno);
637-
};
638627

639628
// 1 2 3 4 5 6 7 8 9
640629
DeclVariable: DIRECTIVE_DECL VAR G_CLASS DECL_DATA_TYPE NUM_ELTS NUMBER AlignType AliasInfo GEN_ATTR

0 commit comments

Comments
 (0)