view gen/tollvm.h @ 102:027b8d8b71ec trunk

[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up. Basically it tries to do the following in order: Resolve types, Declare symbols, Create constant initializers, Apply initializers, Generate functions bodies. ClassInfo is now has the most useful(biased?) members working. Probably other stuf...
author lindquist
date Sun, 18 Nov 2007 06:52:57 +0100
parents 5071469303d4
children 4d1e9eb001e0
line wrap: on
line source

#ifndef LLVMDC_GEN_TOLLVM_H
#define LLVMDC_GEN_TOLLVM_H

// D -> LLVM helpers

struct DValue;

const llvm::Type* DtoType(Type* t);
bool DtoIsPassedByRef(Type* type);
Type* DtoDType(Type* t);

const llvm::StructType* DtoDelegateType(Type* t);
llvm::Value* DtoNullDelegate(llvm::Value* v);
llvm::Value* DtoDelegateCopy(llvm::Value* dst, llvm::Value* src);
llvm::Value* DtoCompareDelegate(TOK op, llvm::Value* lhs, llvm::Value* rhs);

llvm::GlobalValue::LinkageTypes DtoLinkage(PROT prot, uint stc);
unsigned DtoCallingConv(LINK l);

llvm::Value* DtoPointedType(llvm::Value* ptr, llvm::Value* val);
llvm::Value* DtoBoolean(llvm::Value* val);

const llvm::Type* DtoSize_t();

const llvm::StructType* DtoComplexType(const llvm::Type* base);

llvm::Constant* DtoConstInitializer(Type* type, Initializer* init);
llvm::Constant* DtoConstFieldInitializer(Type* type, Initializer* init);
DValue* DtoInitializer(Initializer* init);

llvm::Function* LLVM_DeclareMemSet32();
llvm::Function* LLVM_DeclareMemSet64();
llvm::Function* LLVM_DeclareMemCpy32();
llvm::Function* LLVM_DeclareMemCpy64();

llvm::Value* DtoGEP(llvm::Value* ptr, llvm::Value* i0, llvm::Value* i1, const std::string& var, llvm::BasicBlock* bb=NULL);
llvm::Value* DtoGEP(llvm::Value* ptr, const std::vector<unsigned>& src, const std::string& var, llvm::BasicBlock* bb=NULL);
llvm::Value* DtoGEPi(llvm::Value* ptr, unsigned i0, const std::string& var, llvm::BasicBlock* bb=NULL);
llvm::Value* DtoGEPi(llvm::Value* ptr, unsigned i0, unsigned i1, const std::string& var, llvm::BasicBlock* bb=NULL);

llvm::Value* DtoRealloc(llvm::Value* ptr, const llvm::Type* ty);
llvm::Value* DtoRealloc(llvm::Value* ptr, llvm::Value* len);

void DtoAssert(llvm::Value* cond, Loc* loc, DValue* msg);

llvm::Value* DtoArgument(const llvm::Type* paramtype, Argument* fnarg, Expression* argexp);

llvm::Value* DtoNestedVariable(VarDeclaration* vd);

llvm::ConstantInt* DtoConstSize_t(size_t);
llvm::ConstantInt* DtoConstUint(unsigned i);
llvm::ConstantInt* DtoConstInt(int i);
llvm::Constant* DtoConstString(const char*);
llvm::Constant* DtoConstStringPtr(const char* str, const char* section = 0);
llvm::Constant* DtoConstBool(bool);
llvm::Constant* DtoConstNullPtr(const llvm::Type* t);

bool DtoIsTemplateInstance(Dsymbol* s);

void DtoLazyStaticInit(bool istempl, llvm::Value* gvar, Initializer* init, Type* t);

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 DtoForceDeclareDsymbol(Dsymbol* dsym);
void DtoForceConstInitDsymbol(Dsymbol* dsym);
void DtoForceDefineDsymbol(Dsymbol* dsym);

// llvm wrappers
void DtoMemCpy(llvm::Value* dst, llvm::Value* src, llvm::Value* nbytes);
bool DtoCanLoad(llvm::Value* ptr);
llvm::Value* DtoLoad(llvm::Value* src);
void DtoStore(llvm::Value* src, llvm::Value* dst);
llvm::Value* DtoBitCast(llvm::Value* v, const llvm::Type* t);

// llvm::dyn_cast wrappers
const llvm::PointerType* isaPointer(llvm::Value* v);
const llvm::PointerType* isaPointer(const llvm::Type* t);
const llvm::ArrayType* isaArray(llvm::Value* v);
const llvm::ArrayType* isaArray(const llvm::Type* t);
const llvm::StructType* isaStruct(llvm::Value* v);
const llvm::StructType* isaStruct(const llvm::Type* t);
llvm::Constant* isaConstant(llvm::Value* v);
llvm::ConstantInt* isaConstantInt(llvm::Value* v);
llvm::Argument* isaArgument(llvm::Value* v);

// basic operations
void DtoAssign(DValue* lhs, DValue* rhs);

// casts
DValue* DtoCastInt(DValue* val, Type* to);
DValue* DtoCastPtr(DValue* val, Type* to);
DValue* DtoCastFloat(DValue* val, Type* to);
DValue* DtoCastClass(DValue* val, Type* to);
DValue* DtoCast(DValue* val, Type* to);

// 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);

#include "enums.h"

#endif // LLVMDC_GEN_TOLLVM_H