2014-03-06 03:42:23 +00:00
|
|
|
//===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-13 16:57:49 +00:00
|
|
|
|
2014-03-06 03:42:23 +00:00
|
|
|
#ifndef LLVM_LINKER_LINKER_H
|
|
|
|
#define LLVM_LINKER_LINKER_H
|
2001-10-13 16:57:49 +00:00
|
|
|
|
2013-05-04 05:05:18 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2012-03-26 06:58:25 +00:00
|
|
|
#include <string>
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-06-27 18:19:56 +00:00
|
|
|
class Comdat;
|
|
|
|
class GlobalValue;
|
2001-10-13 16:57:49 +00:00
|
|
|
class Module;
|
2012-03-26 06:58:25 +00:00
|
|
|
class StringRef;
|
2013-05-04 05:05:18 +00:00
|
|
|
class StructType;
|
2001-10-28 21:23:44 +00:00
|
|
|
|
2013-05-04 03:06:50 +00:00
|
|
|
/// This class provides the core functionality of linking in LLVM. It keeps a
|
|
|
|
/// pointer to the merged module so far. It doesn't take ownership of the
|
|
|
|
/// module since it is assumed that the user of this class will want to do
|
|
|
|
/// something with it after the linking.
|
2004-12-13 02:58:05 +00:00
|
|
|
class Linker {
|
|
|
|
public:
|
2011-10-11 00:24:54 +00:00
|
|
|
enum LinkerMode {
|
|
|
|
DestroySource = 0, // Allow source module to be destroyed.
|
|
|
|
PreserveSource = 1 // Preserve the source module.
|
|
|
|
};
|
2013-03-08 22:29:44 +00:00
|
|
|
|
2014-02-20 22:19:24 +00:00
|
|
|
Linker(Module *M, bool SuppressWarnings=false);
|
2004-12-13 02:58:05 +00:00
|
|
|
~Linker();
|
2013-10-16 08:59:57 +00:00
|
|
|
|
2013-05-04 03:06:50 +00:00
|
|
|
Module *getModule() const { return Composite; }
|
2013-10-16 08:59:57 +00:00
|
|
|
void deleteModule();
|
2013-05-04 03:06:50 +00:00
|
|
|
|
|
|
|
/// \brief Link \p Src into the composite. The source is destroyed if
|
|
|
|
/// \p Mode is DestroySource and preserved if it is PreserveSource.
|
|
|
|
/// If \p ErrorMsg is not null, information about any error is written
|
|
|
|
/// to it.
|
|
|
|
/// Returns true on error.
|
|
|
|
bool linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg);
|
|
|
|
bool linkInModule(Module *Src, std::string *ErrorMsg) {
|
|
|
|
return linkInModule(Src, Linker::DestroySource, ErrorMsg);
|
2006-11-11 19:59:25 +00:00
|
|
|
}
|
2004-12-13 02:58:05 +00:00
|
|
|
|
2013-05-04 03:06:50 +00:00
|
|
|
static bool LinkModules(Module *Dest, Module *Src, unsigned Mode,
|
|
|
|
std::string *ErrorMsg);
|
2004-12-13 02:58:05 +00:00
|
|
|
|
|
|
|
private:
|
2013-05-04 03:06:50 +00:00
|
|
|
Module *Composite;
|
2013-05-04 05:05:18 +00:00
|
|
|
SmallPtrSet<StructType*, 32> IdentifiedStructTypes;
|
2014-02-20 22:19:24 +00:00
|
|
|
|
|
|
|
bool SuppressWarnings;
|
2004-12-13 02:58:05 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-10-13 16:57:49 +00:00
|
|
|
#endif
|