Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show address offsets in hex #73816

Merged
merged 3 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions src/coreclr/jit/emitarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(", ");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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("]");

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 18 additions & 7 deletions src/coreclr/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("#");
}
Expand Down Expand Up @@ -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("%llXH", imm);
}
else
{
printf("0x%llx", imm);
}
}
else
{
printf("0x%02x", (unsigned)imm);
printf("%02XH", (unsigned)imm);
jakobbotsch marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -12253,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("]");

Expand All @@ -12264,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
Expand Down Expand Up @@ -12298,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("]");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitarm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
void emitDispFloatZero();
void emitDispFloatImm(ssize_t imm8);
void emitDispImmOptsLSL12(ssize_t imm, insOpts opt);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down