Mercurial > projects > ldc
diff gen/tollvm.h @ 244:a95056b3c996 trunk
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
Did a lot of smaller cleans up here and there.
Replaced more llvm::Foo with LLFoo for common stuff.
Split up tollvm.cpp.
author | lindquist |
---|---|
date | Mon, 09 Jun 2008 09:37:08 +0200 |
parents | 0806379a5eca |
children | d59c363fccad |
line wrap: on
line diff
--- a/gen/tollvm.h Mon Jun 09 03:02:14 2008 +0200 +++ b/gen/tollvm.h Mon Jun 09 09:37:08 2008 +0200 @@ -19,15 +19,13 @@ Type* DtoDType(Type* t); // delegate helpers -const llvm::StructType* DtoDelegateType(Type* t); -void DtoDelegateToNull(LLValue* v); -void DtoDelegateCopy(LLValue* dst, LLValue* src); +const LLStructType* DtoDelegateType(Type* t); LLValue* DtoDelegateCompare(TOK op, LLValue* lhs, LLValue* rhs); // return linkage type for symbol using the current ir state for context -llvm::GlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym); -llvm::GlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym); -llvm::GlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym); +LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym); +LLGlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym); +LLGlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym); // convert DMD calling conv to LLVM unsigned DtoCallingConv(LINK l); @@ -40,122 +38,94 @@ // some types const LLType* DtoSize_t(); -const llvm::StructType* DtoInterfaceInfoType(); - -// getting typeinfo of type, base=true casts to object.TypeInfo -LLConstant* DtoTypeInfoOf(Type* ty, bool base=true); - -// initializer helpers -LLConstant* DtoConstInitializer(Type* type, Initializer* init); -LLConstant* DtoConstFieldInitializer(Type* type, Initializer* init); -DValue* DtoInitializer(Initializer* init); - -// declaration of memset/cpy intrinsics -llvm::Function* LLVM_DeclareMemSet32(); -llvm::Function* LLVM_DeclareMemSet64(); -llvm::Function* LLVM_DeclareMemCpy32(); -llvm::Function* LLVM_DeclareMemCpy64(); +const LLStructType* DtoInterfaceInfoType(); // getelementptr helpers -LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb=NULL); -LLValue* DtoGEPi(LLValue* ptr, const DStructIndexVector& src, const char* var, llvm::BasicBlock* bb=NULL); -LLValue* DtoGEPi(LLValue* ptr, unsigned i0, const char* var, llvm::BasicBlock* bb=NULL); -LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::BasicBlock* bb=NULL); - -// dynamic memory helpers -LLValue* DtoNew(Type* newtype); -void DtoDeleteMemory(LLValue* ptr); -void DtoDeleteClass(LLValue* inst); -void DtoDeleteInterface(LLValue* inst); -void DtoDeleteArray(DValue* arr); - -// assertion generator -void DtoAssert(Loc* loc, DValue* msg); - -// nested variable/class helpers -LLValue* DtoNestedContext(FuncDeclaration* func); -LLValue* DtoNestedVariable(VarDeclaration* vd); - -// annotation generator -void DtoAnnotation(const char* str); +LLValue* DtoGEP1(LLValue* ptr, LLValue* i0, const char* var=NULL, llvm::BasicBlock* bb=NULL); +LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var=NULL, llvm::BasicBlock* bb=NULL); +LLValue* DtoGEPi(LLValue* ptr, const DStructIndexVector& src, const char* var=NULL, llvm::BasicBlock* bb=NULL); +LLValue* DtoGEPi1(LLValue* ptr, unsigned i0, const char* var=NULL, llvm::BasicBlock* bb=NULL); +LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var=NULL, llvm::BasicBlock* bb=NULL); // to constant helpers -llvm::ConstantInt* DtoConstSize_t(size_t); -llvm::ConstantInt* DtoConstUint(unsigned i); -llvm::ConstantInt* DtoConstInt(int i); +LLConstantInt* DtoConstSize_t(size_t); +LLConstantInt* DtoConstUint(unsigned i); +LLConstantInt* DtoConstInt(int i); +LLConstantInt* DtoConstUbyte(unsigned char i); llvm::ConstantFP* DtoConstFP(Type* t, long double value); LLConstant* DtoConstString(const char*); LLConstant* DtoConstStringPtr(const char* str, const char* section = 0); LLConstant* DtoConstBool(bool); -// is template instance check -bool DtoIsTemplateInstance(Dsymbol* s); - -// generates lazy static initialization code for a global variable -void DtoLazyStaticInit(bool istempl, LLValue* gvar, Initializer* init, Type* t); - -// these are all basically drivers for the codegeneration called by the main loop -void DtoResolveDsymbol(Dsymbol* dsym); -void DtoDeclareDsymbol(Dsymbol* dsym); -void DtoDefineDsymbol(Dsymbol* dsym); -void DtoConstInitDsymbol(Dsymbol* dsym); -void DtoConstInitGlobal(VarDeclaration* vd); -void DtoEmptyResolveList(); -void DtoEmptyDeclareList(); -void DtoEmptyConstInitList(); -void DtoEmptyAllLists(); -void DtoForceDeclareDsymbol(Dsymbol* dsym); -void DtoForceConstInitDsymbol(Dsymbol* dsym); -void DtoForceDefineDsymbol(Dsymbol* dsym); - // llvm wrappers -void DtoMemSetZero(LLValue* dst, LLValue* nbytes); -void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes); -void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device=false); bool DtoCanLoad(LLValue* ptr); LLValue* DtoLoad(LLValue* src, const char* name=0); void DtoStore(LLValue* src, LLValue* dst); LLValue* DtoBitCast(LLValue* v, const LLType* t, const char* name=0); // llvm::dyn_cast wrappers -const llvm::PointerType* isaPointer(LLValue* v); -const llvm::PointerType* isaPointer(const LLType* t); -const llvm::ArrayType* isaArray(LLValue* v); -const llvm::ArrayType* isaArray(const LLType* t); -const llvm::StructType* isaStruct(LLValue* v); -const llvm::StructType* isaStruct(const LLType* t); +const LLPointerType* isaPointer(LLValue* v); +const LLPointerType* isaPointer(const LLType* t); +const LLArrayType* isaArray(LLValue* v); +const LLArrayType* isaArray(const LLType* t); +const LLStructType* isaStruct(LLValue* v); +const LLStructType* isaStruct(const LLType* t); LLConstant* isaConstant(LLValue* v); -llvm::ConstantInt* isaConstantInt(LLValue* v); +LLConstantInt* isaConstantInt(LLValue* v); llvm::Argument* isaArgument(LLValue* v); -llvm::GlobalVariable* isaGlobalVar(LLValue* v); +LLGlobalVariable* isaGlobalVar(LLValue* v); // llvm::T::get(...) wrappers -const llvm::PointerType* getPtrToType(const LLType* t); -const llvm::PointerType* getVoidPtrType(); +const LLPointerType* getPtrToType(const LLType* t); +const LLPointerType* getVoidPtrType(); llvm::ConstantPointerNull* getNullPtr(const LLType* t); // type sizes size_t getTypeBitSize(const LLType* t); size_t getTypeStoreSize(const LLType* t); size_t getABITypeSize(const LLType* t); +// type alignments +unsigned char getABITypeAlign(const LLType* t); +unsigned char getPrefTypeAlign(const LLType* t); -// basic operations -void DtoAssign(DValue* lhs, DValue* rhs); +/** + * Generates a call to llvm.memset.i32 (or i64 depending on architecture). + * @param dst Destination memory. + * @param nbytes Number of bytes to overwrite. + */ +void DtoMemSetZero(LLValue* dst, LLValue* nbytes); + +/** + * Generates a call to llvm.memcpy.i32 (or i64 depending on architecture). + * @param dst Destination memory. + * @param src Source memory. + * @param nbytes Number of bytes to copy. + */ +void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes); -// casts -DValue* DtoCastInt(DValue* val, Type* to); -DValue* DtoCastPtr(DValue* val, Type* to); -DValue* DtoCastFloat(DValue* val, Type* to); -DValue* DtoCastComplex(DValue* val, Type* to); -DValue* DtoCast(DValue* val, Type* to); +/** + * The same as DtoMemSetZero but figures out the size itself by "dereferencing" the v pointer once. + * @param v Destination memory. + */ +void DtoAggrZeroInit(LLValue* v); -// binary operations -DValue* DtoBinAdd(DValue* lhs, DValue* rhs); -DValue* DtoBinSub(DValue* lhs, DValue* rhs); -DValue* DtoBinMul(DValue* lhs, DValue* rhs); -DValue* DtoBinDiv(DValue* lhs, DValue* rhs); -DValue* DtoBinRem(DValue* lhs, DValue* rhs); +/** + * The same as DtoMemCpy but figures out the size itself by "dereferencing" dst the pointer once. + * @param dst Destination memory. + * @param src Source memory. + */ +void DtoAggrCopy(LLValue* dst, LLValue* src); + +/** + * Generates a call to llvm.memory.barrier + * @param ll load-load + * @param ls load-store + * @param sl store-load + * @param ss store-store + * @param device special device flag + */ +void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device=false); #include "enums.h"