Commit 56e0a2ac authored by Adam Kallai's avatar Adam Kallai Committed by Commit Bot

Fix the substitution of neon arrangement specifiers

NEONFormatDecoder::Substitute function utilizes snprintf()
to substitute arrangement specifier into a format string.
Some instruction format strings (e.i. ld4r) are specified
with '%n$' positional parameter fields, but on Windows
snprintf function doesn't support these parameters.
NEONFormatDecoder logic is extended to handle four parameters
in order to avoid using positional parameters.

Bug: v8:10365
Change-Id: I79d4014c6b45d698ca47090a74c30e4eae856334
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2148776Reviewed-by: 's avatarMartyn Capewell <martyn.capewell@arm.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67201}
parent b47893fc
......@@ -343,6 +343,10 @@ void NEONFormatDecoder::SetFormatMaps(const NEONFormatMap* format0,
formats_[0] = format0;
formats_[1] = (format1 == nullptr) ? formats_[0] : format1;
formats_[2] = (format2 == nullptr) ? formats_[1] : format2;
// Support four parameters form (e.i. ld4r)
// to avoid using positional arguments in DisassemblingDecoder.
// See: https://crbug.com/v8/10365
formats_[3] = formats_[2];
}
void NEONFormatDecoder::SetFormatMap(unsigned index,
......@@ -353,15 +357,18 @@ void NEONFormatDecoder::SetFormatMap(unsigned index,
}
const char* NEONFormatDecoder::SubstitutePlaceholders(const char* string) {
return Substitute(string, kPlaceholder, kPlaceholder, kPlaceholder);
return Substitute(string, kPlaceholder, kPlaceholder, kPlaceholder,
kPlaceholder);
}
const char* NEONFormatDecoder::Substitute(const char* string,
SubstitutionMode mode0,
SubstitutionMode mode1,
SubstitutionMode mode2) {
SubstitutionMode mode2,
SubstitutionMode mode3) {
snprintf(form_buffer_, sizeof(form_buffer_), string, GetSubstitute(0, mode0),
GetSubstitute(1, mode1), GetSubstitute(2, mode2));
GetSubstitute(1, mode1), GetSubstitute(2, mode2),
GetSubstitute(3, mode3));
return form_buffer_;
}
......
......@@ -619,7 +619,8 @@ class NEONFormatDecoder {
// substitution mode.
const char* Substitute(const char* string, SubstitutionMode mode0 = kFormat,
SubstitutionMode mode1 = kFormat,
SubstitutionMode mode2 = kFormat);
SubstitutionMode mode2 = kFormat,
SubstitutionMode mode3 = kFormat);
// Append a "2" to a mnemonic string based of the state of the Q bit.
const char* Mnemonic(const char* mnemonic);
......@@ -738,7 +739,7 @@ class NEONFormatDecoder {
uint8_t PickBits(const uint8_t bits[]);
Instr instrbits_;
const NEONFormatMap* formats_[3];
const NEONFormatMap* formats_[4];
char form_buffer_[64];
char mne_buffer_[16];
};
......
......@@ -2252,10 +2252,10 @@ void DisassemblingDecoder::VisitNEONExtract(Instruction* instr) {
void DisassemblingDecoder::VisitNEONLoadStoreMultiStruct(Instruction* instr) {
const char* mnemonic = nullptr;
const char* form = nullptr;
const char* form_1v = "{'Vt.%1$s}, ['Xns]";
const char* form_2v = "{'Vt.%1$s, 'Vt2.%1$s}, ['Xns]";
const char* form_3v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s}, ['Xns]";
const char* form_4v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns]";
const char* form_1v = "{'Vt.%s}, ['Xns]";
const char* form_2v = "{'Vt.%s, 'Vt2.%s}, ['Xns]";
const char* form_3v = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s}, ['Xns]";
const char* form_4v = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s, 'Vt4.%s}, ['Xns]";
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LoadStoreFormatMap());
switch (instr->Mask(NEONLoadStoreMultiStructMask)) {
......@@ -2349,11 +2349,10 @@ void DisassemblingDecoder::VisitNEONLoadStoreMultiStructPostIndex(
Instruction* instr) {
const char* mnemonic = nullptr;
const char* form = nullptr;
const char* form_1v = "{'Vt.%1$s}, ['Xns], 'Xmr1";
const char* form_2v = "{'Vt.%1$s, 'Vt2.%1$s}, ['Xns], 'Xmr2";
const char* form_3v = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s}, ['Xns], 'Xmr3";
const char* form_4v =
"{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns], 'Xmr4";
const char* form_1v = "{'Vt.%s}, ['Xns], 'Xmr1";
const char* form_2v = "{'Vt.%s, 'Vt2.%s}, ['Xns], 'Xmr2";
const char* form_3v = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s}, ['Xns], 'Xmr3";
const char* form_4v = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s, 'Vt4.%s}, ['Xns], 'Xmr4";
NEONFormatDecoder nfd(instr, NEONFormatDecoder::LoadStoreFormatMap());
switch (instr->Mask(NEONLoadStoreMultiStructPostIndexMask)) {
......@@ -2561,7 +2560,7 @@ void DisassemblingDecoder::VisitNEONLoadStoreSingleStruct(Instruction* instr) {
break;
case NEON_LD4R:
mnemonic = "ld4r";
form = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns]";
form = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s, 'Vt4.%s}, ['Xns]";
break;
default:
break;
......@@ -2722,7 +2721,7 @@ void DisassemblingDecoder::VisitNEONLoadStoreSingleStructPostIndex(
break;
case NEON_LD4R_post:
mnemonic = "ld4r";
form = "{'Vt.%1$s, 'Vt2.%1$s, 'Vt3.%1$s, 'Vt4.%1$s}, ['Xns], 'Xmz4";
form = "{'Vt.%s, 'Vt2.%s, 'Vt3.%s, 'Vt4.%s}, ['Xns], 'Xmz4";
break;
default:
break;
......
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