Files
rocm-systems/rocclr/compiler/lib/backends/common/linker.hpp
T
foreman 5901528bb0 P4 to Git Change 1271561 by smekhano@stas-rampitec-hsa on 2016/05/20 13:15:00
SWDEV-85602 - Complib: switch off some legacy code
	Testing: smoke, precheckin
	Reviewed by Evgeny Mankov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/linker.cpp#143 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/linker.hpp#16 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/linker/include/AMDResolveLinker.h#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/linker/lib/AMDResolveLinker.cpp#3 edit
2016-05-20 13:32:27 -04:00

94 baris
2.5 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:
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_