P4 to Git Change 1451958 by skudchad@skudchad_test_win_opencl2 on 2017/08/25 19:27:11
SWDEV-116136 - Support -Og for Clang
ReviewBoardURL = http://ocltc.amd.com/reviews/r/13341/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/backends/common/codegen.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/backends/common/linker.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/backends/common/opt_level.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/backends/common/opt_level.hpp#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/backends/common/optimizer.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/backends/gpu/hsail_be.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/backends/gpu/scwrapper/scState.cpp#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/utils/OPTIONS.def#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/utils/options.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/legacy-lib/utils/options.hpp#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/codegen.cpp#73 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/linker.cpp#157 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/opt_level.cpp#33 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/opt_level.hpp#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/optimizer.cpp#30 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/hsail_be.cpp#68 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/OPTIONS.def#136 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/options.cpp#42 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/options.hpp#19 edit
[ROCm/clr commit: 2c0b212d96]
This commit is contained in:
@@ -392,7 +392,7 @@ llvmCodeGen(
|
||||
aclBinary* binary)
|
||||
{
|
||||
const FamilyMapping &familyMap = familySet[binary->target.arch_id];
|
||||
const bool optimize = (OptionsObj ? (OptionsObj->oVariables->OptLevel > 0) : true);
|
||||
const bool optimize = (OptionsObj ? (OptionsObj->oVariables->OptLevel > amd::option::OPT_O0) : true);
|
||||
const TargetMapping* targetMap = familyMap.target;
|
||||
unsigned famID = binary->target.chip_id;
|
||||
if (!targetMap || !targetMap[famID].supported) {
|
||||
@@ -475,20 +475,22 @@ llvmCodeGen(
|
||||
|
||||
CodeGenOpt::Level OLvl = CodeGenOpt::None;
|
||||
switch (OptionsObj->oVariables->OptLevel) {
|
||||
case 0: // -O0
|
||||
case amd::option::OPT_O0: // -O0
|
||||
OLvl = CodeGenOpt::None;
|
||||
break;
|
||||
case 1: // -O1
|
||||
case amd::option::OPT_O1: // -O1
|
||||
OLvl = CodeGenOpt::Less;
|
||||
break;
|
||||
default:
|
||||
assert(!"Error with optimization level");
|
||||
case 2: // -O2
|
||||
case 5: // -O5(-Os)
|
||||
case amd::option::OPT_O2: // -O2
|
||||
case amd::option::OPT_O5: // -O5
|
||||
case amd::option::OPT_OS: // -Os
|
||||
OLvl = CodeGenOpt::Default;
|
||||
break;
|
||||
case 3: // -O3
|
||||
case 4: // -O4
|
||||
case amd::option::OPT_OG: // -Og
|
||||
case amd::option::OPT_O3: // -O3
|
||||
case amd::option::OPT_O4: // -O4
|
||||
OLvl = CodeGenOpt::Aggressive;
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -572,7 +572,7 @@ amdcl::OCLLinker::link(llvm::Module* input, std::vector<std::unique_ptr<llvm::Mo
|
||||
setWholeProgram(true);
|
||||
setOptSimplifyLibCall(Options()->oVariables->OptSimplifyLibCall);
|
||||
setUnsafeMathOpt(Options()->oVariables->UnsafeMathOpt);
|
||||
setIsPreLinkOpt(Options()->oVariables->OptLevel);
|
||||
setIsPreLinkOpt(Options()->oVariables->OptLevel != amd::option::OPT_O0);
|
||||
setFP32RoundDivideSqrt(Options()->oVariables->FP32RoundDivideSqrt);
|
||||
setUseNative(Options()->oVariables->OptUseNative);
|
||||
setDenormsAreZero(Options()->oVariables->DenormsAreZero);
|
||||
|
||||
@@ -63,18 +63,20 @@ OptLevel::setup(aclBinary *elf, bool isGPU, uint32_t OptLevel)
|
||||
|
||||
llvm::CodeGenOpt::Level OLvl = CodeGenOpt::None;
|
||||
switch (Options()->oVariables->OptLevel) {
|
||||
case 0: // -O0
|
||||
case amd::option::OPT_O0: // -O0
|
||||
OLvl = CodeGenOpt::None;
|
||||
break;
|
||||
case 1: // -O1
|
||||
case amd::option::OPT_O1: // -O1
|
||||
OLvl = CodeGenOpt::Less;
|
||||
break;
|
||||
case 2: // -O2
|
||||
case 5: // -O5(-Os)
|
||||
case amd::option::OPT_O2: // -O2
|
||||
case amd::option::OPT_O5: // -O5
|
||||
case amd::option::OPT_OS: // -Os
|
||||
OLvl = CodeGenOpt::Default;
|
||||
break;
|
||||
case 3: // -O3
|
||||
case 4: // -O4
|
||||
case amd::option::OPT_OG: // -Og
|
||||
case amd::option::OPT_O3: // -O3
|
||||
case amd::option::OPT_O4: // -O4
|
||||
OLvl = CodeGenOpt::Aggressive;
|
||||
break;
|
||||
default:
|
||||
@@ -271,3 +273,12 @@ OsOptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
OgOptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
|
||||
{
|
||||
module_ = input;
|
||||
setup(elf, isGPU, 3);
|
||||
run(elf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -200,5 +200,19 @@ namespace amdcl
|
||||
}; // class OsOptLevel
|
||||
/*@}*/
|
||||
|
||||
class OgOptLevel : public OptLevel {
|
||||
OgOptLevel(OgOptLevel&); // DO NOT IMPLEMENT.
|
||||
OgOptLevel(); // DO NOT IMPLEMENT.
|
||||
|
||||
public:
|
||||
OgOptLevel(amd::option::Options *opts)
|
||||
: OptLevel(opts) {}
|
||||
|
||||
virtual ~OgOptLevel() {}
|
||||
|
||||
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
||||
}; // class OgOptLevel
|
||||
/*@}*/
|
||||
|
||||
}; // amdcl namespace
|
||||
#endif // _BE_OPT_LEVEL_HPP_
|
||||
|
||||
@@ -25,25 +25,29 @@ using namespace amdcl;
|
||||
using namespace llvm;
|
||||
|
||||
static OptLevel* getOptLevel(amd::option::Options* Options, bool isGPU) {
|
||||
switch(Options->oVariables->OptLevel) {
|
||||
switch(Options->oVariables->OptLevel) {
|
||||
case amd::option::OPT_O0:
|
||||
return (isGPU) ? new GPUO0OptLevel(Options) : new O0OptLevel(Options);
|
||||
return (isGPU) ? new GPUO0OptLevel(Options) : new O0OptLevel(Options);
|
||||
case amd::option::OPT_O1:
|
||||
return new O1OptLevel(Options);
|
||||
return new O1OptLevel(Options);
|
||||
default:
|
||||
assert(!"Found an invalid optimization level!");
|
||||
assert(!"Found an invalid optimization level!");
|
||||
case amd::option::OPT_O2:
|
||||
return new O2OptLevel(Options);
|
||||
return new O2OptLevel(Options);
|
||||
case amd::option::OPT_OG:
|
||||
return new OgOptLevel(Options);
|
||||
case amd::option::OPT_O3:
|
||||
return new O3OptLevel(Options);
|
||||
return new O3OptLevel(Options);
|
||||
case amd::option::OPT_O4:
|
||||
return new O4OptLevel(Options);
|
||||
return new O4OptLevel(Options);
|
||||
case amd::option::OPT_O5:
|
||||
case amd::option::OPT_OS:
|
||||
return new OsOptLevel(Options);
|
||||
}
|
||||
assert(!"Unreachable!");
|
||||
return NULL;
|
||||
return new OsOptLevel(Options);
|
||||
}
|
||||
assert(!"Unreachable!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
CPUOptimizer::preOptimizer(llvm::Module* M)
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
* OT_INT32 : int32
|
||||
* OT_UINT32 : uint32
|
||||
* OT_CSTRING : char*
|
||||
* OT_uCHAR : unsigned char
|
||||
*
|
||||
* attr: option attributes, divided in several groups:
|
||||
* OptionValue : value attribute. Use exactly one.
|
||||
@@ -118,17 +119,17 @@
|
||||
* NOPTION, no varialbe in option object for this. But we still need PP_D (as option ID)
|
||||
* All unused parameters are set to 0.
|
||||
*
|
||||
* -O[0|1|2|3|4|5]
|
||||
* OPTION(OT_UINT32, \
|
||||
* -O[0|1|2|3|4|5|s|g]
|
||||
* OPTION(OT_UCHAR, \
|
||||
* OA_RUNTIME|OVIS_INTERNAL|OVA_OPTIONAL|OA_SEPARATOR_NONE, \
|
||||
* "O", NULL, \
|
||||
* OptLevel, \
|
||||
* 3, 0, 3, NULL, \
|
||||
* "Set optimization level to <number>(0-4, 5(-Os equivalent)")
|
||||
* '3', 0, 's', NULL, \
|
||||
* "Set optimization level to <number>(0-4, 5(-Os equivalent), g")
|
||||
*
|
||||
* where sn = "O", var = "OptLevel", ideft is 3 (Which means -O will mean -O3). And code
|
||||
* can use the following for checking the option level:
|
||||
* if (localOptions.oVariables->OptLevel == 0) {
|
||||
* if (localOptions.oVariables->OptLevel == amd::option::OPT_O0) {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
@@ -549,13 +550,13 @@ OPTION(OT_CSTRING, \
|
||||
0, 0, 0, NULL, \
|
||||
"Pass comma-separated <options> to the finalizer (sc)")
|
||||
|
||||
// -O[0|1|2|3|4|5]
|
||||
OPTION(OT_UINT32, \
|
||||
// -O[0|1|2|3|4|5|s|g]
|
||||
OPTION(OT_UCHAR, \
|
||||
OA_RUNTIME|OVA_OPTIONAL|OA_SEPARATOR_NONE, \
|
||||
"O", NULL, \
|
||||
OptLevel, \
|
||||
3, 0, 5, NULL, \
|
||||
"Set optimization level to <number>(0|1|2|3|4|5(-Os equivalent))")
|
||||
'3', 0, 's', NULL, \
|
||||
"Set optimization level to <number>(0|1|2|3|4|5(-Os equivalent)|g)")
|
||||
|
||||
// -srt/--sr-threshold=<positive integer> : Scalar Replacement threshold
|
||||
OPTION(OT_UINT32, \
|
||||
|
||||
@@ -128,10 +128,10 @@ getDefault2(int OptDescTableIx, int64_t& idefault2, const char*& sdefault2)
|
||||
break;
|
||||
|
||||
case OID_OptLevel:
|
||||
idefault2 = 3;
|
||||
idefault2 = amd::option::OPT_O3;
|
||||
break;
|
||||
|
||||
case OID_OptUseNative:
|
||||
case OID_OptUseNative:
|
||||
sdefault2 = "all";
|
||||
break;
|
||||
|
||||
@@ -285,6 +285,8 @@ ShowOptionsHelp(const char* helpValue, Options& Opts)
|
||||
case OT_UINT32:
|
||||
pntVal = "<number>";
|
||||
break;
|
||||
case OT_UCHAR:
|
||||
pntVal = "<0-9 | a-z>";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -425,6 +427,10 @@ setOptionVariable (OptionDescriptor* oDesc, OptionVariables* oVars,
|
||||
OT_CSTRING_t* o = reinterpret_cast<OT_CSTRING_t*>(addr);
|
||||
*o = static_cast<OT_CSTRING_t>(SValue);
|
||||
}
|
||||
else if (OPTION_type(oDesc) == OT_UCHAR) {
|
||||
OT_UCHAR_t* o = reinterpret_cast<OT_UCHAR_t*>(addr);
|
||||
*o = static_cast<OT_UCHAR_t>(IValue);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
@@ -452,6 +458,11 @@ setOptionVariable (OptionDescriptor* oDesc, OptionVariables* srcOVars,
|
||||
OT_UINT32_t* dst = reinterpret_cast<OT_UINT32_t*>(dstAddr);
|
||||
*dst = *src;
|
||||
}
|
||||
else if (OPTION_type(oDesc) == OT_UCHAR) {
|
||||
OT_UCHAR_t* src = reinterpret_cast<OT_UCHAR_t*>(srcAddr);
|
||||
OT_UCHAR_t* dst = reinterpret_cast<OT_UCHAR_t*>(dstAddr);
|
||||
*dst = *src;
|
||||
}
|
||||
else if (OPTION_type(oDesc) == OT_CSTRING) {
|
||||
OT_CSTRING_t* src = reinterpret_cast<OT_CSTRING_t*>(srcAddr);
|
||||
OT_CSTRING_t* dst = reinterpret_cast<OT_CSTRING_t*>(dstAddr);
|
||||
@@ -670,6 +681,12 @@ processOption(int OptDescTableIx, Options& Opts, const std::string& Value,
|
||||
}
|
||||
break;
|
||||
|
||||
case OT_UCHAR:
|
||||
{
|
||||
ival = Value.at(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case OT_INT32:
|
||||
ival = ::strtol(Value.c_str(), &p, 0);
|
||||
if (*p != '\0') {
|
||||
@@ -741,6 +758,14 @@ processOption(int OptDescTableIx, Options& Opts, const std::string& Value,
|
||||
}
|
||||
break;
|
||||
|
||||
case OID_OptLevel:
|
||||
if (ival == 'g') {
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
Opts.clangOptions.push_back("-Og");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case OID_FiniteMathOnly:
|
||||
Opts.setFlag(OID_FiniteMathOnly, 1);
|
||||
tod = &OptDescTable[OID_FiniteMathOnly];
|
||||
@@ -833,7 +858,6 @@ processOption(int OptDescTableIx, Options& Opts, const std::string& Value,
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case OID_DisableAllWarnings:
|
||||
if (ival != 0) {
|
||||
Opts.clcOptions.append(" --no_warnings");
|
||||
@@ -1597,6 +1621,11 @@ bool Options::equals(const Options& other, bool ignoreClcOptions) const
|
||||
OT_CSTRING_t* o2 = reinterpret_cast<OT_CSTRING_t*>(addr2);
|
||||
if (!isCStrOptionsEqual(*o,*o2)) return false;
|
||||
}
|
||||
else if (OPTION_type(od) == OT_UCHAR) {
|
||||
OT_UCHAR_t* o = reinterpret_cast<OT_UCHAR_t*>(addr);
|
||||
OT_UCHAR_t* o2 = reinterpret_cast<OT_UCHAR_t*>(addr2);
|
||||
if (*o != *o2) return false;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ enum OptionType {
|
||||
OT_INT32,
|
||||
OT_UINT32,
|
||||
OT_CSTRING,
|
||||
OT_UCHAR,
|
||||
OT_MASK = 0x3f
|
||||
};
|
||||
|
||||
@@ -91,6 +92,7 @@ typedef bool OT_BOOL_t;
|
||||
typedef int32_t OT_INT32_t;
|
||||
typedef uint32_t OT_UINT32_t;
|
||||
typedef const char* OT_CSTRING_t;
|
||||
typedef unsigned char OT_UCHAR_t;
|
||||
|
||||
// This must be a POD
|
||||
struct OptionDescriptor {
|
||||
@@ -180,18 +182,20 @@ enum DumpFlags {
|
||||
};
|
||||
|
||||
enum OptLevelFlags {
|
||||
OPT_O0 = 0, // No optimization setting.
|
||||
OPT_O1 = 1,
|
||||
OPT_O2 = 2,
|
||||
OPT_O3 = 3,
|
||||
OPT_O4 = 4,
|
||||
OPT_OS = 5,
|
||||
OPT_Error = 6, // Invalid optimization set
|
||||
OPT_O0 = 48, // No optimization setting.
|
||||
OPT_O1 = 49,
|
||||
OPT_O2 = 50,
|
||||
OPT_O3 = 51,
|
||||
OPT_O4 = 52,
|
||||
OPT_O5 = 53,
|
||||
OPT_OG = 103, // g ASCII
|
||||
OPT_OS = 115, // s ASCII
|
||||
OPT_Error = 116, // Invalid optimization set
|
||||
/** Canary Value that guards against enum changes
|
||||
* @warning This value cannot be changed without updating the appropriate
|
||||
* tests and should NEVER be decreased.
|
||||
*/
|
||||
optLast = 7
|
||||
optLast = 117
|
||||
};
|
||||
|
||||
class Options {
|
||||
|
||||
Reference in New Issue
Block a user