comma::CodeGen Class Reference

#include <CodeGen.h>

Inheritance diagram for comma::CodeGen:
Inheritance graph
[legend]
Collaboration diagram for comma::CodeGen:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~CodeGen ()
CommaRTgetRuntime () const
 Returns the interface to the runtime system.
llvm::Module * getModule ()
 Returns the module we are generating code for.
llvm::Constant * getModuleName ()
 Returns an i8* pointing the the name of this module.
const llvm::TargetData & getTargetData () const
 Returns the llvm::TargetData used to generate code.
AstResourcegetAstResource () const
 Returns the AstResource used to generate new AST nodes.
llvm::LLVMContext & getLLVMContext () const
 Returns the LLVMContext associated with this code generator.
bool extendWorklist (DomainInstanceDecl *instace)
 Inserts the given instance into the work list.
InstanceInfolookupInstanceInfo (const DomainInstanceDecl *instance) const
InstanceInfogetInstanceInfo (const DomainInstanceDecl *instance) const
SRInfogetSRInfo (DomainInstanceDecl *instance, SubroutineDecl *srDecl)
 Returns the SRInfo object associated with srDecl.
const DependencySetgetDependencySet (const Domoid *domoid)
 FIXME: This method needs to be encapsulated in a seperate structure.
bool insertGlobal (const std::string &linkName, llvm::GlobalValue *GV)
 Adds a mapping between the given link name and an LLVM GlobalValue into the global table.
llvm::GlobalValue * lookupGlobal (const std::string &linkName) const
 Returns an llvm value for a previously declared decl with the given link (mangled) name, or null if no such declaration exists.
llvm::GlobalValue * lookupCapsuleInfo (const Domoid *domoid) const
 Returns an llvm value representing the static compile time info representing a previously declared capsule, or null if no such information is present.
llvm::GlobalVariable * emitInternString (const llvm::StringRef &elems, bool addNull=true, bool isConstant=true, const std::string &name="")
 Emits a string with internal linkage, returning the global variable for the associated data. If addNull is true, emit as a null terminated string.
llvm::BasicBlock * makeBasicBlock (const std::string &name="", llvm::Function *parent=0, llvm::BasicBlock *insertBefore=0) const
 Returns an llvm basic block.
llvm::GlobalVariable * makeExternGlobal (llvm::Constant *init, bool isConstant=false, const std::string &name="")
 Returns a global variable with external linkage embedded in the current module.
llvm::GlobalVariable * makeInternGlobal (llvm::Constant *init, bool isConstant=false, const std::string &name="")
 Returns a global variable with internal linkage embedded in the current module.
llvm::Function * makeFunction (const llvm::FunctionType *Ty, const std::string &name="")
 Creates a function with the given name and type. The linkage type is external.
llvm::Function * makeFunction (const DomainInstanceDecl *instance, const SubroutineDecl *srDecl, CodeGenTypes &CGT)
 Creates a function corresponding to the given Comma subroutine declaration.
llvm::Function * makeInternFunction (const llvm::FunctionType *Ty, const std::string &name="")
 Creates a function with the given name and type. The linkage type is internal.
llvm::Function * getLLVMIntrinsic (llvm::Intrinsic::ID id) const
llvm::Function * getMemcpy64 () const
 Returns a function declaration for the llvm.memcpy.i64 intrinsic.
llvm::Function * getMemcpy32 () const
 Returns a function declaration for the llvm.memcpy.i32 intrinsic.
llvm::Function * getMemset32 () const
 Returns a function declaration for the llvm.memset.i32 intrinsic.
const llvm::OpaqueType * getOpaqueTy () const
 Returns an llvm "opaque" type.
const llvm::PointerType * getInt8PtrTy () const
 Returns the llvm type i8*.
const llvm::Type * getVoidTy () const
 Returns the llvm type "void".
const llvm::IntegerType * getInt1Ty () const
 Returns the llvm type "i1".
const llvm::IntegerType * getInt8Ty () const
 Returns the llvm type "i8".
const llvm::IntegerType * getInt16Ty () const
 Returns the llvm type "i16".
const llvm::IntegerType * getInt32Ty () const
 Returns the llvm type "i32".
const llvm::IntegerType * getInt64Ty () const
 Returns the llvm type "i64".
const llvm::IntegerType * getIntPtrTy () const
 Returns a integer type capable of representing a pointer.
llvm::Constant * getNullPointer (const llvm::PointerType *Ty) const
 Returns a null pointer constant of the specified type.
llvm::PointerType * getPointerType (const llvm::Type *Ty) const
 Returns a pointer-to the given type.
llvm::ConstantInt * getConstantInt (const llvm::IntegerType *type, uint64_t value) const
 Returns a constant integer.
llvm::ConstantInt * getConstantInt (const llvm::IntegerType *type, const llvm::APInt &value) const
llvm::Constant * getConstantArray (const llvm::Type *elementType, std::vector< llvm::Constant * > &elems) const
 Returns a constant array consiting of the given elements, each of which must be of the supplied type.
llvm::Constant * getPointerCast (llvm::Constant *constant, const llvm::PointerType *Ty) const
 Casts the given constant expression into the given pointer type.
llvm::StructType * getStructTy (const std::vector< const llvm::Type * > &elts, bool isPacked=false) const
 Returns an llvm structure type.
llvm::ArrayType * getVLArrayTy (const llvm::Type *componentTy) const
 Returns a variable length array type.
Accessors to the llvm exception intrinsics.



llvm::Function * getEHExceptionIntrinsic () const
llvm::Function * getEHSelectorIntrinsic () const
llvm::Function * getEHTypeidIntrinsic () const
Location helpers.

The following methods provide convenience functions for generating LLVM values corresponding to line and column information. All lines and columns are represented as unsigned i32's.



SourceLocation getSourceLocation (Location loc)
llvm::ConstantInt * getSourceLine (Location loc)
 Returns the line of the given location as an i32.
llvm::ConstantInt * getSourceColumn (Location loc)
 Returns the column of the given location is an i32.

Friends

class Generator

Detailed Description

Definition at line 30 of file CodeGen.h.


Constructor & Destructor Documentation

CodeGen::~CodeGen (  ) 

Definition at line 34 of file CodeGen.cpp.


Member Function Documentation

llvm::GlobalVariable * CodeGen::emitInternString ( const llvm::StringRef &  elems,
bool  addNull = true,
bool  isConstant = true,
const std::string &  name = "" 
)

Emits a string with internal linkage, returning the global variable for the associated data. If addNull is true, emit as a null terminated string.

Definition at line 278 of file CodeGen.cpp.

bool CodeGen::extendWorklist ( DomainInstanceDecl instace  ) 

Inserts the given instance into the work list.

Returns:
true if the instance was not already present in the worklist and false otherwise.

The given instance must not be dependent (meaning that DomainInstanceDecl::isDependent must return false).

When an instance is inserted into the worklist, a few actions take place. First, the instance is schedualed for codegen, meaning that specializations of that instances subroutines will be emmited into the current module. Second, forward declarations are created for each of the instances subroutines. These declarations are accessible thru the lookupGlobal method using the appropriately mangled name.

Definition at line 231 of file CodeGen.cpp.

AstResource& comma::CodeGen::getAstResource (  )  const [inline]

Returns the AstResource used to generate new AST nodes.

Definition at line 48 of file CodeGen.h.

llvm::Constant* comma::CodeGen::getConstantArray ( const llvm::Type *  elementType,
std::vector< llvm::Constant * > &  elems 
) const [inline]

Returns a constant array consiting of the given elements, each of which must be of the supplied type.

Definition at line 263 of file CodeGen.h.

llvm::ConstantInt * CodeGen::getConstantInt ( const llvm::IntegerType *  type,
const llvm::APInt &  value 
) const

Returns a ConstantInt for the given value.

This method ensures that the given APInt is within the representational limits of the given type. If the bit width of the supplied APInt does not match that of the given type, then the active bits of the value (interpreted as a signed integer) are used, sign extended to the width of the type. An assertion will fire if the number of active bits exceeds the width of the supplied type.

Definition at line 351 of file CodeGen.cpp.

llvm::ConstantInt* comma::CodeGen::getConstantInt ( const llvm::IntegerType *  type,
uint64_t  value 
) const [inline]

Returns a constant integer.

Definition at line 244 of file CodeGen.h.

const DependencySet & CodeGen::getDependencySet ( const Domoid domoid  ) 

FIXME: This method needs to be encapsulated in a seperate structure.

Definition at line 378 of file CodeGen.cpp.

llvm::Function * CodeGen::getEHExceptionIntrinsic (  )  const

Definition at line 177 of file CodeGen.cpp.

llvm::Function * CodeGen::getEHSelectorIntrinsic (  )  const

Definition at line 182 of file CodeGen.cpp.

llvm::Function * CodeGen::getEHTypeidIntrinsic (  )  const

Definition at line 190 of file CodeGen.cpp.

InstanceInfo* comma::CodeGen::getInstanceInfo ( const DomainInstanceDecl instance  )  const [inline]

Definition at line 75 of file CodeGen.h.

const llvm::IntegerType* comma::CodeGen::getInt16Ty (  )  const [inline]

Returns the llvm type "i16".

Definition at line 213 of file CodeGen.h.

const llvm::IntegerType* comma::CodeGen::getInt1Ty (  )  const [inline]

Returns the llvm type "i1".

Definition at line 203 of file CodeGen.h.

const llvm::IntegerType* comma::CodeGen::getInt32Ty (  )  const [inline]

Returns the llvm type "i32".

Definition at line 218 of file CodeGen.h.

const llvm::IntegerType* comma::CodeGen::getInt64Ty (  )  const [inline]

Returns the llvm type "i64".

Definition at line 223 of file CodeGen.h.

const llvm::PointerType* comma::CodeGen::getInt8PtrTy (  )  const [inline]

Returns the llvm type i8*.

Definition at line 193 of file CodeGen.h.

const llvm::IntegerType* comma::CodeGen::getInt8Ty (  )  const [inline]

Returns the llvm type "i8".

Definition at line 208 of file CodeGen.h.

const llvm::IntegerType* comma::CodeGen::getIntPtrTy (  )  const [inline]

Returns a integer type capable of representing a pointer.

Definition at line 228 of file CodeGen.h.

llvm::LLVMContext& comma::CodeGen::getLLVMContext (  )  const [inline]

Returns the LLVMContext associated with this code generator.

Definition at line 51 of file CodeGen.h.

llvm::Function* comma::CodeGen::getLLVMIntrinsic ( llvm::Intrinsic::ID  id  )  const [inline]

Returns a function declaration for the given llvm intrinsic.

This method is not appropriate for the retrieval of overloaded intrinsics.

Definition at line 165 of file CodeGen.h.

llvm::Function * CodeGen::getMemcpy32 (  )  const

Returns a function declaration for the llvm.memcpy.i32 intrinsic.

Definition at line 165 of file CodeGen.cpp.

llvm::Function * CodeGen::getMemcpy64 (  )  const

Returns a function declaration for the llvm.memcpy.i64 intrinsic.

Definition at line 159 of file CodeGen.cpp.

llvm::Function * CodeGen::getMemset32 (  )  const

Returns a function declaration for the llvm.memset.i32 intrinsic.

Definition at line 171 of file CodeGen.cpp.

llvm::Module* comma::CodeGen::getModule (  )  [inline]

Returns the module we are generating code for.

Definition at line 39 of file CodeGen.h.

llvm::Constant * CodeGen::getModuleName (  ) 

Returns an i8* pointing the the name of this module.

Definition at line 390 of file CodeGen.cpp.

llvm::Constant* comma::CodeGen::getNullPointer ( const llvm::PointerType *  Ty  )  const [inline]

Returns a null pointer constant of the specified type.

Definition at line 234 of file CodeGen.h.

const llvm::OpaqueType* comma::CodeGen::getOpaqueTy (  )  const [inline]

Returns an llvm "opaque" type.

Definition at line 188 of file CodeGen.h.

llvm::Constant* comma::CodeGen::getPointerCast ( llvm::Constant *  constant,
const llvm::PointerType *  Ty 
) const [inline]

Casts the given constant expression into the given pointer type.

Definition at line 272 of file CodeGen.h.

llvm::PointerType* comma::CodeGen::getPointerType ( const llvm::Type *  Ty  )  const [inline]

Returns a pointer-to the given type.

Definition at line 239 of file CodeGen.h.

CommaRT& comma::CodeGen::getRuntime (  )  const [inline]

Returns the interface to the runtime system.

Definition at line 36 of file CodeGen.h.

llvm::ConstantInt* comma::CodeGen::getSourceColumn ( Location  loc  )  [inline]

Returns the column of the given location is an i32.

Definition at line 306 of file CodeGen.h.

llvm::ConstantInt* comma::CodeGen::getSourceLine ( Location  loc  )  [inline]

Returns the line of the given location as an i32.

Definition at line 300 of file CodeGen.h.

SourceLocation CodeGen::getSourceLocation ( Location  loc  ) 

Returns the detailed source location object corresponding to the given raw location.

Definition at line 401 of file CodeGen.cpp.

SRInfo * CodeGen::getSRInfo ( DomainInstanceDecl instance,
SubroutineDecl srDecl 
)

Returns the SRInfo object associated with srDecl.

The given instance must be a domain registered with the code generator. If the lookup of srDecl fails an assertion will fire.

Definition at line 244 of file CodeGen.cpp.

llvm::StructType* comma::CodeGen::getStructTy ( const std::vector< const llvm::Type * > &  elts,
bool  isPacked = false 
) const [inline]

Returns an llvm structure type.

Definition at line 278 of file CodeGen.h.

const llvm::TargetData& comma::CodeGen::getTargetData (  )  const [inline]

Returns the llvm::TargetData used to generate code.

Definition at line 45 of file CodeGen.h.

llvm::ArrayType* comma::CodeGen::getVLArrayTy ( const llvm::Type *  componentTy  )  const [inline]

Returns a variable length array type.

Definition at line 284 of file CodeGen.h.

const llvm::Type* comma::CodeGen::getVoidTy (  )  const [inline]

Returns the llvm type "void".

Definition at line 198 of file CodeGen.h.

bool CodeGen::insertGlobal ( const std::string &  linkName,
llvm::GlobalValue *  GV 
)

Adds a mapping between the given link name and an LLVM GlobalValue into the global table.

Returns true if the insertion succeeded and false if there was a conflict. In the latter case, the global table is not modified.

Definition at line 251 of file CodeGen.cpp.

llvm::GlobalValue * CodeGen::lookupCapsuleInfo ( const Domoid domoid  )  const

Returns an llvm value representing the static compile time info representing a previously declared capsule, or null if no such information is present.

Definition at line 267 of file CodeGen.cpp.

llvm::GlobalValue * CodeGen::lookupGlobal ( const std::string &  linkName  )  const

Returns an llvm value for a previously declared decl with the given link (mangled) name, or null if no such declaration exists.

Definition at line 262 of file CodeGen.cpp.

InstanceInfo* comma::CodeGen::lookupInstanceInfo ( const DomainInstanceDecl instance  )  const [inline]

Definition at line 71 of file CodeGen.h.

llvm::BasicBlock * CodeGen::makeBasicBlock ( const std::string &  name = "",
llvm::Function *  parent = 0,
llvm::BasicBlock *  insertBefore = 0 
) const

Returns an llvm basic block.

Definition at line 290 of file CodeGen.cpp.

llvm::GlobalVariable * CodeGen::makeExternGlobal ( llvm::Constant *  init,
bool  isConstant = false,
const std::string &  name = "" 
)

Returns a global variable with external linkage embedded in the current module.

Parameters:
init A constant initializer for the global.
isConstant If true, the global will be allocated in a read-only section, otherwise in a writeable section.
name The name of the global to be linked into the module.

Definition at line 298 of file CodeGen.cpp.

llvm::Function * CodeGen::makeFunction ( const DomainInstanceDecl instance,
const SubroutineDecl srDecl,
CodeGenTypes CGT 
)

Creates a function corresponding to the given Comma subroutine declaration.

Definition at line 325 of file CodeGen.cpp.

llvm::Function * CodeGen::makeFunction ( const llvm::FunctionType *  Ty,
const std::string &  name = "" 
)

Creates a function with the given name and type. The linkage type is external.

Definition at line 317 of file CodeGen.cpp.

llvm::Function * CodeGen::makeInternFunction ( const llvm::FunctionType *  Ty,
const std::string &  name = "" 
)

Creates a function with the given name and type. The linkage type is internal.

Definition at line 342 of file CodeGen.cpp.

llvm::GlobalVariable * CodeGen::makeInternGlobal ( llvm::Constant *  init,
bool  isConstant = false,
const std::string &  name = "" 
)

Returns a global variable with internal linkage embedded in the current module.

Parameters:
init A constant initializer for the global.
isConstant If true, the global will be allocated in a read-only section, otherwise in a writeable section.
name The name of the global to be linked into the module.

Definition at line 308 of file CodeGen.cpp.


Friends And Related Function Documentation

friend class Generator [friend]

Definition at line 370 of file CodeGen.h.


The documentation for this class was generated from the following files:

Generated on 1 Feb 2010 for Comma by  doxygen 1.6.1