Skip to content

Commit 944c4aa

Browse files
authored
Arm64/SVE: Add insEncodeReg* methods (#95105)
* Add insEncodeReg* methods * Adjust the `ins` for sve instruction Picked up the change in #95127 (comment) * Update the comments * Use sve_ins_offset
1 parent eb4e50c commit 944c4aa

File tree

2 files changed

+284
-43
lines changed

2 files changed

+284
-43
lines changed

Diff for: src/coreclr/jit/emitarm64.cpp

+233-37
Original file line numberDiff line numberDiff line change
@@ -3768,60 +3768,61 @@ emitter::code_t emitter::emitInsCodeSve(instruction ins, insFormat fmt)
37683768
}
37693769

37703770
assert(encoding_found);
3771+
const unsigned sve_ins_offset = ((unsigned)ins - INS_sve_invalid);
37713772

37723773
switch (index)
37733774
{
37743775
case 0:
3775-
assert(ins < ArrLen(insCodes1));
3776-
code = insCodes1[ins];
3776+
assert(sve_ins_offset < ArrLen(insCodes1));
3777+
code = insCodes1[sve_ins_offset];
37773778
break;
37783779
case 1:
3779-
assert(ins < ArrLen(insCodes2));
3780-
code = insCodes2[ins];
3780+
assert(sve_ins_offset < ArrLen(insCodes2));
3781+
code = insCodes2[sve_ins_offset];
37813782
break;
37823783
case 2:
3783-
assert(ins < ArrLen(insCodes3));
3784-
code = insCodes3[ins];
3784+
assert(sve_ins_offset < ArrLen(insCodes3));
3785+
code = insCodes3[sve_ins_offset];
37853786
break;
37863787
case 3:
3787-
assert(ins < ArrLen(insCodes4));
3788-
code = insCodes4[ins];
3788+
assert(sve_ins_offset < ArrLen(insCodes4));
3789+
code = insCodes4[sve_ins_offset];
37893790
break;
37903791
case 4:
3791-
assert(ins < ArrLen(insCodes5));
3792-
code = insCodes5[ins];
3792+
assert(sve_ins_offset < ArrLen(insCodes5));
3793+
code = insCodes5[sve_ins_offset];
37933794
break;
37943795
case 5:
3795-
assert(ins < ArrLen(insCodes6));
3796-
code = insCodes6[ins];
3796+
assert(sve_ins_offset < ArrLen(insCodes6));
3797+
code = insCodes6[sve_ins_offset];
37973798
break;
37983799
case 6:
3799-
assert(ins < ArrLen(insCodes7));
3800-
code = insCodes7[ins];
3800+
assert(sve_ins_offset < ArrLen(insCodes7));
3801+
code = insCodes7[sve_ins_offset];
38013802
break;
38023803
case 7:
3803-
assert(ins < ArrLen(insCodes8));
3804-
code = insCodes8[ins];
3804+
assert(sve_ins_offset < ArrLen(insCodes8));
3805+
code = insCodes8[sve_ins_offset];
38053806
break;
38063807
case 8:
3807-
assert(ins < ArrLen(insCodes9));
3808-
code = insCodes9[ins];
3808+
assert(sve_ins_offset < ArrLen(insCodes9));
3809+
code = insCodes9[sve_ins_offset];
38093810
break;
38103811
case 9:
3811-
assert(ins < ArrLen(insCodes10));
3812-
code = insCodes10[ins];
3812+
assert(sve_ins_offset < ArrLen(insCodes10));
3813+
code = insCodes10[sve_ins_offset];
38133814
break;
38143815
case 10:
3815-
assert(ins < ArrLen(insCodes11));
3816-
code = insCodes11[ins];
3816+
assert(sve_ins_offset < ArrLen(insCodes11));
3817+
code = insCodes11[sve_ins_offset];
38173818
break;
38183819
case 11:
3819-
assert(ins < ArrLen(insCodes12));
3820-
code = insCodes12[ins];
3820+
assert(sve_ins_offset < ArrLen(insCodes12));
3821+
code = insCodes12[sve_ins_offset];
38213822
break;
38223823
case 12:
3823-
assert(ins < ArrLen(insCodes13));
3824-
code = insCodes13[ins];
3824+
assert(sve_ins_offset < ArrLen(insCodes13));
3825+
code = insCodes13[sve_ins_offset];
38253826
break;
38263827
}
38273828

@@ -10633,41 +10634,236 @@ void emitter::emitIns_Call(EmitCallType callType,
1063310634

1063410635
/*****************************************************************************
1063510636
*
10636-
* Returns an encoding for the specified register used in the 'Pd' position
10637+
* Return an encoding for the specified 'V' register used in '4' thru '0' position.
10638+
*/
10639+
10640+
/*static*/ emitter::code_t emitter::insEncodeReg_V_4_to_0(regNumber reg)
10641+
{
10642+
assert(isVectorRegister(reg));
10643+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_V0;
10644+
assert((ureg >= 0) && (ureg <= 32));
10645+
return ureg << 0;
10646+
}
10647+
10648+
/*****************************************************************************
10649+
*
10650+
* Return an encoding for the specified 'V' register used in '9' thru '5' position.
1063710651
*/
1063810652

10639-
/*static*/ emitter::code_t emitter::insEncodeReg_Pd(regNumber reg)
10653+
/*static*/ emitter::code_t emitter::insEncodeReg_V_9_to_5(regNumber reg)
1064010654
{
10641-
assert(emitter::isPredicateRegister(reg));
10655+
assert(isVectorRegister(reg));
10656+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_V0;
10657+
assert((ureg >= 0) && (ureg <= 32));
10658+
return ureg << 5;
10659+
}
10660+
10661+
/*****************************************************************************
10662+
*
10663+
* Return an encoding for the specified 'P' register used in '12' thru '10' position.
10664+
*/
10665+
10666+
/*static*/ emitter::code_t emitter::insEncodeReg_P_12_to_10(regNumber reg)
10667+
{
10668+
assert(isPredicateRegister(reg));
1064210669
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
1064310670
assert((ureg >= 0) && (ureg <= 15));
10644-
return ureg;
10671+
return ureg << 10;
10672+
}
10673+
10674+
/*****************************************************************************
10675+
*
10676+
* Return an encoding for the specified 'V' register used in '21' thru '17' position.
10677+
*/
10678+
10679+
/*static*/ emitter::code_t emitter::insEncodeReg_V_21_to_17(regNumber reg)
10680+
{
10681+
assert(isVectorRegister(reg));
10682+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_V0;
10683+
assert((ureg >= 0) && (ureg <= 32));
10684+
return ureg << 17;
10685+
}
10686+
10687+
/*****************************************************************************
10688+
*
10689+
* Return an encoding for the specified 'R' register used in '21' thru '17' position.
10690+
*/
10691+
10692+
/*static*/ emitter::code_t emitter::insEncodeReg_R_21_to_17(regNumber reg)
10693+
{
10694+
assert(isIntegerRegister(reg));
10695+
emitter::code_t ureg = (emitter::code_t)reg;
10696+
assert((ureg >= 0) && (ureg <= 32));
10697+
return ureg << 17;
10698+
}
10699+
10700+
/*****************************************************************************
10701+
*
10702+
* Return an encoding for the specified 'R' register used in '9' thru '5' position.
10703+
*/
10704+
10705+
/*static*/ emitter::code_t emitter::insEncodeReg_R_9_to_5(regNumber reg)
10706+
{
10707+
assert(isIntegerRegister(reg));
10708+
emitter::code_t ureg = (emitter::code_t)reg;
10709+
assert((ureg >= 0) && (ureg <= 32));
10710+
return ureg << 5;
10711+
}
10712+
10713+
/*****************************************************************************
10714+
*
10715+
* Return an encoding for the specified 'R' register used in '4' thru '0' position.
10716+
*/
10717+
10718+
/*static*/ emitter::code_t emitter::insEncodeReg_R_4_to_0(regNumber reg)
10719+
{
10720+
assert(isIntegerRegister(reg));
10721+
emitter::code_t ureg = (emitter::code_t)reg;
10722+
assert((ureg >= 0) && (ureg <= 32));
10723+
return ureg << 0;
10724+
}
10725+
10726+
/*****************************************************************************
10727+
*
10728+
* Return an encoding for the specified 'P' register used in '20' thru '17' position.
10729+
*/
10730+
10731+
/*static*/ emitter::code_t emitter::insEncodeReg_P_20_to_17(regNumber reg)
10732+
{
10733+
assert(isPredicateRegister(reg));
10734+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
10735+
assert((ureg >= 0) && (ureg <= 15));
10736+
return ureg << 17;
1064510737
}
1064610738

1064710739
/*****************************************************************************
1064810740
*
10649-
* Returns an encoding for the specified register used in the 'Pn' position
10741+
* Return an encoding for the specified 'P' register used in '3' thru '0' position.
1065010742
*/
1065110743

10652-
/*static*/ emitter::code_t emitter::insEncodeReg_Pn(regNumber reg)
10744+
/*static*/ emitter::code_t emitter::insEncodeReg_P_3_to_0(regNumber reg)
1065310745
{
10654-
assert(emitter::isPredicateRegister(reg));
10746+
assert(isPredicateRegister(reg));
10747+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
10748+
assert((ureg >= 0) && (ureg <= 15));
10749+
return ureg << 0;
10750+
}
10751+
10752+
/*****************************************************************************
10753+
*
10754+
* Return an encoding for the specified 'P' register used in '8' thru '5' position.
10755+
*/
10756+
10757+
/*static*/ emitter::code_t emitter::insEncodeReg_P_8_to_5(regNumber reg)
10758+
{
10759+
assert(isPredicateRegister(reg));
1065510760
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
1065610761
assert((ureg >= 0) && (ureg <= 15));
1065710762
return ureg << 5;
1065810763
}
1065910764

1066010765
/*****************************************************************************
1066110766
*
10662-
* Returns an encoding for the specified register used in the 'Pm' position
10767+
* Return an encoding for the specified 'P' register used in '13' thru '10' position.
1066310768
*/
1066410769

10665-
/*static*/ emitter::code_t emitter::insEncodeReg_Pm(regNumber reg)
10770+
/*static*/ emitter::code_t emitter::insEncodeReg_P_13_to_10(regNumber reg)
1066610771
{
10667-
assert(emitter::isPredicateRegister(reg));
10772+
assert(isPredicateRegister(reg));
1066810773
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
1066910774
assert((ureg >= 0) && (ureg <= 15));
10670-
return ureg << 16;
10775+
return ureg << 10;
10776+
}
10777+
10778+
/*****************************************************************************
10779+
*
10780+
* Return an encoding for the specified 'R' register used in '18' thru '17' position.
10781+
*/
10782+
10783+
/*static*/ emitter::code_t emitter::insEncodeReg_R_18_to_17(regNumber reg)
10784+
{
10785+
assert(isIntegerRegister(reg));
10786+
emitter::code_t ureg = (emitter::code_t)reg;
10787+
assert((ureg >= 0) && (ureg <= 32));
10788+
return ureg << 17;
10789+
}
10790+
10791+
/*****************************************************************************
10792+
*
10793+
* Return an encoding for the specified 'P' register used in '7' thru '5' position.
10794+
*/
10795+
10796+
/*static*/ emitter::code_t emitter::insEncodeReg_P_7_to_5(regNumber reg)
10797+
{
10798+
assert(isPredicateRegister(reg));
10799+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
10800+
assert((ureg >= 0) && (ureg <= 15));
10801+
return ureg << 5;
10802+
}
10803+
10804+
/*****************************************************************************
10805+
*
10806+
* Return an encoding for the specified 'P' register used in '3' thru '1' position.
10807+
*/
10808+
10809+
/*static*/ emitter::code_t emitter::insEncodeReg_P_3_to_1(regNumber reg)
10810+
{
10811+
assert(isPredicateRegister(reg));
10812+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
10813+
assert((ureg >= 0) && (ureg <= 15));
10814+
return ureg << 1;
10815+
}
10816+
10817+
/*****************************************************************************
10818+
*
10819+
* Return an encoding for the specified 'P' register used in '2' thru '0' position.
10820+
*/
10821+
10822+
/*static*/ emitter::code_t emitter::insEncodeReg_P_2_to_0(regNumber reg)
10823+
{
10824+
assert(isPredicateRegister(reg));
10825+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_P0;
10826+
assert((ureg >= 0) && (ureg <= 15));
10827+
return ureg << 0;
10828+
}
10829+
10830+
/*****************************************************************************
10831+
*
10832+
* Return an encoding for the specified 'V' register used in '19' thru '17' position.
10833+
*/
10834+
10835+
/*static*/ emitter::code_t emitter::insEncodeReg_V_19_to_17(regNumber reg)
10836+
{
10837+
assert(isVectorRegister(reg));
10838+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_V0;
10839+
assert((ureg >= 0) && (ureg <= 32));
10840+
return ureg << 17;
10841+
}
10842+
10843+
/*****************************************************************************
10844+
*
10845+
* Return an encoding for the specified 'V' register used in '20' thru '17' position.
10846+
*/
10847+
10848+
/*static*/ emitter::code_t emitter::insEncodeReg_V_20_to_17(regNumber reg)
10849+
{
10850+
assert(isVectorRegister(reg));
10851+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_V0;
10852+
assert((ureg >= 0) && (ureg <= 32));
10853+
return ureg << 17;
10854+
}
10855+
10856+
/*****************************************************************************
10857+
*
10858+
* Return an encoding for the specified 'V' register used in '9' thru '6' position.
10859+
*/
10860+
10861+
/*static*/ emitter::code_t emitter::insEncodeReg_V_9_to_6(regNumber reg)
10862+
{
10863+
assert(isVectorRegister(reg));
10864+
emitter::code_t ureg = (emitter::code_t)reg - (emitter::code_t)REG_V0;
10865+
assert((ureg >= 0) && (ureg <= 32));
10866+
return ureg << 6;
1067110867
}
1067210868

1067310869
/*****************************************************************************

0 commit comments

Comments
 (0)