From 12a20fdb855c8185dbc29d3204b562bf9005a91f Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Aug 2022 13:52:42 -0700 Subject: [PATCH 1/3] Show address offsets in hex --- src/coreclr/jit/emitarm64.cpp | 19 +++++++++++++++---- src/coreclr/jit/emitarm64.h | 2 +- src/coreclr/jit/emitxarch.cpp | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index f4e5896bdb533..3802d1b111008 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -11790,9 +11790,13 @@ void emitter::emitDispInst(instruction ins) * * Display an immediate value */ -void emitter::emitDispImm(ssize_t imm, bool addComma, bool alwaysHex /* =false */) +void emitter::emitDispImm(ssize_t imm, bool addComma, bool alwaysHex /* =false */, bool isAddrOffset /* =false */) { - if (strictArmAsm) + if (isAddrOffset) + { + alwaysHex = true; + } + else if (strictArmAsm) { printf("#"); } @@ -11821,11 +11825,18 @@ void emitter::emitDispImm(ssize_t imm, bool addComma, bool alwaysHex /* =false * if ((imm & 0xFFFFFFFF00000000LL) != 0) { - printf("0x%llx", imm); + if (isAddrOffset) + { + printf("%08XH", imm); + } + else + { + printf("0x%llx", imm); + } } else { - printf("0x%02x", (unsigned)imm); + printf("%02XH", (unsigned)imm); } } diff --git a/src/coreclr/jit/emitarm64.h b/src/coreclr/jit/emitarm64.h index 30ceeb4f34b80..e2be5a939c9d8 100644 --- a/src/coreclr/jit/emitarm64.h +++ b/src/coreclr/jit/emitarm64.h @@ -26,7 +26,7 @@ void emitDispInsHelp( void emitDispLargeJmp( instrDesc* id, bool isNew, bool doffs, bool asmfm, unsigned offset, BYTE* pCode, size_t sz, insGroup* ig); void emitDispInst(instruction ins); -void emitDispImm(ssize_t imm, bool addComma, bool alwaysHex = false); +void emitDispImm(ssize_t imm, bool addComma, bool alwaysHex = false, bool isAddrOffset = false); void emitDispFloatZero(); void emitDispFloatImm(ssize_t imm8); void emitDispImmOptsLSL12(ssize_t imm, insOpts opt); diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 1e645ad73fdb0..cbba666f80eb7 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -8710,7 +8710,7 @@ void emitter::emitDispAddrMode(instrDesc* id, bool noDetail) } else if (disp < 1000) { - printf("%d", (unsigned)disp); + printf("%02XH", (unsigned)disp); } else if (disp <= 0xFFFF) { @@ -8729,7 +8729,7 @@ void emitter::emitDispAddrMode(instrDesc* id, bool noDetail) } else if (disp > -1000) { - printf("-%d", (unsigned)-disp); + printf("-%02XH", (unsigned)-disp); } else if (disp >= -0xFFFF) { From 8f66b07cc803249e904245ab4eaec02bba7f65e7 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Aug 2022 14:11:25 -0700 Subject: [PATCH 2/3] fix the rebase errors --- src/coreclr/jit/emitarm64.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 3802d1b111008..3fb57a30d71d1 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -11827,7 +11827,7 @@ void emitter::emitDispImm(ssize_t imm, bool addComma, bool alwaysHex /* =false * { if (isAddrOffset) { - printf("%08XH", imm); + printf("%llXH", imm); } else { @@ -12264,7 +12264,7 @@ void emitter::emitDispAddrRI(regNumber reg, insOpts opt, ssize_t imm) if (!insOptsPostIndex(opt) && (imm != 0)) { printf(","); - emitDispImm(imm, false); + emitDispImm(imm, false, true, true); } printf("]"); @@ -12275,7 +12275,7 @@ void emitter::emitDispAddrRI(regNumber reg, insOpts opt, ssize_t imm) else if (insOptsPostIndex(opt)) { printf(","); - emitDispImm(imm, false); + emitDispImm(imm, false, true, true); } } else // !strictArmAsm @@ -12309,7 +12309,7 @@ void emitter::emitDispAddrRI(regNumber reg, insOpts opt, ssize_t imm) { printf("%c", operStr[1]); } - emitDispImm(imm, false); + emitDispImm(imm, false, true, true); printf("]"); } } From e6c901b42de13a2c6ada5f15a7035df81789b7e0 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 11 Aug 2022 14:27:56 -0700 Subject: [PATCH 3/3] Add support for arm --- src/coreclr/jit/emitarm.cpp | 33 +++++++++++++++++++++++++++------ src/coreclr/jit/emitarm.h | 2 +- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index c474fc3d1324c..faca533e53946 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -6770,16 +6770,37 @@ void emitter::emitDispInst(instruction ins, insFlags flags) * * Display an immediate value */ -void emitter::emitDispImm(int imm, bool addComma, bool alwaysHex /* =false */) +void emitter::emitDispImm(int imm, bool addComma, bool alwaysHex /* =false */, bool isAddrOffset /*= false*/) { if (!alwaysHex && (imm > -1000) && (imm < 1000)) + { printf("%d", imm); + } else if ((imm > 0) || (imm == -imm) || // -0x80000000 == 0x80000000. So we don't want to add an extra "-" at the beginning. (emitComp->opts.disDiffable && (imm == (int)0xD1FFAB1E))) // Don't display this as negative - printf("0x%02x", imm); - else // val <= -1000 - printf("-0x%02x", -imm); + { + if (isAddrOffset) + { + printf("%02XH", imm); + } + else + { + printf("0x%02x", imm); + } + } + else + { + // val <= -1000 + if (isAddrOffset) + { + printf("-%02XH", -imm); + } + else + { + printf("-0x%02x", -imm); + } + } if (addComma) printf(", "); @@ -6953,7 +6974,7 @@ void emitter::emitDispAddrRI(regNumber reg, int imm, emitAttr attr) printf("+"); #endif } - emitDispImm(imm, false, regIsSPorFP); + emitDispImm(imm, false, true, true); } printf("]"); emitDispGC(attr); @@ -7029,7 +7050,7 @@ void emitter::emitDispAddrPUW(regNumber reg, int imm, insOpts opt, emitAttr attr printf("+"); #endif } - emitDispImm(imm, false, regIsSPorFP); + emitDispImm(imm, false, true, true); } printf("]"); diff --git a/src/coreclr/jit/emitarm.h b/src/coreclr/jit/emitarm.h index e1c281a6fccf1..245196bfa1834 100644 --- a/src/coreclr/jit/emitarm.h +++ b/src/coreclr/jit/emitarm.h @@ -28,7 +28,7 @@ unsigned emitOutput_Thumb2Instr(BYTE* dst, code_t code); /************************************************************************/ void emitDispInst(instruction ins, insFlags flags); -void emitDispImm(int imm, bool addComma, bool alwaysHex = false); +void emitDispImm(int imm, bool addComma, bool alwaysHex = false, bool isAddrOffset = false); void emitDispReloc(BYTE* addr); void emitDispCond(int cond); void emitDispShiftOpts(insOpts opt);