Commit 57560fd6 authored by Connor Abbott's avatar Connor Abbott

bifrost: Decode bit-saving trick for registers

This makes the disassembly of vertex shaders much more sane.
parent 5fa78525
......@@ -41,6 +41,19 @@ struct RegCtrl {
bool clauseStart;
};
static unsigned getReg0(Regs regs)
{
if (regs.ctrl == 0)
return regs.reg0 | ((regs.reg1 & 0x1) << 5);
return regs.reg0 <= regs.reg1 ? regs.reg0 : 63 - regs.reg0;
}
static unsigned getReg1(Regs regs)
{
return regs.reg0 <= regs.reg1 ? regs.reg1 : 63 - regs.reg1;
}
static RegCtrl DecodeRegCtrl(Regs regs)
{
RegCtrl decoded = {};
......@@ -118,15 +131,10 @@ static void DumpRegs(Regs srcs)
{
RegCtrl ctrl = DecodeRegCtrl(srcs);
printf("# ");
if (ctrl.readReg0) {
unsigned reg0 = srcs.reg0;
if (srcs.ctrl == 0)
reg0 |= (srcs.reg1 & 1) << 5;
printf("port 0: R%d ", reg0);
}
if (ctrl.readReg0)
printf("port 0: R%d ", getReg0(srcs));
if (ctrl.readReg1)
printf("port 1: R%" PRId64 " ", srcs.reg1);
printf("port 1: R%d ", getReg1(srcs));
if (ctrl.FMAWriteUnit == RegWrite2)
printf("port 2: R%" PRId64 " (write FMA) ", srcs.reg2);
......@@ -178,14 +186,8 @@ static uint64_t GetConst(uint64_t *consts, Regs srcs)
static void DumpSrc(unsigned src, Regs srcs, uint64_t *consts, bool isFMA)
{
switch (src) {
case 0: {
unsigned reg = srcs.reg0;
if (srcs.ctrl == 0)
reg |= (srcs.reg1 & 1) << 5;
printf("R%d", reg);
break;
}
case 1: printf("R%" PRId64, srcs.reg1); break;
case 0: printf("R%d", getReg0(srcs)); break;
case 1: printf("R%d", getReg1(srcs)); break;
case 2: printf("R%" PRId64, srcs.reg3); break;
case 3:
if (isFMA)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment