Refactor setting of compilation mode and cache mode

This change refactors the setting of the compilation mode, so that
instead of using a 'gOfflineCompiler' bool together with a
'gOfflineCompilerOutputType' enum, a single 'gCompilationMode' enum
is used.  The default value for gCompilationMode is 'kOnline', which
is equivalent to the previous defaulting of gOfflineCompiler to false.

In addition, it refactors the setting of the compilation cache mode,
so that instead of the 'gForceSpirVCache' and 'gForceSpirVGenerate'
bools, a single 'gCompilationCacheMode' enum is used.  The default
value for gCompilationCacheMode is 'kCacheModeCompileIfAbsent', which
is equivalent to the previous defaulting of both booleans to false.
This commit is contained in:
Stuart Brady
2019-06-27 17:44:54 +01:00
committed by Kévin Petit
parent 814dd8adc0
commit 9be570cdf0
6 changed files with 62 additions and 39 deletions

View File

@@ -27,11 +27,9 @@
using namespace std;
bool gOfflineCompiler = false;
bool gForceSpirVCache = false;
bool gForceSpirVGenerate = false;
std::string gSpirVPath = ".";
OfflineCompilerOutputType gOfflineCompilerOutputType;
CompilationMode gCompilationMode = kOnline;
CompilationCacheMode gCompilationCacheMode = kCacheModeCompileIfAbsent;
std::string gSpirVPath = ".";
void helpInfo ()
{
@@ -78,29 +76,27 @@ int parseCustomParam (int argc, const char *argv[], const char *ignore)
delArg = 1;
if ((i + 1) < argc)
{
gOfflineCompiler = true;
if (!strcmp(argv[i + 1], "binary"))
{
gOfflineCompilerOutputType = kBinary;
gCompilationMode = kBinary;
delArg++;
}
else if (!strcmp(argv[i + 1], "spir_v"))
{
gOfflineCompilerOutputType = kSpir_v;
gCompilationMode = kSpir_v;
delArg++;
if ((i + 3) < argc)
{
if (!strcmp(argv[i + 2], "cache"))
{
gForceSpirVCache = true;
gCompilationCacheMode = kCacheModeForceRead;
gSpirVPath = argv[i + 3];
log_info(" SpirV reading from cache enabled.\n");
delArg += 2;
}
else if (!strcmp(argv[i + 2], "generate"))
{
gForceSpirVGenerate = true;
gCompilationCacheMode = kCacheModeOverwrite;
gSpirVPath = argv[i + 3];
log_info(" SpirV force generate binaries enabled.\n");
delArg += 2;