@@ -257,15 +257,22 @@ VISA_Type vISAVerifier::getOperandVISAType(const CISA_INST* I, unsigned Ix) cons
257
257
bool vISAVerifier::useGivenVISAType (const CISA_INST* I, VISA_Type GivenType) const
258
258
{
259
259
ISA_Opcode opc = (ISA_Opcode)I->opcode ;
260
- for (int j = 0 ; j < ISA_Inst_Table[opc].n_dsts ; j++)
260
+ int ndst = (int )ISA_Inst_Table[opc].n_dsts ;
261
+ if (opc == ISA_CMP)
262
+ {
263
+ // cmp's 1st opnd is cmp relop, which returns ISA_TYPE_NUM as its type.
264
+ // Thus, it is ignored as expected.
265
+ ++ndst;
266
+ }
267
+ for (int j = 0 ; j < ndst; j++)
261
268
{
262
269
VISA_Type dstType = getOperandVISAType (I, j);
263
270
if (dstType == GivenType)
264
271
return true ;
265
272
}
266
273
for (int j = 0 ; j < ISA_Inst_Table[opc].n_srcs ; j++)
267
274
{
268
- VISA_Type srcType = getOperandVISAType (I, j + ISA_Inst_Table[opc]. n_dsts );
275
+ VISA_Type srcType = getOperandVISAType (I, j + ndst );
269
276
if (srcType == GivenType)
270
277
return true ;
271
278
}
@@ -1492,7 +1499,7 @@ void vISAVerifier::verifyInstructionArith(
1492
1499
{
1493
1500
ISA_Opcode opcode = (ISA_Opcode)inst->opcode ;
1494
1501
1495
- if (useGivenVISAType (inst, ISA_TYPE_BF16 ))
1502
+ if (useGivenVISAType (inst, ISA_TYPE_BF ))
1496
1503
{
1497
1504
// Let bfmode verifier to verify it.
1498
1505
return ;
@@ -3019,7 +3026,7 @@ void vISAVerifier::verifyInstructionDataport(
3019
3026
//
3020
3027
void vISAVerifier::verifyBFMixedMode (const CISA_INST* inst)
3021
3028
{
3022
- if (!useGivenVISAType (inst, ISA_TYPE_BF16 ))
3029
+ if (!useGivenVISAType (inst, ISA_TYPE_BF ))
3023
3030
return ;
3024
3031
if (!irBuilder->hasBFMixMode ())
3025
3032
{
@@ -3034,28 +3041,29 @@ void vISAVerifier::verifyBFMixedMode(const CISA_INST* inst)
3034
3041
}
3035
3042
3036
3043
ISA_Opcode opcode = (ISA_Opcode)inst->opcode ;
3044
+ uint32_t ndst = ISA_Inst_Table[opcode].n_dsts ;
3037
3045
switch (opcode)
3038
3046
{
3039
3047
case ISA_MUL:
3040
3048
{ // case 2
3041
- const unsigned src1ix = 1 + ISA_Inst_Table[opcode]. n_dsts ;
3049
+ const unsigned src1ix = 1 + ndst ;
3042
3050
VISA_Type src2Ty = getOperandVISAType (inst, src1ix);
3043
3051
REPORT_INSTRUCTION (options, src2Ty == ISA_TYPE_F, " Mul's src1 must be F in BF mixed mode" );
3044
3052
break ;
3045
3053
}
3046
3054
case ISA_MAD:
3047
3055
{ // case 3
3048
- const unsigned src2ix = 2 + ISA_Inst_Table[opcode]. n_dsts ;
3056
+ const unsigned src2ix = 2 + ndst ;
3049
3057
VISA_Type src2Ty = getOperandVISAType (inst, src2ix);
3050
3058
REPORT_INSTRUCTION (options, src2Ty == ISA_TYPE_F, " Mad's src2 must be F in BF mixed mode" );
3051
3059
break ;
3052
3060
}
3053
3061
case ISA_MOV:
3054
3062
{
3055
3063
// bf->f isn't a hardware inst, just left shift. Thus bf restriction does not apply.
3056
- const vector_opnd& src = getVectorOperand (inst, ISA_Inst_Table[opcode]. n_dsts );
3064
+ const vector_opnd& src = getVectorOperand (inst, ndst );
3057
3065
VISA_Type srcType = getVectorOperandType (header, src);
3058
- if (srcType == ISA_TYPE_BF16 )
3066
+ if (srcType == ISA_TYPE_BF )
3059
3067
{
3060
3068
return ;
3061
3069
}
@@ -3064,8 +3072,13 @@ void vISAVerifier::verifyBFMixedMode(const CISA_INST* inst)
3064
3072
}
3065
3073
case ISA_ADD:
3066
3074
case ISA_SEL:
3075
+ {
3076
+ // case 1
3077
+ break ;
3078
+ }
3067
3079
case ISA_CMP:
3068
3080
{ // case 1
3081
+ ++ndst; // cmp's first opnd is relop
3069
3082
break ;
3070
3083
}
3071
3084
default :
@@ -3080,55 +3093,61 @@ void vISAVerifier::verifyBFMixedMode(const CISA_INST* inst)
3080
3093
REPORT_INSTRUCTION (options, execSize <= nativeES,
3081
3094
" Exection Size > %d is not allowed for BF mixed-mode instruction" , nativeES);
3082
3095
3083
- // Check dst
3084
- const vector_opnd& dst = getVectorOperand (inst, 0 );
3085
- VISA_Type dstType = getVectorOperandType (header, dst);
3086
3096
uint16_t row_off, col_off, v_stride, width, h_stride;
3087
- if (getRegion (dst, row_off, col_off, v_stride, width, h_stride))
3097
+ // Check dst
3098
+ if (opcode != ISA_CMP)
3088
3099
{
3089
- // case 5 & 6
3090
- bool legitUnpackedBF = (dstType == ISA_TYPE_BF16 && h_stride == 2 && (col_off == 0 || col_off == 1 ));
3091
- bool legitPackedBF = (dstType == ISA_TYPE_BF16 && h_stride == 1 && (col_off == 0 || col_off == nativeES));
3092
- bool legitF = (dstType == ISA_TYPE_F && h_stride == 1 && col_off == 0 );
3093
- bool legitScalar = (execSize == 1 && h_stride == 1 );
3094
- REPORT_INSTRUCTION (options, (legitUnpackedBF || legitPackedBF || legitF || legitScalar),
3095
- " Dst region is incorrect in BF mixed mode" );
3100
+ const vector_opnd& dst = getVectorOperand (inst, 0 );
3101
+ VISA_Type dstType = getVectorOperandType (header, dst);
3102
+ if (getRegion (dst, row_off, col_off, v_stride, width, h_stride))
3103
+ {
3104
+ // case 5 & 6
3105
+ bool legitUnpackedBF = (dstType == ISA_TYPE_BF && h_stride == 2 && (col_off == 0 || col_off == 1 ));
3106
+ bool legitPackedBF = (dstType == ISA_TYPE_BF && h_stride == 1 && (col_off == 0 || col_off == nativeES));
3107
+ bool legitF = (dstType == ISA_TYPE_F && h_stride == 1 && col_off == 0 );
3108
+ bool legitScalar = (execSize == 1 && h_stride == 1 );
3109
+ REPORT_INSTRUCTION (options, (legitUnpackedBF || legitPackedBF || legitF || legitScalar),
3110
+ " Dst region is incorrect in BF mixed mode" );
3111
+ }
3096
3112
}
3097
3113
3098
3114
for (uint32_t i = 0 ; i < ISA_Inst_Table[opcode].n_srcs ; i++)
3099
3115
{
3100
- const vector_opnd& src = getVectorOperand (inst, i + ISA_Inst_Table[opcode]. n_dsts );
3116
+ const vector_opnd& src = getVectorOperand (inst, i + ndst );
3101
3117
VISA_Type srcType = getVectorOperandType (header, src);
3102
3118
Common_ISA_Operand_Class operand_class = src.getOperandClass ();
3103
3119
if (getRegion (src, row_off, col_off, v_stride, width, h_stride))
3104
3120
{
3105
- if (srcType == ISA_TYPE_BF16
3106
- && (operand_class == OPERAND_IMMEDIATE ||
3107
- (execSize > 1 && (h_stride == 0 && v_stride == 0 && width == 1 ))))
3121
+ if (srcType == ISA_TYPE_BF
3122
+ && execSize > 1 && h_stride == 0 && v_stride == 0 && width == 1 )
3108
3123
{
3109
3124
REPORT_INSTRUCTION (options, false ,
3110
- " Src%d : BF imm or BF broadcast scalar not supported! in BF mixed mode" , i);
3125
+ " Src%d : BF broadcast scalar not supported! in BF mixed mode" , i);
3111
3126
continue ;
3112
3127
}
3113
3128
3114
3129
bool isContinuous = ((h_stride == 0 && v_stride == 1 && width == 1 ) // (1;1,0)
3115
3130
|| (h_stride == 1 && v_stride == width)); // (4;4,1)
3116
- bool isLegitPackedBF = (srcType == ISA_TYPE_BF16
3131
+ bool isLegitPackedBF = (srcType == ISA_TYPE_BF
3117
3132
&& execSize != 1
3118
3133
&& isContinuous && (col_off == 0 || col_off == nativeES));
3119
3134
bool isLegitF = (srcType == ISA_TYPE_F && execSize != 1 && isContinuous && col_off == 0 );
3120
- bool isLegitScalar = (execSize == 1 && ( h_stride == 0 && v_stride == 0 && width == 1 ) );
3135
+ bool isLegitScalar = (h_stride == 0 && v_stride == 0 && width == 1 );
3121
3136
if (!(isLegitPackedBF || isLegitF || isLegitScalar))
3122
3137
{
3123
3138
// case 5 & 6
3124
3139
REPORT_INSTRUCTION (options, false , " Src%d : invalid region in BF mixed mode" , i);
3125
3140
}
3126
3141
}
3127
- else
3142
+ else if (operand_class == OPERAND_IMMEDIATE)
3128
3143
{
3129
- REPORT_INSTRUCTION (options, false , " Invalid region " );
3144
+ REPORT_INSTRUCTION (options, srcType == ISA_TYPE_F , " Src%d : BF immediate not supported " , i );
3130
3145
return ;
3131
3146
}
3147
+ else
3148
+ {
3149
+ REPORT_INSTRUCTION (options, false , " Src%d : unrecognized region in BF mixed mode" , i);
3150
+ }
3132
3151
}
3133
3152
return ;
3134
3153
}
0 commit comments