2008-11-01 09:53:16 +08:00
|
|
|
//===-- CGBuilder.h - Choose IRBuilder implementation ----------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:25:19 +08:00
|
|
|
#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
|
|
|
|
#define LLVM_CLANG_LIB_CODEGEN_CGBUILDER_H
|
2008-11-01 09:53:16 +08:00
|
|
|
|
2013-01-02 19:45:17 +08:00
|
|
|
#include "llvm/IR/IRBuilder.h"
|
2008-11-01 09:53:16 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace CodeGen {
|
2010-07-03 17:25:20 +08:00
|
|
|
|
2014-05-22 16:54:05 +08:00
|
|
|
class CodeGenFunction;
|
|
|
|
|
|
|
|
/// \brief This is an IRBuilder insertion helper that forwards to
|
2014-09-11 00:59:01 +08:00
|
|
|
/// CodeGenFunction::InsertHelper, which adds necessary metadata to
|
2014-05-22 16:54:05 +08:00
|
|
|
/// instructions.
|
|
|
|
template <bool PreserveNames>
|
|
|
|
class CGBuilderInserter
|
|
|
|
: protected llvm::IRBuilderDefaultInserter<PreserveNames> {
|
|
|
|
public:
|
|
|
|
CGBuilderInserter() : CGF(nullptr) {}
|
|
|
|
explicit CGBuilderInserter(CodeGenFunction *CGF) : CGF(CGF) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// \brief This forwards to CodeGenFunction::InsertHelper.
|
|
|
|
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name,
|
|
|
|
llvm::BasicBlock *BB,
|
|
|
|
llvm::BasicBlock::iterator InsertPt) const;
|
|
|
|
private:
|
2015-02-16 06:54:08 +08:00
|
|
|
void operator=(const CGBuilderInserter &) = delete;
|
2014-05-22 16:54:05 +08:00
|
|
|
|
|
|
|
CodeGenFunction *CGF;
|
|
|
|
};
|
|
|
|
|
2010-07-03 17:25:20 +08:00
|
|
|
// Don't preserve names on values in an optimized build.
|
2008-11-12 08:01:12 +08:00
|
|
|
#ifdef NDEBUG
|
2014-05-22 16:54:05 +08:00
|
|
|
#define PreserveNames false
|
2008-11-12 08:01:12 +08:00
|
|
|
#else
|
2014-05-22 16:54:05 +08:00
|
|
|
#define PreserveNames true
|
2008-11-12 08:01:12 +08:00
|
|
|
#endif
|
2014-05-22 16:54:05 +08:00
|
|
|
typedef CGBuilderInserter<PreserveNames> CGBuilderInserterTy;
|
|
|
|
typedef llvm::IRBuilder<PreserveNames, llvm::ConstantFolder,
|
|
|
|
CGBuilderInserterTy> CGBuilderTy;
|
|
|
|
#undef PreserveNames
|
2010-07-03 17:25:20 +08:00
|
|
|
|
2008-11-01 09:53:16 +08:00
|
|
|
} // end namespace CodeGen
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|