2c0b212d96
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
219 строки
4.9 KiB
C++
219 строки
4.9 KiB
C++
//
|
|
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
#ifndef _BE_OPT_LEVEL_HPP_
|
|
#define _BE_OPT_LEVEL_HPP_
|
|
#include "top.hpp"
|
|
#include "utils/options.hpp"
|
|
#include "aclTypes.h"
|
|
|
|
#if defined DEBUG
|
|
#undef DEBUG
|
|
#endif
|
|
|
|
#include "llvm/Analysis/Passes.h"
|
|
#include "llvm/IR/LegacyPassManager.h"
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
namespace llvm {
|
|
class Module;
|
|
|
|
}; // llvm namespace
|
|
|
|
#if defined(LEGACY_COMPLIB)
|
|
#define LLVM_LEGACY_NAMESPACE llvm
|
|
#else
|
|
#define LLVM_LEGACY_NAMESPACE llvm::legacy
|
|
#endif
|
|
|
|
namespace amdcl
|
|
{
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::OptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class OptLevel {
|
|
OptLevel(OptLevel&); // DO NOT IMPLEMENT.
|
|
OptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
OptLevel(amd::option::Options *OptionsObj)
|
|
: opts_(OptionsObj), TM(nullptr) {}
|
|
|
|
virtual ~OptLevel() { delete TM; }
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU) = 0;
|
|
protected:
|
|
void setup(aclBinary *elf, bool isGPU, uint32_t OptLevel);
|
|
void run(aclBinary *elf);
|
|
LLVM_LEGACY_NAMESPACE::PassManager& Passes() { return passes_; }
|
|
LLVM_LEGACY_NAMESPACE::FunctionPassManager& FPasses() { return (*fpasses_); }
|
|
amd::option::Options* Options() { return opts_; }
|
|
llvm::Module* module_;
|
|
private:
|
|
LLVM_LEGACY_NAMESPACE::FunctionPassManager *fpasses_;
|
|
LLVM_LEGACY_NAMESPACE::PassManager passes_;
|
|
amd::option::Options *opts_;
|
|
llvm::TargetMachine* TM;
|
|
}; // class OptLevel
|
|
/*@}*/
|
|
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::O0OptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class O0OptLevel : public OptLevel {
|
|
O0OptLevel(O0OptLevel&); // DO NOT IMPLEMENT.
|
|
O0OptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
O0OptLevel(amd::option::Options *opts)
|
|
: OptLevel(opts) {}
|
|
|
|
virtual ~O0OptLevel() {}
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
|
}; // class O0OptLevel
|
|
/*@}*/
|
|
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::GPUO0OptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class GPUO0OptLevel : public O0OptLevel {
|
|
GPUO0OptLevel(GPUO0OptLevel&); // DO NOT IMPLEMENT.
|
|
GPUO0OptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
GPUO0OptLevel(amd::option::Options *opts)
|
|
: O0OptLevel(opts) {}
|
|
|
|
virtual ~GPUO0OptLevel() {}
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
|
}; // class O0OptLevel
|
|
/*@}*/
|
|
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::O1OptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class O1OptLevel : public OptLevel {
|
|
O1OptLevel(O1OptLevel&); // DO NOT IMPLEMENT.
|
|
O1OptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
O1OptLevel(amd::option::Options *opts)
|
|
: OptLevel(opts) {}
|
|
|
|
virtual ~O1OptLevel() {}
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
|
}; // class O1OptLevel
|
|
/*@}*/
|
|
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::O2OptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class O2OptLevel : public OptLevel {
|
|
O2OptLevel(O2OptLevel&); // DO NOT IMPLEMENT.
|
|
O2OptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
O2OptLevel(amd::option::Options *opts)
|
|
: OptLevel(opts) {}
|
|
|
|
virtual ~O2OptLevel() {}
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
|
}; // class O2OptLevel
|
|
/*@}*/
|
|
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::O3OptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class O3OptLevel : public OptLevel {
|
|
O3OptLevel(O3OptLevel&); // DO NOT IMPLEMENT.
|
|
O3OptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
O3OptLevel(amd::option::Options *opts)
|
|
: OptLevel(opts) {}
|
|
|
|
virtual ~O3OptLevel() {}
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
|
}; // class O3OptLevel
|
|
/*@}*/
|
|
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::O4OptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class O4OptLevel : public OptLevel {
|
|
O4OptLevel(O4OptLevel&); // DO NOT IMPLEMENT.
|
|
O4OptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
O4OptLevel(amd::option::Options *opts)
|
|
: OptLevel(opts) {}
|
|
|
|
virtual ~O4OptLevel() {}
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
|
}; // class O4OptLevel
|
|
/*@}*/
|
|
|
|
/*! \addtogroup Compiler Library
|
|
*
|
|
* \copydoc amdcl::OsOptLevel
|
|
*
|
|
* @{
|
|
*/
|
|
class OsOptLevel : public OptLevel {
|
|
OsOptLevel(OsOptLevel&); // DO NOT IMPLEMENT.
|
|
OsOptLevel(); // DO NOT IMPLEMENT.
|
|
|
|
public:
|
|
OsOptLevel(amd::option::Options *opts)
|
|
: OptLevel(opts) {}
|
|
|
|
virtual ~OsOptLevel() {}
|
|
|
|
virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU);
|
|
}; // 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_
|