From 439e3dde3b080a098689adfc6604ea196e3e4ab4 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 17 Sep 2015 08:46:23 -0400
Subject: [PATCH] P4 to Git Change 1191624 by emankov@em-hsa-amd on 2015/09/17
08:40:13
ECR #333753 - Compiler Lib: Bug 10998 - Add a way to pass options to finalizer (-Wh,-finalizer-option)
Works only for HSAIL path.
Testing: complib -Wh, pre check-in
Reviewer: Nikolay Haustov
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/hsail_be.cpp#52 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/OPTIONS.def#131 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/options.cpp#33 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/options.hpp#18 edit
... //depot/stg/opencl/drivers/opencl/tests/hsa/src/complib/options/-Wh/HelloWorld_Kernel_cl.cl#1 add
... //depot/stg/opencl/drivers/opencl/tests/hsa/tlst/complib.tlst#15 edit
[ROCm/clr commit: 087722ed4949e14116ffc023f0f03a682a62b102]
---
projects/clr/rocclr/compiler/lib/utils/OPTIONS.def | 8 ++++++++
projects/clr/rocclr/compiler/lib/utils/options.cpp | 14 +++++++++++++-
projects/clr/rocclr/compiler/lib/utils/options.hpp | 13 +++++++++----
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def b/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def
index 9d31dafcae..bd9afe5459 100644
--- a/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def
+++ b/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def
@@ -526,6 +526,14 @@ OPTION(OT_CSTRING, \
0, 0, 0, NULL, \
"Pass comma-separated to the backend (llvm)")
+// -Wh, : pass comma-separated to the finalizer (sc)
+OPTION(OT_CSTRING, \
+ OA_RUNTIME|OVIS_SUPPORT|OVA_REQUIRED|OA_SEPARATOR_NONE, \
+ "Wh,", NULL, \
+ WHComma, \
+ 0, 0, 0, NULL, \
+ "Pass comma-separated to the finalizer (sc)")
+
// -O[0|1|2|3|4|5]
OPTION(OT_UINT32, \
OA_RUNTIME|OVA_OPTIONAL|OA_SEPARATOR_NONE, \
diff --git a/projects/clr/rocclr/compiler/lib/utils/options.cpp b/projects/clr/rocclr/compiler/lib/utils/options.cpp
index 810baf7960..f23ca1be32 100644
--- a/projects/clr/rocclr/compiler/lib/utils/options.cpp
+++ b/projects/clr/rocclr/compiler/lib/utils/options.cpp
@@ -267,7 +267,7 @@ ShowOptionsHelp(const char* helpValue, Options& Opts)
std::string pntVal;
switch (OPTION_type(od)) {
case OT_CSTRING:
- if ((i == OID_WFComma) || (i == OID_WBComma)) {
+ if ((i == OID_WFComma) || (i == OID_WBComma) || (i == OID_WHComma)) {
pntVal = "";
}
else if (i == OID_SaveTemps) {
@@ -858,6 +858,7 @@ processOption(int OptDescTableIx, Options& Opts, const std::string& Value,
case OID_WFComma:
case OID_WBComma:
+ case OID_WHComma:
if (sval != NULL) {
// we know that sval was new'ed
for (char* p=(char*)sval; *p; ++p) {
@@ -878,6 +879,9 @@ processOption(int OptDescTableIx, Options& Opts, const std::string& Value,
Opts.llvmOptions.append(" ");
Opts.llvmOptions.append(sval);
}
+ else if (((OptionIdentifier)OptDescTableIx) == OID_WHComma) {
+ Opts.finalizerOptions.push_back(sval);
+ }
}
break;
@@ -1587,6 +1591,14 @@ bool Options::setOptionVariablesAs(const Options& other)
return true;
}
+std::string Options::getStringFromStringVec(std::vector& stringVec)
+{
+ const char* const delim = " ";
+ std::ostringstream strstr;
+ std::copy(stringVec.begin(), stringVec.end(), std::ostream_iterator(strstr, delim));
+ return strstr.str();
+}
+
} // option
}// amd
diff --git a/projects/clr/rocclr/compiler/lib/utils/options.hpp b/projects/clr/rocclr/compiler/lib/utils/options.hpp
index de8af867b3..ceb4a9b34d 100644
--- a/projects/clr/rocclr/compiler/lib/utils/options.hpp
+++ b/projects/clr/rocclr/compiler/lib/utils/options.hpp
@@ -198,10 +198,11 @@ class Options {
public:
std::string origOptionStr;
- OptionVariables *oVariables; // pointer to a struct of all option variables
- std::string clcOptions; // options passed into EDG frontend (clc)
- std::vector clangOptions; // Options passed into Clang frontend.
- std::string llvmOptions; // options passed into backend (llvm)
+ OptionVariables *oVariables; // pointer to a struct of all option variables
+ std::string clcOptions; // options passed into EDG frontend (clc)
+ std::vector clangOptions; // options passed into Clang frontend
+ std::string llvmOptions; // options passed into backend (llvm)
+ std::vector finalizerOptions; // options passed into finalizer
// Given as build option
int WorkGroupSize[3]; // -1: use default
@@ -279,6 +280,8 @@ public:
// Set the option variables same as defined in "other"
bool setOptionVariablesAs(const Options& other);
+ std::string getFinalizerOptions() { return getStringFromStringVec(finalizerOptions); }
+
private:
std::string fullPath, baseName;
long basename_max;
@@ -310,7 +313,9 @@ private:
(f & DUMP_ENCRYPT));
}
+ std::string getStringFromStringVec(std::vector& stringVec);
void setDumpFileName(const char* val);
+
public:
LibrarySelector libraryType_;
std::string sourceFileName_;