From f278afd272d2cb12dc99aa4e4df6d28d827d66f8 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Wed, 17 Jan 2024 17:21:29 +0000 Subject: [PATCH 1/3] Use insGetPredicateType for SVE encodings --- src/coreclr/jit/emitarm64.cpp | 169 ++++++++++++++++++---------------- src/coreclr/jit/emitarm64.h | 3 +- 2 files changed, 91 insertions(+), 81 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index ce5a2820e0e43..ba10a03362a88 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -13966,7 +13966,7 @@ void emitter::emitIns_Call(EmitCallType callType, * Returns the predicate type for the given SVE format. */ -/*static*/ emitter::PredicateType emitter::insGetPredicateType(insFormat fmt) +/*static*/ emitter::PredicateType emitter::insGetPredicateType(insFormat fmt, int regpos /* =0 */) { switch (fmt) { @@ -14008,13 +14008,10 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_IF_4A_A: case IF_SVE_IM_3A: case IF_SVE_IN_4A: - case IF_SVE_CX_4A: - case IF_SVE_CX_4A_A: case IF_SVE_CY_3A: case IF_SVE_CY_3B: case IF_SVE_IX_4A: case IF_SVE_HI_3A: - case IF_SVE_HT_4A: case IF_SVE_DG_2A: case IF_SVE_IO_3A: case IF_SVE_IP_4A: @@ -14025,7 +14022,6 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_DA_4A: case IF_SVE_DB_3B: case IF_SVE_DC_3A: - case IF_SVE_GE_4A: case IF_SVE_GI_4A: case IF_SVE_IC_3A_C: case IF_SVE_IC_3A: @@ -14103,8 +14099,13 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_DN_2A: case IF_SVE_DO_2A: case IF_SVE_DP_2A: + case IF_SVE_DR_1A: + case IF_SVE_DT_3A: + case IF_SVE_DU_3A: + case IF_SVE_DY_3A: case IF_SVE_CK_2A: case IF_SVE_DI_2A: + case IF_SVE_DZ_1A: return PREDICATE_SIZED; // This is a special case as the second register could be ZERO or MERGE. @@ -14113,6 +14114,7 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_AH_3A: case IF_SVE_DB_3A: // TODO: Handle these cases. + assert(false); break; case IF_SVE_JD_4B: @@ -14175,6 +14177,13 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_IY_4A: return PREDICATE_NONE; + case IF_SVE_CX_4A: + case IF_SVE_CX_4A_A: + case IF_SVE_GE_4A: + case IF_SVE_HT_4A: + assert(regpos >= 1 && regpos <= 2); + return (regpos == 1 ? PREDICATE_SIZED : PREDICATE_ZERO); + default: break; } @@ -19063,10 +19072,10 @@ void emitter::emitDispInsHelp( // (predicated) case IF_SVE_GR_3A: // ........xx...... ...gggmmmmmddddd -- SVE2 floating-point pairwise operations case IF_SVE_HL_3A: // ........xx...... ...gggmmmmmddddd -- SVE floating-point arithmetic (predicated) - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispLowPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispLowPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; // ., /, . @@ -19081,18 +19090,18 @@ void emitter::emitDispInsHelp( // ., /M, ., # case IF_SVE_AM_2A: // ........xx...... ...gggxxiiiddddd -- SVE bitwise shift by immediate (predicated) - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispLowPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispImm(emitGetInsSC(id), false); // iiii + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispLowPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispImm(emitGetInsSC(id), false); // iiii break; // ., /M, ., .D case IF_SVE_AO_3A: // ........xx...... ...gggmmmmmddddd -- SVE bitwise shift by wide elements (predicated) - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispLowPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispSveReg(id->idReg3(), INS_OPTS_SCALABLE_D, false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispLowPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispSveReg(id->idReg3(), INS_OPTS_SCALABLE_D, false); // mmmmm break; // ., /M, ., . @@ -19101,18 +19110,18 @@ void emitter::emitDispInsHelp( // (predicated) case IF_SVE_AS_4A: // ........xx.mmmmm ...gggaaaaaddddd -- SVE integer multiply-add writing multiplicand // (predicated) - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispLowPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispLowPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg emitDispSveReg(id->idReg3(), id->idInsOpt(), true); emitDispSveReg(id->idReg4(), id->idInsOpt(), false); break; // ., , ., . case IF_SVE_CM_3A: // ........xx...... ...gggmmmmmddddd -- SVE conditionally broadcast element to vector - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispLowPredicateReg(id->idReg2(), PREDICATE_NONE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispLowPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; // , , , . @@ -19120,10 +19129,10 @@ void emitter::emitDispInsHelp( case IF_SVE_CN_3A: // ........xx...... ...gggmmmmmddddd -- SVE conditionally extract element to SIMD&FP scalar case IF_SVE_CO_3A: // ........xx...... ...gggmmmmmddddd -- SVE conditionally extract element to general register case IF_SVE_HJ_3A: // ........xx...... ...gggmmmmmddddd -- SVE floating-point serial reduction (predicated) - emitDispReg(id->idReg1(), size, true); // ddddd - emitDispLowPredicateReg(id->idReg2(), PREDICATE_NONE, id->idInsOpt(), true); // ggg - emitDispReg(id->idReg1(), size, true); // ddddd - emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm + emitDispReg(id->idReg1(), size, true); // ddddd + emitDispLowPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispReg(id->idReg1(), size, true); // ddddd + emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; // , , . @@ -19133,9 +19142,9 @@ void emitter::emitDispInsHelp( case IF_SVE_CR_3A: // ........xx...... ...gggnnnnnddddd -- SVE extract element to SIMD&FP scalar register case IF_SVE_CS_3A: // ........xx...... ...gggnnnnnddddd -- SVE extract element to general register case IF_SVE_HE_3A: // ........xx...... ...gggnnnnnddddd -- SVE floating-point recursive reduction - emitDispReg(id->idReg1(), size, true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_NONE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm + emitDispReg(id->idReg1(), size, true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; // ., , . @@ -19144,15 +19153,15 @@ void emitter::emitDispInsHelp( case IF_SVE_AL_3A: // ........xx...... ...gggnnnnnddddd -- SVE integer min/max reduction (quadwords) case IF_SVE_GS_3A: // ........xx...... ...gggnnnnnddddd -- SVE floating-point recursive reduction (quadwords) emitDispVectorReg(id->idReg1(), optSveToQuadwordElemsizeArrangement(id->idInsOpt()), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_NONE, id->idInsOpt(), true); // ggg + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; //
, , . case IF_SVE_AI_3A: // ........xx...... ...gggnnnnnddddd -- SVE integer add reduction (predicated) - emitDispReg(id->idReg1(), EA_8BYTE, true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_NONE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm + emitDispReg(id->idReg1(), EA_8BYTE, true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; // ., /M, . @@ -19162,65 +19171,65 @@ void emitter::emitDispInsHelp( case IF_SVE_ES_3A: // ........xx...... ...gggnnnnnddddd -- SVE2 integer unary operations (predicated) case IF_SVE_HQ_3A: // ........xx...... ...gggnnnnnddddd -- SVE floating-point round to integral value case IF_SVE_HR_3A: // ........xx...... ...gggnnnnnddddd -- SVE floating-point unary operations - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; // ., , . case IF_SVE_CL_3A: // ........xx...... ...gggnnnnnddddd -- SVE compress active elements - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_NONE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), id->idInsOpt(), false); // mmmmm break; // ., /M, case IF_SVE_CP_3A: // ........xx...... ...gggnnnnnddddd -- SVE copy SIMD&FP scalar register to vector // (predicated) - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg - emitDispReg(id->idReg3(), size, false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispReg(id->idReg3(), size, false); // mmmmm break; // ., /M, case IF_SVE_CQ_3A: // ........xx...... ...gggnnnnnddddd -- SVE copy general register to vector (predicated) - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg - emitDispReg(encodingZRtoSP(id->idReg3()), size, false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispReg(encodingZRtoSP(id->idReg3()), size, false); // mmmmm break; // ., /Z, ., . case IF_SVE_CX_4A: // ........xx.mmmmm ...gggnnnnn.DDDD -- SVE integer compare vectors case IF_SVE_GE_4A: // ........xx.mmmmm ...gggnnnnn.DDDD -- SVE2 character match case IF_SVE_HT_4A: // ........xx.mmmmm ...gggnnnnn.DDDD -- SVE floating-point compare vectors - emitDispPredicateReg(id->idReg1(), PREDICATE_SIZED, id->idInsOpt(), true); // DDDD - emitDispPredicateReg(id->idReg2(), PREDICATE_ZERO, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), id->idInsOpt(), true); // nnnnn - emitDispSveReg(id->idReg4(), id->idInsOpt(), false); // mmmmm + emitDispPredicateReg(id->idReg1(), insGetPredicateType(fmt, 1), id->idInsOpt(), true); // DDDD + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt, 2), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), id->idInsOpt(), true); // nnnnn + emitDispSveReg(id->idReg4(), id->idInsOpt(), false); // mmmmm break; // ., /Z, ., .D case IF_SVE_CX_4A_A: // ........xx.mmmmm ...gggnnnnn.DDDD -- SVE integer compare vectors - emitDispPredicateReg(id->idReg1(), PREDICATE_SIZED, id->idInsOpt(), true); // DDDD - emitDispPredicateReg(id->idReg2(), PREDICATE_ZERO, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), id->idInsOpt(), true); // nnnnn - emitDispSveReg(id->idReg4(), INS_OPTS_SCALABLE_D, false); // mmmmm + emitDispPredicateReg(id->idReg1(), insGetPredicateType(fmt, 1), id->idInsOpt(), true); // DDDD + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt, 2), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), id->idInsOpt(), true); // nnnnn + emitDispSveReg(id->idReg4(), INS_OPTS_SCALABLE_D, false); // mmmmm break; // ., /Z, ., # case IF_SVE_CY_3A: // ........xx.iiiii ...gggnnnnn.DDDD -- SVE integer compare with signed immediate case IF_SVE_CY_3B: // ........xx.iiiii ii.gggnnnnn.DDDD -- SVE integer compare with unsigned immediate - emitDispPredicateReg(id->idReg1(), PREDICATE_SIZED, id->idInsOpt(), true); // DDDD - emitDispPredicateReg(id->idReg2(), PREDICATE_ZERO, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), id->idInsOpt(), true); // nnnnn - emitDispImm(emitGetInsSC(id), false, (fmt == IF_SVE_CY_3B)); // iiiii + emitDispPredicateReg(id->idReg1(), insGetPredicateType(fmt, 1), id->idInsOpt(), true); // DDDD + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt, 2), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), id->idInsOpt(), true); // nnnnn + emitDispImm(emitGetInsSC(id), false, (fmt == IF_SVE_CY_3B)); // iiiii break; // ., /M, . case IF_SVE_EQ_3A: // ........xx...... ...gggnnnnnddddd -- SVE2 integer pairwise add and accumulate long - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispLowPredicateReg(id->idReg2(), PREDICATE_MERGE, id->idInsOpt(), true); // ggg - emitDispSveReg(id->idReg3(), (insOpts)((unsigned)id->idInsOpt() - 1), false); // mmmmm + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispLowPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // ggg + emitDispSveReg(id->idReg3(), (insOpts)((unsigned)id->idInsOpt() - 1), false); // mmmmm break; // .H, { .S-.S }, # @@ -19232,22 +19241,22 @@ void emitter::emitDispInsHelp( // , ., case IF_SVE_DL_2A: // ........xx...... .....l.NNNNddddd -- SVE predicate count (predicate-as-counter) - emitDispReg(id->idReg1(), id->idOpSize(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_SIZED, id->idInsOpt(), true); // NNNN + emitDispReg(id->idReg1(), id->idOpSize(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), true); // NNNN emitDispVectorLengthSpecifier(id); break; // , . case IF_SVE_DM_2A: // ........xx...... .......MMMMddddd -- SVE inc/dec register by predicate count - emitDispReg(id->idReg1(), id->idOpSize(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_SIZED, id->idInsOpt(), false); // MMMM + emitDispReg(id->idReg1(), id->idOpSize(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), false); // MMMM break; // ., . case IF_SVE_DN_2A: // ........xx...... .......MMMMddddd -- SVE inc/dec vector by predicate count case IF_SVE_DP_2A: // ........xx...... .......MMMMddddd -- SVE saturating inc/dec vector by predicate count - emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_SIZED, id->idInsOpt(), false); // MMMM + emitDispSveReg(id->idReg1(), id->idInsOpt(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), false); // MMMM break; // , ., @@ -19257,9 +19266,9 @@ void emitter::emitDispInsHelp( { // 32-bit result: , ., // 64-bit result: , . - const bool is32BitResult = (id->idOpSize() == EA_4BYTE); // X - emitDispReg(id->idReg1(), EA_8BYTE, true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_SIZED, id->idInsOpt(), is32BitResult); // MMMM + const bool is32BitResult = (id->idOpSize() == EA_4BYTE); // X + emitDispReg(id->idReg1(), EA_8BYTE, true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), is32BitResult); // MMMM if (is32BitResult) { @@ -19269,8 +19278,8 @@ void emitter::emitDispInsHelp( else { assert((ins == INS_sve_uqdecp) || (ins == INS_sve_uqincp)); - emitDispReg(id->idReg1(), id->idOpSize(), true); // ddddd - emitDispPredicateReg(id->idReg2(), PREDICATE_SIZED, id->idInsOpt(), false); // MMMM + emitDispReg(id->idReg1(), id->idOpSize(), true); // ddddd + emitDispPredicateReg(id->idReg2(), insGetPredicateType(fmt), id->idInsOpt(), false); // MMMM } break; @@ -19280,7 +19289,7 @@ void emitter::emitDispInsHelp( // .B case IF_SVE_DR_1A: // ................ .......NNNN..... -- SVE FFR write from predicate - emitDispPredicateReg(id->idReg1(), PREDICATE_SIZED, id->idInsOpt(), false); // NNNN + emitDispPredicateReg(id->idReg1(), insGetPredicateType(fmt), id->idInsOpt(), false); // NNNN break; // , @@ -19313,9 +19322,9 @@ void emitter::emitDispInsHelp( case IF_SVE_DT_3A: // ........xx.mmmmm ...X..nnnnn.DDDD -- SVE integer compare scalar count and limit // ., , case IF_SVE_DU_3A: // ........xx.mmmmm ......nnnnn.DDDD -- SVE pointer conflict compare - emitDispPredicateReg(id->idReg1(), PREDICATE_SIZED, id->idInsOpt(), true); // DDDD - emitDispReg(id->idReg2(), id->idOpSize(), true); // nnnnn - emitDispReg(id->idReg3(), id->idOpSize(), false); // mmmmm + emitDispPredicateReg(id->idReg1(), insGetPredicateType(fmt), id->idInsOpt(), true); // DDDD + emitDispReg(id->idReg2(), id->idOpSize(), true); // nnnnn + emitDispReg(id->idReg3(), id->idOpSize(), false); // mmmmm break; // {., .}, , @@ -19329,15 +19338,15 @@ void emitter::emitDispInsHelp( // ., , , case IF_SVE_DY_3A: // ........xx.mmmmm ..l...nnnnn..DDD -- SVE integer compare scalar count and limit // (predicate-as-counter) - emitDispPredicateReg(id->idReg1(), PREDICATE_SIZED, id->idInsOpt(), true); // DDD - emitDispReg(id->idReg2(), id->idOpSize(), true); // nnnnn - emitDispReg(id->idReg3(), id->idOpSize(), true); // mmmmm + emitDispPredicateReg(id->idReg1(), insGetPredicateType(fmt), id->idInsOpt(), true); // DDD + emitDispReg(id->idReg2(), id->idOpSize(), true); // nnnnn + emitDispReg(id->idReg3(), id->idOpSize(), true); // mmmmm emitDispVectorLengthSpecifier(id); break; // PTRUE . case IF_SVE_DZ_1A: // ........xx...... .............DDD -- sve_int_pn_ptrue - emitDispPredicateReg(id->idReg1(), PREDICATE_SIZED, id->idInsOpt(), false); // DDD + emitDispPredicateReg(id->idReg1(), insGetPredicateType(fmt), id->idInsOpt(), false); // DDD break; // FDUP ., # diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index e76290a28a28b..ea518a28b1f59 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -491,7 +491,8 @@ static code_t insEncodeSveElemsize_tszh_22_tszl_20_to_19(emitAttr size); static int insGetSveReg1ListSize(instruction ins); // Returns the predicate type for the given SVE format. -static PredicateType insGetPredicateType(insFormat fmt); +// Register position is required for instructions with multiple predicates. +static PredicateType insGetPredicateType(insFormat fmt, int regpos = 0); // Returns true if the specified instruction can encode the 'dtype' field. static bool canEncodeSveElemsize_dtype(instruction ins); From 0efb945930568d2f9430e32c02bbfad7b885236f Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Thu, 18 Jan 2024 10:41:25 +0000 Subject: [PATCH 2/3] Add predicate as counter printing --- src/coreclr/jit/emitarm64.cpp | 50 ++++++++++++++++++++++++++++++----- src/coreclr/jit/emitarm64.h | 10 ++++--- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index ba10a03362a88..edc267e241edb 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -1904,6 +1904,14 @@ static const char * const pRegNames[] = "p10", "p11", "p12", "p13", "p14", "p15" }; + +static const char * const pnRegNames[] = +{ + "pn0", "pn1", "pn2", "pn3", "pn4", + "pn5", "pn6", "pn7", "pn8", "pn9", + "pn10", "pn11", "pn12", "pn13", "pn14", + "pn15" +}; // clang-format on //------------------------------------------------------------------------ @@ -2010,6 +2018,24 @@ const char* emitter::emitPredicateRegName(regNumber reg) return pRegNames[index]; } +//------------------------------------------------------------------------ +// emitPredicateAsCounterRegName: Returns a predicate as counter register name. +// +// Arguments: +// reg - A predicate register. +// +// Return value: +// A string that represents a predicate as counter register name. +// +const char* emitter::emitPredicateAsCounterRegName(regNumber reg) +{ + assert((reg >= REG_P0) && (reg <= REG_P15)); + + int index = (int)reg - (int)REG_P0; + + return pnRegNames[index]; +} + /***************************************************************************** * * Returns the base encoding of the given CPU instruction. @@ -14008,8 +14034,6 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_IF_4A_A: case IF_SVE_IM_3A: case IF_SVE_IN_4A: - case IF_SVE_CY_3A: - case IF_SVE_CY_3B: case IF_SVE_IX_4A: case IF_SVE_HI_3A: case IF_SVE_DG_2A: @@ -14094,7 +14118,6 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_CF_2C: case IF_SVE_CF_2D: case IF_SVE_CI_3A: - case IF_SVE_DL_2A: case IF_SVE_DM_2A: case IF_SVE_DN_2A: case IF_SVE_DO_2A: @@ -14102,12 +14125,15 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_DR_1A: case IF_SVE_DT_3A: case IF_SVE_DU_3A: - case IF_SVE_DY_3A: case IF_SVE_CK_2A: case IF_SVE_DI_2A: - case IF_SVE_DZ_1A: return PREDICATE_SIZED; + case IF_SVE_DL_2A: + case IF_SVE_DY_3A: + case IF_SVE_DZ_1A: + return PREDICATE_N_SIZED; + // This is a special case as the second register could be ZERO or MERGE. // / // Therefore, by default return NONE due to ambiguity. @@ -14179,6 +14205,8 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_CX_4A: case IF_SVE_CX_4A_A: + case IF_SVE_CY_3A: + case IF_SVE_CY_3B: case IF_SVE_GE_4A: case IF_SVE_HT_4A: assert(regpos >= 1 && regpos <= 2); @@ -17386,7 +17414,15 @@ void emitter::emitDispSveConsecutiveRegList(regNumber firstReg, unsigned listSiz void emitter::emitDispPredicateReg(regNumber reg, PredicateType ptype, insOpts opt, bool addComma) { assert(isPredicateRegister(reg)); - printf(emitPredicateRegName(reg)); + + if (ptype == PREDICATE_N_SIZED) + { + printf(emitPredicateAsCounterRegName(reg)); + } + else + { + printf(emitPredicateRegName(reg)); + } if (ptype == PREDICATE_MERGE) { @@ -17396,7 +17432,7 @@ void emitter::emitDispPredicateReg(regNumber reg, PredicateType ptype, insOpts o { printf("/z"); } - else if (ptype == PREDICATE_SIZED) + else if (ptype == PREDICATE_SIZED || ptype == PREDICATE_N_SIZED) { emitDispElemsize(optGetSveElemsize(opt)); } diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index ea518a28b1f59..baef6a3df249e 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -21,15 +21,17 @@ static bool strictArmAsm; enum PredicateType { - PREDICATE_NONE = 0, - PREDICATE_MERGE, - PREDICATE_ZERO, - PREDICATE_SIZED, + PREDICATE_NONE = 0, // Predicate printed with no extensions + PREDICATE_MERGE, // Predicate printed with /m + PREDICATE_ZERO, // Predicate printed with /z + PREDICATE_SIZED, // Predicate printed with element size + PREDICATE_N_SIZED, // Predicate printed printed as counter with element size }; const char* emitSveRegName(regNumber reg); const char* emitVectorRegName(regNumber reg); const char* emitPredicateRegName(regNumber reg); +const char* emitPredicateAsCounterRegName(regNumber reg); void emitDispInsHelp( instrDesc* id, bool isNew, bool doffs, bool asmfm, unsigned offset, BYTE* pCode, size_t sz, insGroup* ig); From 7ede28f2a016949e3591819d7a097414981bab25 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Thu, 18 Jan 2024 15:31:13 +0000 Subject: [PATCH 3/3] Pass type to emitPredicateRegName --- src/coreclr/jit/emitarm64.cpp | 34 ++++------------------------------ src/coreclr/jit/emitarm64.h | 3 +-- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index edc267e241edb..ef6b3f02ce6f7 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -2009,31 +2009,13 @@ const char* emitter::emitVectorRegName(regNumber reg) // Return value: // A string that represents a predicate register name. // -const char* emitter::emitPredicateRegName(regNumber reg) +const char* emitter::emitPredicateRegName(regNumber reg, PredicateType ptype) { assert((reg >= REG_P0) && (reg <= REG_P15)); int index = (int)reg - (int)REG_P0; - return pRegNames[index]; -} - -//------------------------------------------------------------------------ -// emitPredicateAsCounterRegName: Returns a predicate as counter register name. -// -// Arguments: -// reg - A predicate register. -// -// Return value: -// A string that represents a predicate as counter register name. -// -const char* emitter::emitPredicateAsCounterRegName(regNumber reg) -{ - assert((reg >= REG_P0) && (reg <= REG_P15)); - - int index = (int)reg - (int)REG_P0; - - return pnRegNames[index]; + return (ptype == PREDICATE_N_SIZED) ? pnRegNames[index] : pRegNames[index]; } /***************************************************************************** @@ -14209,7 +14191,7 @@ void emitter::emitIns_Call(EmitCallType callType, case IF_SVE_CY_3B: case IF_SVE_GE_4A: case IF_SVE_HT_4A: - assert(regpos >= 1 && regpos <= 2); + assert((regpos == 1) || (regpos == 2)); return (regpos == 1 ? PREDICATE_SIZED : PREDICATE_ZERO); default: @@ -17414,15 +17396,7 @@ void emitter::emitDispSveConsecutiveRegList(regNumber firstReg, unsigned listSiz void emitter::emitDispPredicateReg(regNumber reg, PredicateType ptype, insOpts opt, bool addComma) { assert(isPredicateRegister(reg)); - - if (ptype == PREDICATE_N_SIZED) - { - printf(emitPredicateAsCounterRegName(reg)); - } - else - { - printf(emitPredicateRegName(reg)); - } + printf(emitPredicateRegName(reg, ptype)); if (ptype == PREDICATE_MERGE) { diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index baef6a3df249e..04f8322a06fc9 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -30,8 +30,7 @@ enum PredicateType const char* emitSveRegName(regNumber reg); const char* emitVectorRegName(regNumber reg); -const char* emitPredicateRegName(regNumber reg); -const char* emitPredicateAsCounterRegName(regNumber reg); +const char* emitPredicateRegName(regNumber reg, PredicateType ptype); void emitDispInsHelp( instrDesc* id, bool isNew, bool doffs, bool asmfm, unsigned offset, BYTE* pCode, size_t sz, insGroup* ig);