@@ -2138,19 +2138,13 @@ void emitter::emitJumpDistBind()
21382138
21392139size_t emitter::emitOutputInstr (insGroup* ig, instrDesc* id, BYTE** dp)
21402140{
2141- BYTE* dstRW = *dp + writeableOffset;
2142- BYTE* dstRW2 = dstRW + 4 ; // addr for updating gc info if needed.
2143- code_t code = 0 ;
2144- instruction ins;
2145- size_t sz; // = emitSizeOfInsDsc(id);
2146-
2147- #ifdef DEBUG
2148- #if DUMP_GC_TABLES
2149- bool dspOffs = emitComp->opts .dspGCtbls ;
2150- #else
2151- bool dspOffs = !emitComp->opts .disDiffable ;
2152- #endif
2153- #endif // DEBUG
2141+ BYTE* dstRW = *dp + writeableOffset;
2142+ BYTE* dstRW2 = dstRW + 4 ; // addr for updating gc info if needed.
2143+ const BYTE* const odstRW = dstRW;
2144+ const BYTE* const odst = *dp;
2145+ code_t code = 0 ;
2146+ instruction ins;
2147+ size_t sz; // = emitSizeOfInsDsc(id);
21542148
21552149 assert (REG_NA == (int )REG_NA);
21562150
@@ -2879,12 +2873,12 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
28792873
28802874 if (emitComp->opts .disAsm || emitComp->verbose )
28812875 {
2882- code_t * cp = ( code_t *)(*dp + writeableOffset);
2883- while ((BYTE*)cp != dstRW)
2884- {
2885- emitDisInsName (*cp, (BYTE*)cp, id) ;
2886- cp++;
2887- }
2876+ # if DUMP_GC_TABLES
2877+ bool dspOffs = emitComp-> opts . dspGCtbls ;
2878+ # else // !DUMP_GC_TABLES
2879+ bool dspOffs = !emitComp-> opts . disDiffable ;
2880+ # endif // !DUMP_GC_TABLES
2881+ emitDispIns (id, false , dspOffs, true , emitCurCodeOffs (odst), *dp, (dstRW - odstRW), ig);
28882882 }
28892883
28902884 if (emitComp->compDebugBreak )
@@ -2896,7 +2890,12 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
28962890 assert (!" JitBreakEmitOutputInstr reached" );
28972891 }
28982892 }
2899- #endif
2893+ #else // !DEBUG
2894+ if (emitComp->opts .disAsm )
2895+ {
2896+ emitDispIns (id, false , false , true , emitCurCodeOffs (odst), *dp, (dstRW - odstRW), ig);
2897+ }
2898+ #endif // !DEBUG
29002899
29012900 /* All instructions are expected to generate code */
29022901
@@ -2910,8 +2909,6 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
29102909/* ****************************************************************************/
29112910/* ****************************************************************************/
29122911
2913- #ifdef DEBUG
2914-
29152912// clang-format off
29162913static const char * const RegNames[] =
29172914{
@@ -2922,39 +2919,32 @@ static const char* const RegNames[] =
29222919
29232920// ----------------------------------------------------------------------------------------
29242921// Disassemble the given instruction.
2925- // The `emitter::emitDisInsName ` is focused on the most important for debugging.
2922+ // The `emitter::emitDispInsName ` is focused on the most important for debugging.
29262923// So it implemented as far as simply and independently which is very useful for
29272924// porting easily to the release mode.
29282925//
29292926// Arguments:
29302927// code - The instruction's encoding.
29312928// addr - The address of the code.
2929+ // doffs - Flag informing whether the instruction's offset should be displayed.
2930+ // insOffset - The instruction's offset.
29322931// id - The instrDesc of the code if needed.
29332932//
29342933// Note:
29352934// The length of the instruction's name include aligned space is 15.
29362935//
29372936
2938- void emitter::emitDisInsName (code_t code, const BYTE* addr, instrDesc* id)
2937+ void emitter::emitDispInsName (code_t code, const BYTE* addr, bool doffs, unsigned insOffset , instrDesc* id)
29392938{
29402939 const BYTE* insAdr = addr - writeableOffset;
29412940
29422941 unsigned int opcode = code & 0x7f ;
29432942 assert ((opcode & 0x3 ) == 0x3 );
29442943
2945- bool disOpcode = !emitComp->opts .disDiffable ;
2946- bool disAddr = emitComp->opts .disAddr ;
2947- if (disAddr)
2948- {
2949- printf (" 0x%llx" , insAdr);
2950- }
2944+ emitDispInsAddr (insAdr);
2945+ emitDispInsOffs (insOffset, doffs);
29512946
2952- printf (" " );
2953-
2954- if (disOpcode)
2955- {
2956- printf (" %08X " , code);
2957- }
2947+ printf (" " );
29582948
29592949 switch (opcode)
29602950 {
@@ -3915,15 +3905,38 @@ void emitter::emitDispInsHex(instrDesc* id, BYTE* code, size_t sz)
39153905 }
39163906}
39173907
3908+ void emitter::emitDispInsInstrNum (const instrDesc* id) const
3909+ {
3910+ #ifdef DEBUG
3911+ if (!emitComp->verbose )
3912+ return ;
3913+
3914+ printf (" IN%04x: " , id->idDebugOnlyInfo ()->idNum );
3915+ #endif // DEBUG
3916+ }
3917+
39183918void emitter::emitDispIns (
39193919 instrDesc* id, bool isNew, bool doffs, bool asmfm, unsigned offset, BYTE* pCode, size_t sz, insGroup* ig)
39203920{
3921- // RISCV64 implements this similar by `emitter::emitDisInsName`.
3922- // For RISCV64 maybe the `emitDispIns` is over complicate.
3923- // The `emitter::emitDisInsName` is focused on the most important for debugging.
3924- NYI_RISCV64 (" RISCV64 not used the emitter::emitDispIns" );
3921+ if (pCode == nullptr )
3922+ return ;
3923+
3924+ emitDispInsInstrNum (id);
3925+
3926+ const BYTE* instr = pCode + writeableOffset;
3927+ size_t instrSize;
3928+ for (size_t i = 0 ; i < sz; instr += instrSize, i += instrSize, offset += instrSize)
3929+ {
3930+ // TODO-RISCV64: support different size instructions
3931+ instrSize = sizeof (code_t );
3932+ code_t instruction;
3933+ memcpy (&instruction, instr, instrSize);
3934+ emitDispInsName (instruction, instr, doffs, offset, id);
3935+ }
39253936}
39263937
3938+ #ifdef DEBUG
3939+
39273940/* ****************************************************************************
39283941 *
39293942 * Display a stack frame reference.
0 commit comments