Subzero: add subzeroEmitTextAsm flag
If enabled, and ALLOW_DUMP = 1, emit() outputs text asm to stdout along
with liveness info. Useful for debugging register allocation.
Bug: b/144688789
Change-Id: I36137c439f6f2ca32af6f208146501b095ccfac4
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38478
Tested-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 06409ff..0a93e27 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -162,9 +162,11 @@
const bool emulateMismatchedBitCast = CPUID::ARM;
constexpr bool subzeroDumpEnabled = false;
+ constexpr bool subzeroEmitTextAsm = false;
#if !ALLOW_DUMP
static_assert(!subzeroDumpEnabled, "Compile Subzero with ALLOW_DUMP=1 for subzeroDumpEnabled");
+ static_assert(!subzeroEmitTextAsm, "Compile Subzero with ALLOW_DUMP=1 for subzeroEmitTextAsm");
#endif
}
@@ -600,6 +602,12 @@
static llvm::raw_os_ostream cout(std::cout);
static llvm::raw_os_ostream cerr(std::cerr);
+ if (subzeroEmitTextAsm)
+ {
+ // Decorate text asm with liveness info
+ Flags.setDecorateAsm(true);
+ }
+
if(false) // Write out to a file
{
std::error_code errorCode;
@@ -679,6 +687,12 @@
}
::context->emitFileHeader();
+
+ if (subzeroEmitTextAsm)
+ {
+ ::function->emit();
+ }
+
::function->emitIAS();
auto assembler = ::function->releaseAssembler();
auto objectWriter = ::context->getObjectWriter();