Skip to content

Commit 803061c

Browse files
trbauersys_zuul
authored andcommitted
Two fixes for vISA assembly.
1. Corrects resinfo and sampleinfo syntax to accept the channel set argument next to the opcode rather than across the execsize. Also the prefixing . was missing from disassembly (breaking parsing). 2. restores the .implicit* directive. It's unclear if this is still used, so we will continue to support it. Change-Id: I654439309238212fb80d93920ce9733e0f1fb84c
1 parent d9c4fb6 commit 803061c

File tree

4 files changed

+91
-55
lines changed

4 files changed

+91
-55
lines changed

visa/BuildCISAIRImpl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,8 @@ bool CISA_IR_Builder::CISA_create_info_3d_instruction(
23292329
return true;
23302330
}
23312331

2332-
bool CISA_IR_Builder::createSample4Instruction(VISA_opnd* pred,
2332+
bool CISA_IR_Builder::createSample4Instruction(
2333+
VISA_opnd* pred,
23332334
VISASampler3DSubOpCode subOpcode,
23342335
bool pixelNullMask,
23352336
ChannelMask channel,

visa/CISA.l

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,28 +177,34 @@ static void appendStringLiteralChar(char c, char *buf, size_t
177177

178178
".version" {TRACE("\n** VERSION "); return DIRECTIVE_VERSION;}
179179
".decl" {TRACE("\n** DECLARE "); return DIRECTIVE_DECL;}
180-
".funcdecl" {TRACE("\n** FUNCTION DECLARE "); return FUNC_DIRECTIVE_DECL;}
180+
".funcdecl" {TRACE("\n** FUNCTION DECLARE "); return DIRECTIVE_FUNCDECL;}
181181
".attr" {TRACE("\n** ATTR "); return DIRECTIVE_ATTR;}
182182
".kernel_attr" {TRACE("\n** KERNEL ATTR "); return DIRECTIVE_KERNEL_ATTR;}
183183
".input" {TRACE("\n** INPUT "); return DIRECTIVE_INPUT;}
184+
"."implicit[a-zA-Z0-9_\-$@?]* {
185+
TRACE("\n** DIRECTIVE_IMPLICIT ");
186+
CISAlval.string = strdup(yytext);
187+
CISAlval.string[yyleng] = '\0';
188+
return DIRECTIVE_IMPLICIT;
189+
}
184190
".parameter" {TRACE("\n** PARAMETER "); return DIRECTIVE_PARAMETER;}
185191
".function" {TRACE("\n** FUNCTION "); return DIRECTIVE_FUNC;}
186192
".global_function" {TRACE("\n** GLOBAL FUNCTION "); return DIRECTIVE_GLOBAL_FUNC;}
187193
".kernel" {TRACE("\n** KERNEL NAME DIRECTIVE "); return DIRECTIVE_KERNEL;}
188194

189195
num_elts[ ]*= {TRACE("\n** NUM_ELTS_EQ "); return NUM_ELTS_EQ;}
190-
align[ ]*= { TRACE("\n** ALIGN_EQ "); return ALIGN_EQ;}
191-
offset[ ]*= { TRACE("\n** OFFSET_EQ "); return OFFSET_EQ;}
192-
size[ ]*= { TRACE("\n** SIZE_EQ "); return SIZE_EQ;}
193-
alias[ ]*= { TRACE("\n** ALIAS_EQ "); return ALIAS_EQ;}
194-
attr[ ]*= { TRACE("\n** ATTR_EQ "); return ATTR_EQ;}
195-
v_name[ ]*= { TRACE("\n** V_NAME_EQ "); return V_NAME_EQ;}
196-
197-
v_type[ ]*=[ ]*G {TRACE("\n** G_CLASS "); return G_CLASS;}
198-
v_type[ ]*=[ ]*A {TRACE("\n** A_CLASS "); return A_CLASS;}
199-
v_type[ ]*=[ ]*P {TRACE("\n** P_CLASS "); return P_CLASS;}
200-
v_type[ ]*=[ ]*S {TRACE("\n** S_CLASS "); return S_CLASS;}
201-
v_type[ ]*=[ ]*T {TRACE("\n** T_CLASS "); return T_CLASS;}
196+
align[ ]*= {TRACE("\n** ALIGN_EQ "); return ALIGN_EQ;}
197+
offset[ ]*= {TRACE("\n** OFFSET_EQ "); return OFFSET_EQ;}
198+
size[ ]*= {TRACE("\n** SIZE_EQ "); return SIZE_EQ;}
199+
alias[ ]*= {TRACE("\n** ALIAS_EQ "); return ALIAS_EQ;}
200+
attr[ ]*= {TRACE("\n** ATTR_EQ "); return ATTR_EQ;}
201+
v_name[ ]*= {TRACE("\n** V_NAME_EQ "); return V_NAME_EQ;}
202+
203+
v_type[ ]*=[ ]*G {TRACE("\n** V_TYPE_EQ_G "); return V_TYPE_EQ_G;}
204+
v_type[ ]*=[ ]*A {TRACE("\n** V_TYPE_EQ_A "); return V_TYPE_EQ_A;}
205+
v_type[ ]*=[ ]*P {TRACE("\n** V_TYPE_EQ_P "); return V_TYPE_EQ_P;}
206+
v_type[ ]*=[ ]*S {TRACE("\n** V_TYPE_EQ_S "); return V_TYPE_EQ_S;}
207+
v_type[ ]*=[ ]*T {TRACE("\n** V_TYPE_EQ_T "); return V_TYPE_EQ_T;}
202208

203209

204210
"."(add|sub|inc|dec|min|max|xchg|cmpxchg|and|or|xor|minsint|maxsint|fmax|fmin|fcmpwr) {

visa/CISA.y

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -239,32 +239,35 @@ VISA_RawOpnd* rawOperandArray[16];
239239
%token <align> ALIGN_KEYWORD
240240
%token <atomic_op> ATOMIC_SUB_OP
241241

242-
%token CPS // .cps
243-
%token DIRECTIVE_ATTR // .attr
244-
%token DIRECTIVE_DECL // .decl
245-
%token DIRECTIVE_FUNC // .function
246-
%token DIRECTIVE_GLOBAL_FUNC // .global_function
247-
%token DIRECTIVE_INPUT // .input
248-
%token DIRECTIVE_KERNEL // .kernel
249-
%token DIRECTIVE_KERNEL_ATTR // .kernel_attr
250-
%token DIRECTIVE_PARAMETER // .parameter
251-
%token DIRECTIVE_VERSION // .verions
252-
253-
242+
// directives
243+
%token DIRECTIVE_ATTR // .attr
244+
%token DIRECTIVE_DECL // .decl
245+
%token DIRECTIVE_FUNC // .function
246+
%token DIRECTIVE_FUNCDECL // .funcdecl
247+
%token DIRECTIVE_GLOBAL_FUNC // .global_function
248+
%token <string> DIRECTIVE_IMPLICIT // .implicit*
249+
%token DIRECTIVE_INPUT // .input
250+
%token DIRECTIVE_KERNEL // .kernel
251+
%token DIRECTIVE_KERNEL_ATTR // .kernel_attr
252+
%token DIRECTIVE_PARAMETER // .parameter
253+
%token DIRECTIVE_VERSION // .verions
254+
255+
// tokens to support .decl and .input
254256
%token ALIAS_EQ // .decl ... alias=...
255257
%token ALIGN_EQ // .decl ... align=...
256258
%token ATTR_EQ // .decl ... attr=...
257259
%token OFFSET_EQ
258260
%token NUM_ELTS_EQ
259261
%token V_NAME_EQ
260262
%token SIZE_EQ
261-
%token G_CLASS
262-
%token P_CLASS
263-
%token A_CLASS
264-
%token S_CLASS
265-
%token T_CLASS
263+
%token V_TYPE_EQ_G // v_type=G
264+
%token V_TYPE_EQ_P
265+
%token V_TYPE_EQ_A
266+
%token V_TYPE_EQ_S
267+
%token V_TYPE_EQ_T
268+
266269

267-
%token FUNC_DIRECTIVE_DECL // .funcdecl
270+
%token CPS // .cps
268271
%token NON_UNIFORM_SAMPLER // .divS
269272
%token PIXEL_NULL_MASK // .pixel_null_mask
270273
%token RAW_SENDC_STRING // raw_sendc
@@ -543,6 +546,7 @@ NewlinesOpt: %empty | Newlines
543546
Statement:
544547
DirectiveDecl
545548
| DirectiveGlobalFunction
549+
| DirectiveImplicitInput
546550
| DirectiveInput
547551
| DirectiveParameter
548552
| DirectiveFunc
@@ -603,47 +607,47 @@ DirectiveDecl:
603607
| DeclPredicate
604608
| DeclSampler
605609
| DeclSurface
606-
| DeclFunctions
610+
| DeclFunction
607611

608-
DeclFunctions: FUNC_DIRECTIVE_DECL STRING_LIT
612+
DeclFunction: DIRECTIVE_FUNCDECL STRING_LIT
609613
{
610614
// do nothing as it's informational only
611615
}
612616

613617
DeclVariable:
614-
// 1 2 3 4 5 6 7 8 9
615-
DIRECTIVE_DECL IDENT G_CLASS DECL_DATA_TYPE NUM_ELTS_EQ IntExp AlignAttrOpt AliasAttrOpt GenAttrOpt
618+
// 1 2 3 4 5 6 7 8 9
619+
DIRECTIVE_DECL IDENT V_TYPE_EQ_G DECL_DATA_TYPE NUM_ELTS_EQ IntExp AlignAttrOpt AliasAttrOpt GenAttrOpt
616620
{
617621
if (!pBuilder->CISA_general_variable_decl($2, (unsigned int)$6, $4, $7, $8.aliasname, $8.offset, $9, CISAlineno)) {
618622
YYABORT; // error already reported
619623
}
620624
}
621625

622-
// 1 2 3 4 5 6
623-
DeclAddress: DIRECTIVE_DECL IDENT A_CLASS NUM_ELTS_EQ IntExp GenAttrOpt
626+
// 1 2 3 4 5 6
627+
DeclAddress: DIRECTIVE_DECL IDENT V_TYPE_EQ_A NUM_ELTS_EQ IntExp GenAttrOpt
624628
{
625629
pBuilder->CISA_addr_variable_decl($2, (unsigned int)$5, ISA_TYPE_UW, $6, CISAlineno);
626630
}
627631

628-
// 1 2 3 4 5 6
629-
DeclPredicate: DIRECTIVE_DECL IDENT P_CLASS NUM_ELTS_EQ IntExp GenAttrOpt
632+
// 1 2 3 4 5 6
633+
DeclPredicate: DIRECTIVE_DECL IDENT V_TYPE_EQ_P NUM_ELTS_EQ IntExp GenAttrOpt
630634
{
631635
if (!pBuilder->CISA_predicate_variable_decl($2, (unsigned int)$5, $6, CISAlineno)) {
632636
YYABORT; // error already reported
633637
}
634638
}
635639

636-
// 1 2 3 4 5 6 7
637-
DeclSampler: DIRECTIVE_DECL IDENT S_CLASS NUM_ELTS_EQ IntExp VNameEqOpt GenAttrOpt
640+
// 1 2 3 4 5 6 7
641+
DeclSampler: DIRECTIVE_DECL IDENT V_TYPE_EQ_S NUM_ELTS_EQ IntExp VNameEqOpt GenAttrOpt
638642
{
639643
if (!pBuilder->CISA_sampler_variable_decl($2, (int)$5, $6, CISAlineno)) {
640644
YYABORT; // error already reported
641645
}
642646
}
643647
VNameEqOpt: %empty {$$ = "";} | V_NAME_EQ IDENT {$$ = $2;};
644648

645-
// 1 2 3 4 5 6 7
646-
DeclSurface: DIRECTIVE_DECL IDENT T_CLASS NUM_ELTS_EQ IntExp VNameEqOpt GenAttrOpt
649+
// 1 2 3 4 5 6 7
650+
DeclSurface: DIRECTIVE_DECL IDENT V_TYPE_EQ_T NUM_ELTS_EQ IntExp VNameEqOpt GenAttrOpt
647651
{
648652
if (!pBuilder->CISA_surface_variable_decl($2, (int)$5, $6, $7, CISAlineno)) {
649653
YYABORT; // error already reported
@@ -671,9 +675,33 @@ DirectiveInput:
671675
}
672676
}
673677

678+
///////////////////////////////////////////////////////////
679+
// ----- .implicit* inputs ------
680+
DirectiveImplicitInput:
681+
// 1 2 3 4 5
682+
DIRECTIVE_IMPLICIT IDENT InputOffset InputSize GenAttrOpt
683+
{
684+
pBuilder->CISA_implicit_input_directive(
685+
$1, $2, (short)$3, (unsigned short)$4, CISAlineno);
686+
}
687+
|
688+
// 1 2 3 4
689+
DIRECTIVE_IMPLICIT IDENT InputOffset GenAttrOpt
690+
{
691+
int64_t size = 0;
692+
if (!pBuilder->CISA_eval_sizeof_decl(CISAlineno, $2, size)) {
693+
YYABORT; // error already reported
694+
}
695+
MUST_HOLD(size < 0x10000, "declaration size is too large");
696+
if (!pBuilder->CISA_input_directive($2, (short)$3, (unsigned short)size, CISAlineno)) {
697+
YYABORT; // error already reported
698+
}
699+
}
700+
674701
InputOffset: %empty {$$ = 0;} | OFFSET_EQ IntExp {$$ = $2;}
675702
InputSize: SIZE_EQ IntExp {$$ = $2;}
676703

704+
///////////////////////////////////////////////////////////
677705
// ----- .parameter ------
678706

679707
DirectiveParameter:
@@ -1199,19 +1227,19 @@ Gather43dInstruction: Predicate SAMPLE4_3D_OP PixelNullMaskEnableOpt SAMPLER_CHA
11991227
PixelNullMaskEnableOpt: %empty {$$ = false;} | PIXEL_NULL_MASK {$$ = true;}
12001228

12011229
// 1 2 3 4 5 6
1202-
ResInfo3dInstruction: RESINFO_OP_3D ExecSize SAMPLER_CHANNEL Var RawOperand RawOperand
1230+
ResInfo3dInstruction: RESINFO_OP_3D SAMPLER_CHANNEL ExecSize Var RawOperand RawOperand
12031231
{
12041232
pBuilder->CISA_create_info_3d_instruction(
1205-
VISA_3D_RESINFO, $2.emask, $2.exec_size,
1206-
ChannelMask::createFromAPI($3), $4, $5.cisa_gen_opnd, $6.cisa_gen_opnd, CISAlineno);
1233+
VISA_3D_RESINFO, $3.emask, $3.exec_size,
1234+
ChannelMask::createFromAPI($2), $4, $5.cisa_gen_opnd, $6.cisa_gen_opnd, CISAlineno);
12071235
}
12081236

1209-
// 1 2 3 4 5
1210-
SampleInfo3dInstruction: SAMPLEINFO_OP_3D ExecSize SAMPLER_CHANNEL Var RawOperand
1237+
// 1 2 3 4 5
1238+
SampleInfo3dInstruction: SAMPLEINFO_OP_3D SAMPLER_CHANNEL ExecSize Var RawOperand
12111239
{
12121240
pBuilder->CISA_create_info_3d_instruction(
1213-
VISA_3D_SAMPLEINFO, $2.emask, $2.exec_size,
1214-
ChannelMask::createFromAPI($3), $4, NULL, $5.cisa_gen_opnd, CISAlineno);
1241+
VISA_3D_SAMPLEINFO, $3.emask, $3.exec_size,
1242+
ChannelMask::createFromAPI($2), $4, NULL, $5.cisa_gen_opnd, CISAlineno);
12151243
}
12161244

12171245
RTWriteOperandParse:

visa/IsaDisassembly.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,15 +1583,16 @@ static std::string printInstructionSampler(
15831583
{
15841584
VISASampler3DSubOpCode subop = (VISASampler3DSubOpCode)getPrimitiveOperand<uint8_t>(inst, i++);
15851585
sstr << SAMPLE_OP_3D_NAME[subop];
1586-
sstr << " " << printExecutionSize(inst->opcode, inst->execsize) << " ";
1587-
1588-
if (subop == VISA_3D_RESINFO)
1586+
if (subop == VISA_3D_RESINFO || subop == VISA_3D_SAMPLEINFO)
15891587
{
15901588
// channelMask
15911589
uint8_t channels = getPrimitiveOperand<uint8_t>(inst, i++);
15921590
ChannelMask chMask = ChannelMask::createFromBinary(ISA_3D_INFO, channels);
1593-
sstr << chMask.getString();
1591+
sstr << "." << chMask.getString();
15941592
}
1593+
1594+
sstr << " " << printExecutionSize(inst->opcode, inst->execsize) << " ";
1595+
15951596
// surface
15961597
uint8_t surface = getPrimitiveOperand<uint8_t>(inst, i++);
15971598
sstr << " " << printSurfaceName(surface);

0 commit comments

Comments
 (0)