Fix printf for type BYTE and SHORT

Generated instructions writing to printf buffer require destination
address to be DWORD aligned. Because of that values of type BYTE (1B)
and SHORT (2B) need to be written as 4B value.
This change adds support for this. When trying to read value of type
BYTE or SHORT four bytes are actually read to be aligned with compiler
implementation.

Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
Krystian Chmielewski
2022-09-01 12:08:36 +00:00
committed by Compute-Runtime-Automation
parent 90ba50bf52
commit b04c226767
3 changed files with 52 additions and 43 deletions

View File

@@ -82,8 +82,10 @@ class PrintFormatter {
template <class T>
size_t typedPrintToken(char *output, size_t size, const char *formatString) {
T value = {0};
T value{0};
read(&value);
constexpr auto offsetToBeDwordAligned = static_cast<uint32_t>(std::max(int64_t(sizeof(int) - sizeof(T)), int64_t(0)));
currentOffset += offsetToBeDwordAligned;
return simpleSprintf(output, size, formatString, value);
}