Files
rocm-systems/rocclr/compiler/lib/backends/common/linker.hpp
T
foreman 2e1fa69ea0 P4 to Git Change 1132376 by atimofee@atimofee-hsa on 2015/03/19 08:10:42
ECR #333753 - HSA HLC: off-/online linkers code refactoring to enable __option_mask()
	                    function body generation on the offline path.

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/compiler_stage.hpp#10 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/linker.cpp#120 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/linker.hpp#15 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/AMDLLVMContextHook.h#24 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/AMDPrelinkOpt.h#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/AMDResolveLinker.h#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/AMDUtils.h#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Linker/AMDPrelinkOpt.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Linker/AMDResolveLinker.cpp#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Transforms/Utils/AMDUtils.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/tools/llvm-link/llvm-link.cpp#51 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/include/llvm/AMDLLVMContextHook.h#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/include/llvm/AMDPrelinkOpt.h#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/include/llvm/AMDResolveLinker.h#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/include/llvm/AMDUtils.h#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/lib/Linker/AMDPrelinkOpt.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/lib/Linker/AMDResolveLinker.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/lib/Transforms/Utils/AMDUtils.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm32/tools/llvm-link/llvm-link.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/tests/hsa/src/ocl/features/option_mask/option_mask.cl#1 add
... //depot/stg/opencl/drivers/opencl/tests/hsa/src/ocl/features/option_mask/option_mask.lua#1 add
... //depot/stg/opencl/drivers/opencl/tests/hsa/tlst/ocl_features.tlst#15 edit
2015-03-19 08:16:21 -04:00

95 lines
2.6 KiB
C++

//
// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
//
#ifndef _BE_LINKER_HPP_
#define _BE_LINKER_HPP_
#include "compiler_stage.hpp"
#include "aclTypes.h"
#include <string>
#include <map>
namespace llvm {
class Module;
class Value;
}; // namespace llvm
namespace amdcl
{
/*! \addtogroup Compiler Library
*
* \copydoc amdcl::Linker
*
* @{
*/
class Linker : public LLVMCompilerStage{
Linker(Linker&); // DO NOT IMPLEMENT.
Linker(); // DO NOT IMPLEMENT.
public:
Linker(aclCompiler *cl, aclBinary* elf, aclLogFunction log)
: LLVMCompilerStage(cl, elf, log) {}
virtual ~Linker() {}
/*! Function that takes as in a llvm::Module that contains LLVM-IR
* binary and links in a vector of libraries.
* Returns 0 on success, non-zero on failure.
*/
virtual int link(llvm::Module* input, std::vector<llvm::Module*> &libs) = 0;
}; // class Linker
/*@}*/
/*! \addtogroup Compiler Library
*
* \copydoc amdcl::OCLLinker
*
* @{
* \brief Linker that is unique to OpenCL.
*/
class OCLLinker : public Linker {
public:
OCLLinker(aclCompiler* cl, aclBinary* bin, aclLogFunction log)
: Linker(cl, bin, log) {}
virtual ~OCLLinker() {
for (unsigned j = 0, i = (unsigned)mathLibs_.size(); j < i; ++j) {
if (mathLibs_[j]) {
delete mathLibs_[j];
}
}
};
void setPreLinkOpt(bool Val) { hookup_.amdoptions.IsPreLinkOpt = Val; }
void setUnrollScratchThreshold(uint32_t ust) { hookup_.amdoptions.UnrollScratchThreshold = ust; }
bool getWholeProgram() { return hookup_.amdoptions.WholeProgram; }
uint32_t getUnrollScratchThreshold() { return hookup_.amdoptions.UnrollScratchThreshold; }
/*! Function that takes as input a std::string which
* contains LLVM-IR binary and links in a vector of libraries.
* This version also links in the OpenCL math libraries along with
* the list of libraries that are passed in.
*/
int link(llvm::Module* input, std::vector<llvm::Module*> &libs);
protected:
void createASICIDFunctions(llvm::Module* module);
bool linkLLVMModules(std::vector<llvm::Module*> &libs);
bool linkWithModule(llvm::Module* Dst, llvm::Module* Src,
std::map<const llvm::Value*, bool> *ModuleRefMap);
private:
static void fixupOldTriple(llvm::Module* module);
/*! Vector of modules that stores the math libraries.
*/
std::vector<llvm::Module*> mathLibs_;
}; // class OCLLinker
/*@}*/
}; // namespace amdcl
#endif // _BE_LINKER_HPP_