Skip to content

Commit eb3de50

Browse files
weiyu-chensys_zuul
authored andcommitted
Fix vISA options printing in the .asm file.
Change-Id: Ia0196145873275bc447f3d348b7f4144e763ebf8
1 parent 30de3da commit eb3de50

File tree

4 files changed

+63
-51
lines changed

4 files changed

+63
-51
lines changed

visa/FlowGraph.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,9 +4241,10 @@ void G4_Kernel::emit_asm(std::ostream& output, bool beforeRegAlloc, void * binar
42414241

42424242
output << "\n" << "//.platform " << platformString[getGenxPlatform()];
42434243
output << "\n" << "//.stepping " << GetSteppingString();
4244-
output << "\n" << "//.CISA version " << (unsigned int)major_version
4244+
output << "\n" << "//.vISA version " << (unsigned int)major_version
42454245
<< "." << (unsigned int)minor_version;
4246-
output << "\n" << "//.options " << m_options->getArgString().str();
4246+
output << "\n" << "//.options_string \"" << m_options->getUserArgString().str() << "\"";
4247+
output << "\n" << "//.full_options \"" << m_options->getFullArgString() << "\"";
42474248
output << "\n" << "//.instCount " << asmInstCount;
42484249
output << "\n//.RA type\t" << RATypeString[RAType];
42494250

visa/Option.cpp

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -489,60 +489,70 @@ void Options::setOption(vISAOptions option, const char* str)
489489
setOptionInternally(option, str);
490490
}
491491

492-
std::stringstream& Options::getArgString()
492+
//
493+
// return full set of arguments ever set by user, either through
494+
// string options or the various setOptions()
495+
//
496+
std::string Options::getFullArgString()
493497
{
494-
if (argString.str().empty())
498+
std::stringstream args;
499+
// Collect all user-set options.
500+
// This is for igc. When igc invokes vISA, it sets options
501+
// via setOption() api instead of options string, thus leave
502+
// argString empty. Here, we re-generate this options strings
503+
// (This is for debugging)
504+
for (int i = vISA_OPTIONS_UNINIT + 1; i < vISA_NUM_OPTIONS; ++i)
495505
{
496-
// Collect all user-set options.
497-
// This is for igc. When igc invokes vISA, it sets options
498-
// via setOption() api instead of options string, thus leave
499-
// argString empty. Here, we re-generate this options strings
500-
// (This is for debugging)
501-
for (int i = vISA_OPTIONS_UNINIT + 1; i < vISA_NUM_OPTIONS; ++i)
506+
vISAOptions o = (vISAOptions)i;
507+
if (isOptionSetByUser(o))
502508
{
503-
vISAOptions o = (vISAOptions)i;
504-
if (isOptionSetByUser(o))
505-
{
506-
EntryType type = m_vISAOptions.getType(o);
507-
switch (type) {
508-
case ET_BOOL:
509-
if (m_vISAOptions.getBool(o) != m_vISAOptions.getDefaultBool(o))
510-
{
511-
// Boolean option means the reverse of the default!
512-
// (Probably should avoid such reverse handling)
513-
argString << m_vISAOptions.getArgStr(o) << " ";
514-
}
515-
break;
516-
case ET_INT32:
517-
argString << m_vISAOptions.getArgStr(o) << " "
518-
<< m_vISAOptions.getUint32(o) << " ";
519-
break;
520-
case ET_INT64:
521-
argString << m_vISAOptions.getArgStr(o) << " "
522-
<< m_vISAOptions.getUint64(o) << " ";
523-
break;
524-
case ET_2xINT32:
525-
{
526-
uint32_t lo32, hi32;
527-
uint64_t val = m_vISAOptions.getUint64(o);
528-
lo32 = (uint32_t)val;
529-
hi32 = (uint32_t)(val >> 32);
530-
argString << m_vISAOptions.getArgStr(o) << " "
531-
<< hi32 << " " << lo32 << " ";
532-
}
533-
break;
534-
case ET_CSTR:
535-
argString << m_vISAOptions.getArgStr(o) << " "
536-
<< m_vISAOptions.getCstr(o) << " ";
537-
break;
538-
default:
539-
assert(false && "Invalid vISA option type!");
540-
argString << "UNDEFINED ";
541-
break;
509+
EntryType type = m_vISAOptions.getType(o);
510+
switch (type) {
511+
case ET_BOOL:
512+
if (m_vISAOptions.getBool(o) != m_vISAOptions.getDefaultBool(o))
513+
{
514+
// Boolean option means the reverse of the default!
515+
// (Probably should avoid such reverse handling)
516+
args << m_vISAOptions.getArgStr(o) << " ";
542517
}
518+
break;
519+
case ET_INT32:
520+
args << m_vISAOptions.getArgStr(o) << " "
521+
<< m_vISAOptions.getUint32(o) << " ";
522+
break;
523+
case ET_INT64:
524+
args << m_vISAOptions.getArgStr(o) << " "
525+
<< m_vISAOptions.getUint64(o) << " ";
526+
break;
527+
case ET_2xINT32:
528+
{
529+
uint32_t lo32, hi32;
530+
uint64_t val = m_vISAOptions.getUint64(o);
531+
lo32 = (uint32_t)val;
532+
hi32 = (uint32_t)(val >> 32);
533+
args << m_vISAOptions.getArgStr(o) << " "
534+
<< hi32 << " " << lo32 << " ";
535+
}
536+
break;
537+
case ET_CSTR:
538+
args << m_vISAOptions.getArgStr(o) << " "
539+
<< m_vISAOptions.getCstr(o) << " ";
540+
break;
541+
default:
542+
assert(false && "Invalid vISA option type!");
543+
args << "UNDEFINED ";
544+
break;
543545
}
544546
}
545547
}
548+
return args.str();
549+
}
550+
551+
//
552+
// this returns the options string explicitly passed in by user
553+
//
554+
std::stringstream& Options::getUserArgString()
555+
{
546556
return argString;
547557
}
548558

visa/Option.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ class Options {
166166

167167
static void showUsage(std::ostream& output);
168168

169-
std::stringstream& getArgString();
169+
std::stringstream& getUserArgString();
170+
std::string getFullArgString();
170171
std::string getEncoderOutputFile();
171172
// Debug print of options
172173
void dump(void) const;

visa/include/VISAOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ DEF_VISA_OPTION(vISA_clearAccBeforeEOT, ET_BOOL, "-clearAccBeforeEO
220220
DEF_VISA_OPTION(vISA_replaceIndirectCallWithJmpi, ET_BOOL, "-replaceIndirectCallWithJmpi", UNUSED, false)
221221
DEF_VISA_OPTION(vISA_noMaskWA, ET_INT32, "-noMaskWA", "USAGE: -noMaskWA <[0:1]=0 (off)|1|2|3(3=2), [2:3]=any>\n", 0)
222222
DEF_VISA_OPTION(vISA_forceNoMaskWA, ET_BOOL, "-forceNoMaskWA", UNUSED, false)
223-
DEF_VISA_OPTION(vISA_DstSrcOverlapWA, ET_BOOL, "-dstSrcOverlapWA", UNUSED, true)
223+
DEF_VISA_OPTION(vISA_DstSrcOverlapWA, ET_BOOL, "-dstSrcOverlapWA", UNUSED, true)
224224

225225
//=== HW debugging options ===
226226
DEF_VISA_OPTION(vISA_GenerateDebugInfo, ET_BOOL, "-generateDebugInfo", UNUSED, false)

0 commit comments

Comments
 (0)