Skip to content

Commit ce2e7e5

Browse files
fangliu2020igcbot
authored andcommitted
Add new vISA opcode "add3o" for ternary add with overflow condition modifier.
Add new vISA opcode "add3o" for ternary add with overflow condition modifier.
1 parent 317e81f commit ce2e7e5

File tree

8 files changed

+33
-2
lines changed

8 files changed

+33
-2
lines changed

visa/CISA.l

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ add3 {
292292
return ARITH4_OP;
293293
}
294294

295+
add3\.o {
296+
TRACE("** ADD3O INST");
297+
CISAlval.opcode = str2opcode(yytext);
298+
return ARITH4_OP;
299+
}
300+
295301
bfn"."x[[:xdigit:]]+ {
296302
TRACE("** BFN INST");
297303
CISAlval.bfn_info.func_ctrl = (uint8_t)hexToInt(yytext+5, yyleng-5);

visa/CISA.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ ArithInstruction_3OPND:
914914

915915

916916
ArithInstruction_4OPND:
917+
// 1 2 3 4 5 6 7 8
917918
Predicate ARITH4_OP SatModOpt ExecSize VecDstOperand_G_I VecSrcOperand_G_I_IMM VecSrcOperand_G_I_IMM VecSrcOperand_G_I_IMM
918919
{
919920
pBuilder->CISA_create_arith_instruction($1, $2, $3, $4.emask, $4.exec_size,

visa/Common_ISA_util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ G4_opcode GetGenOpcodeFromVISAOpcode(ISA_Opcode opcode)
175175
case ISA_DPASW:
176176
return G4_dpasw;
177177
case ISA_ADD3:
178+
case ISA_ADD3O:
178179
return G4_add3;
179180
case ISA_BFN:
180181
return G4_bfn;

visa/G4Instruction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ HANDLE_INST(subb, 2, 1, InstTypeArith, GENX_BDW, ATTR_NONE)
8787
HANDLE_INST(dp4a, 3, 1, InstTypeArith, GENX_TGLLP, ATTR_NONE)
8888
HANDLE_INST(dpas, 3, 1, InstTypeArith, XeHP_SDV, ATTR_NONE)
8989
HANDLE_INST(dpasw, 3, 1, InstTypeArith, XeHP_SDV, ATTR_NONE)
90-
HANDLE_INST(add3, 3, 1, InstTypeArith, XeHP_SDV, ATTR_NONE)
90+
HANDLE_INST(add3, 3, 1, InstTypeArith, XeHP_SDV, ATTR_COMMUTATIVE)
9191

9292

9393
HANDLE_INST(madm, 3, 1, InstTypeArith, GENX_BDW, ATTR_NONE)

visa/IsaDescription.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ struct ISA_Inst_Info ISA_Inst_Table[ISA_OPCODE_ENUM_SIZE] =
165165
{ ISA_RESERVED_8E, ISA_Inst_Reserved, "reserved8e", 0, 0 },
166166
{ ISA_RESERVED_8F, ISA_Inst_Reserved, "reserved8f", 0, 0 },
167167
{ ISA_RESERVED_90, ISA_Inst_Reserved, "reserved90", 0, 0 },
168-
{ ISA_MADW, ISA_Inst_Arith, "madw", 3, 1 }
168+
{ ISA_MADW, ISA_Inst_Arith, "madw", 3, 1 },
169+
{ ISA_ADD3O, ISA_Inst_Arith, "add3.o", 3, 1 }
169170
};
170171

171172

@@ -1787,6 +1788,18 @@ VISA_INST_Desc CISA_INST_table[ISA_NUM_OPCODE] =
17871788
{OPND_VECTOR_SRC_G_I_IMM_AO, ISA_TYPE_UD | ISA_TYPE_D, 0},
17881789
},
17891790
},
1791+
1792+
/// 146 (0x92)
1793+
{ ALL, ISA_ADD3O, ISA_Inst_Arith, "add3.o", 6, SAME_DATA_TYPE,
1794+
{
1795+
{ OPND_EXECSIZE, ISA_TYPE_UB, 0 },
1796+
{ OPND_PRED, ISA_TYPE_UW, 0 },
1797+
{ OPND_VECTOR_DST_G_I, ISA_TYPE_W | ISA_TYPE_UW | ISA_TYPE_D | ISA_TYPE_UD, 0 },
1798+
{ OPND_VECTOR_SRC_G_I_IMM, ISA_TYPE_W | ISA_TYPE_UW | ISA_TYPE_D | ISA_TYPE_UD, 0 },
1799+
{ OPND_VECTOR_SRC_G_I_IMM, ISA_TYPE_W | ISA_TYPE_UW | ISA_TYPE_D | ISA_TYPE_UD, 0 },
1800+
{ OPND_VECTOR_SRC_G_I_IMM, ISA_TYPE_W | ISA_TYPE_UW | ISA_TYPE_D | ISA_TYPE_UD, 0 },
1801+
},
1802+
},
17901803
};
17911804

17921805
static const ISA_SubInst_Desc VASubOpcodeDesc[] =

visa/IsaVerification.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,7 @@ void vISAVerifier::verifyInstructionArith(
16091609
REPORT_INSTRUCTION(options, dstType == ISA_TYPE_UD, "%s only supports single UD type", ISA_Inst_Table[opcode].str);
16101610
break;
16111611
case ISA_ADD3:
1612+
case ISA_ADD3O:
16121613
REPORT_INSTRUCTION(options, dstType == ISA_TYPE_UD || dstType == ISA_TYPE_D ||
16131614
dstType == ISA_TYPE_UW || dstType == ISA_TYPE_W,
16141615
"%s only supports interger D/W type", ISA_Inst_Table[opcode].str);
@@ -1715,6 +1716,7 @@ void vISAVerifier::verifyInstructionArith(
17151716
ISA_Inst_Table[opcode].str);
17161717
break;
17171718
case ISA_ADD3:
1719+
case ISA_ADD3O:
17181720
REPORT_INSTRUCTION(options,
17191721
srcType == ISA_TYPE_D || srcType == ISA_TYPE_UD ||
17201722
srcType == ISA_TYPE_W || srcType == ISA_TYPE_UW,

visa/VisaToG4/TranslateALU.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ int IR_Builder::translateVISAArithmeticInst(
101101
}
102102
else if (ISA_Inst_Table[opcode].n_srcs == 3)
103103
{
104+
if (opcode == ISA_ADD3O)
105+
{
106+
assert(predOpnd != nullptr && "predicate operand couldn't be nullptr");
107+
condMod = createCondMod(Mod_o, predOpnd->getBase(), 0);
108+
predOpnd = nullptr;
109+
}
110+
104111
// do not check type of sources, float and integer are supported
105112
createInst(
106113
predOpnd,

visa/include/visa_igc_common_header.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ typedef enum {
394394
ISA_RESERVED_8F = 0x8F,
395395
ISA_RESERVED_90 = 0x90,
396396
ISA_MADW = 0x91,
397+
ISA_ADD3O = 0x92,
397398
ISA_NUM_OPCODE,
398399
ISA_OPCODE_ENUM_SIZE = 0xFF
399400
} ISA_Opcode;

0 commit comments

Comments
 (0)