[Beignet] [PATCH] GBE: increase the disassembly output's readability.
Zhigang Gong
zhigang.gong at intel.com
Tue Jan 21 18:42:29 PST 2014
Add label information and the instruction address
prefix. Make the address consistent with fulsim.
And also make the register allocation output a little
bit prettier.
Now the disassembly output is as below:
compiler_ceil's disassemble begin:
L0:
(0 ) mov(1) f0<1>UW 0x0UW { align1 WE_all };
....
(32 ) (+f0) mov(16) g1<1>UW 0x1UW { align1 WE_normal 1H };
L1:
(34 ) mov(16) g112<1>UD g0<8,8,1>UD { align1 WE_all 1H };
...
compiler_ceil's disassemble end.
The register allocation output is as below:
%26 g2 .8 4 B [0 -> 0 ]
%28 g2 .12 4 B [0 -> 6 ]
%29 g2 .16 4 B [0 -> 9 ]
%30 g126.0 64 B [2 -> 3 ]
%31 g124.0 64 B [3 -> 4 ]
Please be noted, the register allocation's output is not correct
when the register is a pure scalar(bool) register which allocated
at the backend instruction selection stage. To be fixed.
Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
backend/src/backend/gen_context.cpp | 17 +++++++++++++++--
backend/src/backend/gen_reg_allocation.cpp | 8 +++++---
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index ecb8ef3..584d9d0 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -33,6 +33,8 @@
#include "ir/function.hpp"
#include "sys/cvar.hpp"
#include <cstring>
+#include <iostream>
+#include <iomanip>
namespace gbe
{
@@ -1878,9 +1880,20 @@ namespace gbe
genKernel->insnNum = p->store.size();
genKernel->insns = GBE_NEW_ARRAY_NO_ARG(GenInstruction, genKernel->insnNum);
std::memcpy(genKernel->insns, &p->store[0], genKernel->insnNum * sizeof(GenInstruction));
- if (OCL_OUTPUT_ASM)
- for (uint32_t insnID = 0; insnID < genKernel->insnNum; ++insnID)
+ if (OCL_OUTPUT_ASM) {
+ std::cout << genKernel->getName() << "'s disassemble begin:" << std::endl;
+ ir::LabelIndex curLabel = (ir::LabelIndex)0;
+ std::cout << " L0:" << std::endl;
+ for (uint32_t insnID = 0; insnID < genKernel->insnNum; ++insnID) {
+ if (labelPos.find((ir::LabelIndex)(curLabel + 1))->second == insnID) {
+ std::cout << " L" << curLabel + 1 << ":" << std::endl;
+ curLabel = (ir::LabelIndex)(curLabel + 1);
+ }
+ std::cout << " (" << std::setw(8) << insnID * 2 << ") ";
gen_disasm(stdout, &p->store[insnID]);
+ }
+ std::cout << genKernel->getName() << "'s disassemble end." << std::endl;
+ }
return true;
}
diff --git a/backend/src/backend/gen_reg_allocation.cpp b/backend/src/backend/gen_reg_allocation.cpp
index 25db169..51a9f76 100644
--- a/backend/src/backend/gen_reg_allocation.cpp
+++ b/backend/src/backend/gen_reg_allocation.cpp
@@ -691,9 +691,11 @@ namespace gbe
if (!ctx.isScalarReg(vReg))
registerSize *= ctx.getSimdWidth();
}
- cout << "%" << setw(-8) << vReg << "\tg" << setw(-3) << reg << "." << setw(-2) << subreg << "B"
- << "\t" << setw(3) << registerSize
- << "\t[" << setw(8) << this->intervals[(uint)vReg].minID
+ cout << "%" << setiosflags(ios::left) << setw(8) << vReg << "g"
+ << setiosflags(ios::left) << setw(3) << reg << "."
+ << setiosflags(ios::left) << setw(2) << subreg
+ << " " << setw(3) << registerSize << "B"
+ << " [" << setw(8) << this->intervals[(uint)vReg].minID
<< " -> " << setw(8) << this->intervals[(uint)vReg].maxID
<< "]" << endl;
}
--
1.7.9.5
More information about the Beignet
mailing list