Skip to content

Commit 2e07044

Browse files
Wei-Chen-Inteligcbot
authored andcommitted
Remove .parameter directive from vISA assembly.
Remove .parameter directive from vISA assembly as vISA stack functions are not allowed to have parameters. Assert in CreateVISAInputVars if it's called by a non-kenrel function. Also add comments to describe vISA assembly structure and the meanings for each directive.
1 parent 6dc6c9b commit 2e07044

File tree

5 files changed

+43
-34
lines changed

5 files changed

+43
-34
lines changed

visa/CISA.l

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ static void appendStringLiteralChar(char c, char *buf, size_t
171171
CISAlval.string[yyleng] = '\0';
172172
return DIRECTIVE_IMPLICIT;
173173
}
174-
".parameter" {TRACE("** PARAMETER"); return DIRECTIVE_PARAMETER;}
175174
".function" {TRACE("** FUNCTION"); return DIRECTIVE_FUNC;}
176175
".global_function" {TRACE("** GLOBAL FUNCTION"); return DIRECTIVE_GLOBAL_FUNC;}
177176
".kernel" {TRACE("** KERNEL NAME DIRECTIVE"); return DIRECTIVE_KERNEL;}

visa/CISA.y

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ static int lscCheckExecSize(
2626
LSC_DATA_ORDER data_order,
2727
int exec_size);
2828

29-
//VISA_Type variable_declaration_and_type_check(char *var, Common_ISA_Var_Class type);
3029
void CISAerror(CISA_IR_Builder* builder, char const* msg);
3130
int yylex(CISA_IR_Builder *pBuilder);
3231
extern int CISAlineno;
@@ -37,9 +36,6 @@ static VISA_Align AlignBytesToVisaAlignment(int bytes);
3736
static int DataTypeSizeOf(VISA_Type type);
3837
static bool ParseEMask(const char* sym, VISA_EMask_Ctrl &emask);
3938

40-
41-
42-
4339
//
4440
// check if the cond is true.
4541
// if cond is false, then print errorMessage (syntax error) and YYABORT
@@ -64,9 +60,7 @@ static bool ParseEMask(const char* sym, VISA_EMask_Ctrl &emask);
6460
} while (0)
6561

6662
std::deque<const char*> switchLabels;
67-
char * switch_label_array[32];
6863
std::vector<VISA_opnd*> RTRWOperandsVec;
69-
int num_parameters;
7064

7165
VISA_RawOpnd* rawOperandArray[16];
7266

@@ -300,8 +294,7 @@ std::vector<attr_gen_struct*> AttrOptVar;
300294
%token DIRECTIVE_INPUT // .input
301295
%token DIRECTIVE_KERNEL // .kernel
302296
%token DIRECTIVE_KERNEL_ATTR // .kernel_attr
303-
%token DIRECTIVE_PARAMETER // .parameter
304-
%token DIRECTIVE_VERSION // .verions
297+
%token DIRECTIVE_VERSION // .version
305298

306299
// tokens to support .decl and .input
307300
%token ALIAS_EQ // .decl ... alias=...
@@ -675,7 +668,6 @@ Statement:
675668
| DirectiveGlobalFunction
676669
| DirectiveImplicitInput
677670
| DirectiveInput
678-
| DirectiveParameter
679671
| DirectiveFunc
680672
| DirectiveAttr
681673
| Instruction
@@ -816,13 +808,6 @@ InputOffset: %empty {$$ = 0;} | OFFSET_EQ IntExp {$$ = $2;}
816808
InputSize: SIZE_EQ IntExp {$$ = $2;}
817809

818810
///////////////////////////////////////////////////////////
819-
// ----- .parameter ------
820-
821-
DirectiveParameter:
822-
// 1 2 3 4
823-
DIRECTIVE_PARAMETER IDENT InputSize GenAttrOpt {
824-
ABORT_ON_FAIL(pBuilder->CISA_input_directive($2, 0, (unsigned short)$3, CISAlineno));
825-
}
826811
// ----- .attribute ------
827812

828813
DirectiveAttr:

visa/IsaDisassembly.cpp

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,36 @@ SPDX-License-Identifier: MIT
66
77
============================= end_copyright_notice ===========================*/
88

9-
/*
10-
* vISA IR Disassembler
11-
*
12-
*/
9+
//
10+
// vISA IR Disassembler
11+
//
12+
// A vISA assembly file (.visaasm) has one or more kernels and global functions.
13+
//
14+
// A kernel (.kernel) represents an entry point of GPU execution. It may only be
15+
// invoked from the host program.
16+
//
17+
// A global function (.global_function) may be invoked by a kernel or another
18+
// function through the FCALL/IFCALL instruction.
19+
//
20+
// Each kernel or function contains a number of variables (.decl). By default
21+
// the declares are printed at the top of the kernel/function (i.e., they are
22+
// visible everywhere inside the function), though they can also be interleaved
23+
// with the instructions so long as each variable is declared before its use.
24+
// C-style block scope support also exists with the {} operator.
25+
//
26+
// A kernel may declare input variables via the .input directive, which also
27+
// binds the variable to a fixed GRF location. Input variables are considered
28+
// live-in to the kernel.
29+
//
30+
// Each kernel/function may declare a number of attributes (.kernel_attr
31+
// directive) to communicate additional information about the function. They
32+
// have to be declared before any instructions in the function.
33+
//
34+
// A kernel/function's instructions are organized into subroutines (.function)
35+
// that are invoked through the CALL instruction. By convention the first
36+
// subroutine represents the entry point of the kernel/function, and it may not
37+
// be the target of a CALL.
38+
//
1339

1440
#include "IGC/common/StringMacros.hpp"
1541
#include <algorithm>
@@ -478,16 +504,13 @@ std::string printSurfaceDecl(const print_format_provider_t *header,
478504
}
479505

480506
std::string printFuncInput(const print_format_provider_t *header,
481-
unsigned declID, bool isKernel,
482-
const Options *options) {
507+
unsigned declID, const Options *options) {
483508
vISA_ASSERT_INPUT(header, "Argument Exception: argument header is NULL.");
484509
std::stringstream sstr;
485510

486511
const input_info_t *input = header->getInput(declID);
487-
if (!isKernel) {
488-
sstr << ".parameter " /* function */;
489-
} else if (!input->getImplicitKind()) {
490-
sstr << ".input " /* kernel */;
512+
if (!input->getImplicitKind()) {
513+
sstr << ".input ";
491514
} else {
492515
sstr << input->getImplicitKindString() << " ";
493516
}
@@ -499,9 +522,7 @@ std::string printFuncInput(const print_format_provider_t *header,
499522
sstr << Input_Class_String[input->getInputClass()] << input->index;
500523
}
501524

502-
if (isKernel)
503-
sstr << " offset=" << input->offset;
504-
525+
sstr << " offset=" << input->offset;
505526
sstr << " size=" << input->size;
506527

507528
return sstr.str();
@@ -3287,7 +3308,7 @@ std::string VISAKernel_format_provider::printKernelHeader(bool printVersion) {
32873308
}
32883309
// inputs to kernel
32893310
for (unsigned i = 0; i < getInputCount(); i++) {
3290-
sstr << "\n" << printFuncInput(this, i, isKernel, options);
3311+
sstr << "\n" << printFuncInput(this, i, options);
32913312
}
32923313

32933314
bool isTargetSet = false;

visa/IsaDisassembly.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ std::string printSamplerDecl(const print_format_provider_t *header,
3232
std::string printSurfaceDecl(const print_format_provider_t *header,
3333
unsigned declID, unsigned numPredefinedSurfaces);
3434
std::string printFuncInput(const print_format_provider_t *header,
35-
unsigned declID, bool isKernel,
36-
const Options *options);
35+
unsigned declID, const Options *options);
3736
std::string printOneAttribute(const print_format_provider_t *kernel,
3837
const attribute_info_t *attr);
3938
// Used for printing non-kernel attributes

visa/VISAKernelImpl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,11 @@ int VISAKernelImpl::CreateVISAInputVar(CISA_GEN_VAR *decl, uint16_t offset,
16591659
uint16_t size, uint8_t implicitKind) {
16601660
TIME_SCOPE(VISA_BUILDER_CREATE_VAR);
16611661

1662+
if (!getIsKernel()) {
1663+
vISA_ASSERT(false, "only kernels may have input variables");
1664+
return VISA_FAILURE;
1665+
}
1666+
16621667
unsigned int status = VISA_SUCCESS;
16631668
input_info_t *input = (input_info_t *)m_mem.alloc(sizeof(input_info_t));
16641669
input->kind = GetInputClass(decl->type);
@@ -1708,7 +1713,7 @@ int VISAKernelImpl::CreateVISAInputVar(CISA_GEN_VAR *decl, uint16_t offset,
17081713
VISAKernel_format_provider fmt(this);
17091714
m_CISABuilder->m_ssIsaAsm
17101715
<< printFuncInput(&fmt, m_printDeclIndex.input_index++,
1711-
getIsKernel(), getOptions())
1716+
getOptions())
17121717
<< "\n";
17131718
}
17141719
}

0 commit comments

Comments
 (0)