Move IRBuilder type definition to common file.

- No functionality change.

llvm-svn: 58546
This commit is contained in:
Daniel Dunbar 2008-11-01 01:53:16 +00:00
parent ce149def9d
commit cb4638599c
10 changed files with 61 additions and 45 deletions

View File

@ -0,0 +1,21 @@
//===-- 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.
//
//===----------------------------------------------------------------------===//
#ifndef CLANG_CODEGEN_CGBUILDER_H
#define CLANG_CODEGEN_CGBUILDER_H
#include "llvm/Support/IRBuilder.h"
namespace clang {
namespace CodeGen {
typedef llvm::IRBuilder<> CGBuilderTy;
} // end namespace CodeGen
} // end namespace clang
#endif

View File

@ -27,7 +27,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Target/TargetMachine.h"
using namespace clang;
using namespace clang::CodeGen;
@ -603,7 +602,7 @@ CGDebugInfo::getOrCreateType(QualType type, llvm::CompileUnitDesc *Unit)
void CGDebugInfo::EmitFunctionStart(const char *Name,
QualType ReturnType,
llvm::Function *Fn,
llvm::IRBuilder<> &Builder)
CGBuilderTy &Builder)
{
// Create subprogram descriptor.
Subprogram = new llvm::SubprogramDesc();
@ -647,7 +646,7 @@ void CGDebugInfo::EmitFunctionStart(const char *Name,
void
CGDebugInfo::EmitStopPoint(llvm::Function *Fn, llvm::IRBuilder<> &Builder)
CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder)
{
if (CurLoc.isInvalid() || CurLoc.isMacroID()) return;
@ -682,7 +681,7 @@ CGDebugInfo::EmitStopPoint(llvm::Function *Fn, llvm::IRBuilder<> &Builder)
/// EmitRegionStart- Constructs the debug code for entering a declarative
/// region - "llvm.dbg.region.start.".
void CGDebugInfo::EmitRegionStart(llvm::Function *Fn,
llvm::IRBuilder<> &Builder)
CGBuilderTy &Builder)
{
llvm::BlockDesc *Block = new llvm::BlockDesc();
if (!RegionStack.empty())
@ -700,7 +699,7 @@ void CGDebugInfo::EmitRegionStart(llvm::Function *Fn,
/// EmitRegionEnd - Constructs the debug code for exiting a declarative
/// region - "llvm.dbg.region.end."
void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, llvm::IRBuilder<> &Builder)
void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder)
{
assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
@ -722,7 +721,7 @@ void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, llvm::IRBuilder<> &Builder)
/// EmitDeclare - Emit local variable declaration debug info.
void CGDebugInfo::EmitDeclare(const VarDecl *decl, unsigned Tag,
llvm::Value *AI,
llvm::IRBuilder<> &Builder)
CGBuilderTy &Builder)
{
assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");

View File

@ -16,10 +16,10 @@
#include "clang/AST/Type.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/Support/IRBuilder.h"
#include <map>
#include <vector>
#include "CGBuilder.h"
namespace llvm {
class Function;
@ -41,6 +41,7 @@ namespace llvm {
namespace clang {
class FunctionDecl;
class VarDecl;
namespace CodeGen {
class CodeGenModule;
@ -54,8 +55,6 @@ private:
SourceLocation CurLoc;
SourceLocation PrevLoc;
typedef llvm::IRBuilder<> BuilderType;
/// CompileUnitCache - Cache of previously constructed CompileUnits.
std::map<const FileEntry*, llvm::CompileUnitDesc *> CompileUnitCache;
@ -109,24 +108,24 @@ public:
/// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of
/// source line.
void EmitStopPoint(llvm::Function *Fn, BuilderType &Builder);
void EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder);
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
/// start of a new function.
void EmitFunctionStart(const char *Name, QualType ReturnType,
llvm::Function *Fn, BuilderType &Builder);
llvm::Function *Fn, CGBuilderTy &Builder);
/// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
/// of a new block.
void EmitRegionStart(llvm::Function *Fn, BuilderType &Builder);
void EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder);
/// EmitRegionEnd - Emit call to llvm.dbg.region.end to indicate end of a
/// block.
void EmitRegionEnd(llvm::Function *Fn, BuilderType &Builder);
void EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder);
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
BuilderType &Builder);
CGBuilderTy &Builder);
/// EmitGlobalVariable - Emit information about a global variable.
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *decl);

View File

@ -30,7 +30,7 @@ using namespace CodeGen;
namespace {
class VISIBILITY_HIDDEN AggExprEmitter : public StmtVisitor<AggExprEmitter> {
CodeGenFunction &CGF;
llvm::IRBuilder<> &Builder;
CGBuilderTy &Builder;
llvm::Value *DestPtr;
bool VolatileDest;
public:

View File

@ -32,7 +32,7 @@ namespace {
class VISIBILITY_HIDDEN ComplexExprEmitter
: public StmtVisitor<ComplexExprEmitter, ComplexPairTy> {
CodeGenFunction &CGF;
llvm::IRBuilder<> &Builder;
CGBuilderTy &Builder;
public:
ComplexExprEmitter(CodeGenFunction &cgf) : CGF(cgf), Builder(CGF.Builder) {
}

View File

@ -43,7 +43,7 @@ namespace {
class VISIBILITY_HIDDEN ScalarExprEmitter
: public StmtVisitor<ScalarExprEmitter, Value*> {
CodeGenFunction &CGF;
llvm::IRBuilder<> &Builder;
CGBuilderTy &Builder;
public:

View File

@ -24,7 +24,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Target/TargetData.h"
#include <map>
using namespace clang;
@ -110,14 +109,14 @@ public:
llvm::Value *Receiver,
bool IsClassMessage,
const CallArgList &CallArgs);
virtual llvm::Value *GetClass(llvm::IRBuilder<> &Builder,
virtual llvm::Value *GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *OID);
virtual llvm::Value *GetSelector(llvm::IRBuilder<> &Builder, Selector Sel);
virtual llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel);
virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD);
virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD);
virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
virtual llvm::Value *GenerateProtocolRef(llvm::IRBuilder<> &Builder,
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD);
virtual void GenerateProtocol(const ObjCProtocolDecl *PD);
virtual llvm::Function *ModuleInitFunction();
@ -182,7 +181,7 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm)
}
// This has to perform the lookup every time, since posing and related
// techniques can modify the name -> class mapping.
llvm::Value *CGObjCGNU::GetClass(llvm::IRBuilder<> &Builder,
llvm::Value *CGObjCGNU::GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *OID) {
llvm::Value *ClassName = CGM.GetAddrOfConstantCString(OID->getName());
ClassName = Builder.CreateStructGEP(ClassName, 0);
@ -194,7 +193,7 @@ llvm::Value *CGObjCGNU::GetClass(llvm::IRBuilder<> &Builder,
}
/// GetSelector - Return the pointer to the unique'd string for this selector.
llvm::Value *CGObjCGNU::GetSelector(llvm::IRBuilder<> &Builder, Selector Sel) {
llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, Selector Sel) {
// FIXME: uniquing on the string is wasteful, unique on Sel instead!
llvm::GlobalAlias *&US = UntypedSelectors[Sel.getName()];
if (US == 0)
@ -553,7 +552,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList(
return MakeGlobal(ProtocolListTy, Elements, ".objc_protocol_list");
}
llvm::Value *CGObjCGNU::GenerateProtocolRef(llvm::IRBuilder<> &Builder,
llvm::Value *CGObjCGNU::GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD) {
return ExistingProtocols[PD->getName()];
}
@ -911,7 +910,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
llvm::GlobalValue::InternalLinkage, ".objc_load_function",
&TheModule);
llvm::BasicBlock *EntryBB = llvm::BasicBlock::Create("entry", LoadFunction);
llvm::IRBuilder<> Builder;
CGBuilderTy Builder;
Builder.SetInsertPoint(EntryBB);
llvm::Value *Register = TheModule.getOrInsertFunction("__objc_exec_class",
llvm::Type::VoidTy, llvm::PointerType::getUnqual(ModuleTy), NULL);

View File

@ -22,7 +22,6 @@
#include "llvm/Module.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Target/TargetData.h"
#include <sstream>
@ -257,7 +256,7 @@ private:
/// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy,
/// for the given class.
llvm::Value *EmitClassRef(llvm::IRBuilder<> &Builder,
llvm::Value *EmitClassRef(CGBuilderTy &Builder,
const ObjCInterfaceDecl *ID);
CodeGen::RValue EmitMessageSend(CodeGen::CodeGenFunction &CGF,
@ -349,7 +348,7 @@ private:
/// EmitSelector - Return a Value*, of type ObjCTypes.SelectorPtrTy,
/// for the given selector.
llvm::Value *EmitSelector(llvm::IRBuilder<> &Builder, Selector Sel);
llvm::Value *EmitSelector(CGBuilderTy &Builder, Selector Sel);
/// GetProtocolRef - Return a reference to the internal protocol
/// description, creating an empty one if it has not been
@ -406,10 +405,10 @@ public:
bool IsClassMessage,
const CallArgList &CallArgs);
virtual llvm::Value *GetClass(llvm::IRBuilder<> &Builder,
virtual llvm::Value *GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *ID);
virtual llvm::Value *GetSelector(llvm::IRBuilder<> &Builder, Selector Sel);
virtual llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel);
virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD);
@ -417,7 +416,7 @@ public:
virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
virtual llvm::Value *GenerateProtocolRef(llvm::IRBuilder<> &Builder,
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD);
virtual void GenerateProtocol(const ObjCProtocolDecl *PD);
@ -464,13 +463,13 @@ CGObjCMac::CGObjCMac(CodeGen::CodeGenModule &cgm)
/// GetClass - Return a reference to the class for the given interface
/// decl.
llvm::Value *CGObjCMac::GetClass(llvm::IRBuilder<> &Builder,
llvm::Value *CGObjCMac::GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *ID) {
return EmitClassRef(Builder, ID);
}
/// GetSelector - Return the pointer to the unique'd string for this selector.
llvm::Value *CGObjCMac::GetSelector(llvm::IRBuilder<> &Builder, Selector Sel) {
llvm::Value *CGObjCMac::GetSelector(CGBuilderTy &Builder, Selector Sel) {
return EmitSelector(Builder, Sel);
}
@ -577,7 +576,7 @@ CodeGen::RValue CGObjCMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
return CGF.EmitCall(Fn, ResultType, ActualArgs);
}
llvm::Value *CGObjCMac::GenerateProtocolRef(llvm::IRBuilder<> &Builder,
llvm::Value *CGObjCMac::GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD) {
// FIXME: I don't understand why gcc generates this, or where it is
// resolved. Investigate. Its also wasteful to look this up over and
@ -1873,7 +1872,7 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() {
return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.SymtabPtrTy);
}
llvm::Value *CGObjCMac::EmitClassRef(llvm::IRBuilder<> &Builder,
llvm::Value *CGObjCMac::EmitClassRef(CGBuilderTy &Builder,
const ObjCInterfaceDecl *ID) {
LazySymbols.insert(ID->getIdentifier());
@ -1895,7 +1894,7 @@ llvm::Value *CGObjCMac::EmitClassRef(llvm::IRBuilder<> &Builder,
return Builder.CreateLoad(Entry, false, "tmp");
}
llvm::Value *CGObjCMac::EmitSelector(llvm::IRBuilder<> &Builder, Selector Sel) {
llvm::Value *CGObjCMac::EmitSelector(CGBuilderTy &Builder, Selector Sel) {
llvm::GlobalVariable *&Entry = SelectorReferences[Sel];
if (!Entry) {

View File

@ -17,11 +17,11 @@
#define CLANG_CODEGEN_OBCJRUNTIME_H
#include "clang/Basic/IdentifierTable.h" // Selector
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/IRBuilder.h"
#include <string>
#include "CGValue.h"
#include "CGBuilder.h"
#include "CGCall.h"
#include "CGValue.h"
namespace llvm {
class Constant;
@ -54,7 +54,6 @@ namespace CodeGen {
/// Implements runtime-specific code generation functions.
class CGObjCRuntime {
typedef llvm::IRBuilder<> BuilderType;
public:
virtual ~CGObjCRuntime();
@ -66,7 +65,7 @@ public:
/// Get a selector for the specified name and type values. The
/// return value should have the LLVM type for pointer-to
/// ASTContext::getObjCSelType().
virtual llvm::Value *GetSelector(BuilderType &Builder,
virtual llvm::Value *GetSelector(CGBuilderTy &Builder,
Selector Sel) = 0;
/// Generate a constant string object.
@ -102,7 +101,7 @@ public:
/// Emit the code to return the named protocol as an object, as in a
/// @protocol expression.
virtual llvm::Value *GenerateProtocolRef(llvm::IRBuilder<true> &Builder,
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *OPD) = 0;
/// Generate the named protocol. Protocols contain method metadata but no
@ -126,7 +125,7 @@ public:
/// GetClass - Return a reference to the class for the given
/// interface decl.
virtual llvm::Value *GetClass(BuilderType &Builder,
virtual llvm::Value *GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *OID) = 0;
/// EnumerationMutationFunction - Return the function that's called by the

View File

@ -17,7 +17,6 @@
#include "clang/AST/Type.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/IRBuilder.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
@ -25,6 +24,7 @@
#include <vector>
#include <map>
#include "CGBuilder.h"
#include "CGCall.h"
#include "CGValue.h"
@ -52,7 +52,7 @@ namespace CodeGen {
class CodeGenModule;
class CodeGenTypes;
class CGRecordLayout;
/// CodeGenFunction - This class organizes the per-function state that is used
/// while generating LLVM code.
class CodeGenFunction {
@ -61,7 +61,7 @@ public:
TargetInfo &Target;
typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
llvm::IRBuilder<> Builder;
CGBuilderTy Builder;
// Holds the Decl for the current function or method
const Decl *CurFuncDecl;