comparison 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
comparison
equal deleted inserted replaced
243:4d006f7b2ada 244:a95056b3c996
17 // resolve typedefs to their real type. 17 // resolve typedefs to their real type.
18 // TODO should probably be removed in favor of DMD's Type::toBasetype 18 // TODO should probably be removed in favor of DMD's Type::toBasetype
19 Type* DtoDType(Type* t); 19 Type* DtoDType(Type* t);
20 20
21 // delegate helpers 21 // delegate helpers
22 const llvm::StructType* DtoDelegateType(Type* t); 22 const LLStructType* DtoDelegateType(Type* t);
23 void DtoDelegateToNull(LLValue* v);
24 void DtoDelegateCopy(LLValue* dst, LLValue* src);
25 LLValue* DtoDelegateCompare(TOK op, LLValue* lhs, LLValue* rhs); 23 LLValue* DtoDelegateCompare(TOK op, LLValue* lhs, LLValue* rhs);
26 24
27 // return linkage type for symbol using the current ir state for context 25 // return linkage type for symbol using the current ir state for context
28 llvm::GlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym); 26 LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym);
29 llvm::GlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym); 27 LLGlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym);
30 llvm::GlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym); 28 LLGlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym);
31 29
32 // convert DMD calling conv to LLVM 30 // convert DMD calling conv to LLVM
33 unsigned DtoCallingConv(LINK l); 31 unsigned DtoCallingConv(LINK l);
34 32
35 // TODO: this one should be removed!!! 33 // TODO: this one should be removed!!!
38 // casts any value to a boolean 36 // casts any value to a boolean
39 LLValue* DtoBoolean(LLValue* val); 37 LLValue* DtoBoolean(LLValue* val);
40 38
41 // some types 39 // some types
42 const LLType* DtoSize_t(); 40 const LLType* DtoSize_t();
43 const llvm::StructType* DtoInterfaceInfoType(); 41 const LLStructType* DtoInterfaceInfoType();
44
45 // getting typeinfo of type, base=true casts to object.TypeInfo
46 LLConstant* DtoTypeInfoOf(Type* ty, bool base=true);
47
48 // initializer helpers
49 LLConstant* DtoConstInitializer(Type* type, Initializer* init);
50 LLConstant* DtoConstFieldInitializer(Type* type, Initializer* init);
51 DValue* DtoInitializer(Initializer* init);
52
53 // declaration of memset/cpy intrinsics
54 llvm::Function* LLVM_DeclareMemSet32();
55 llvm::Function* LLVM_DeclareMemSet64();
56 llvm::Function* LLVM_DeclareMemCpy32();
57 llvm::Function* LLVM_DeclareMemCpy64();
58 42
59 // getelementptr helpers 43 // getelementptr helpers
60 LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb=NULL); 44 LLValue* DtoGEP1(LLValue* ptr, LLValue* i0, const char* var=NULL, llvm::BasicBlock* bb=NULL);
61 LLValue* DtoGEPi(LLValue* ptr, const DStructIndexVector& src, const char* var, llvm::BasicBlock* bb=NULL); 45 LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var=NULL, llvm::BasicBlock* bb=NULL);
62 LLValue* DtoGEPi(LLValue* ptr, unsigned i0, const char* var, llvm::BasicBlock* bb=NULL); 46 LLValue* DtoGEPi(LLValue* ptr, const DStructIndexVector& src, const char* var=NULL, llvm::BasicBlock* bb=NULL);
63 LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::BasicBlock* bb=NULL); 47 LLValue* DtoGEPi1(LLValue* ptr, unsigned i0, const char* var=NULL, llvm::BasicBlock* bb=NULL);
64 48 LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var=NULL, llvm::BasicBlock* bb=NULL);
65 // dynamic memory helpers
66 LLValue* DtoNew(Type* newtype);
67 void DtoDeleteMemory(LLValue* ptr);
68 void DtoDeleteClass(LLValue* inst);
69 void DtoDeleteInterface(LLValue* inst);
70 void DtoDeleteArray(DValue* arr);
71
72 // assertion generator
73 void DtoAssert(Loc* loc, DValue* msg);
74
75 // nested variable/class helpers
76 LLValue* DtoNestedContext(FuncDeclaration* func);
77 LLValue* DtoNestedVariable(VarDeclaration* vd);
78
79 // annotation generator
80 void DtoAnnotation(const char* str);
81 49
82 // to constant helpers 50 // to constant helpers
83 llvm::ConstantInt* DtoConstSize_t(size_t); 51 LLConstantInt* DtoConstSize_t(size_t);
84 llvm::ConstantInt* DtoConstUint(unsigned i); 52 LLConstantInt* DtoConstUint(unsigned i);
85 llvm::ConstantInt* DtoConstInt(int i); 53 LLConstantInt* DtoConstInt(int i);
54 LLConstantInt* DtoConstUbyte(unsigned char i);
86 llvm::ConstantFP* DtoConstFP(Type* t, long double value); 55 llvm::ConstantFP* DtoConstFP(Type* t, long double value);
87 56
88 LLConstant* DtoConstString(const char*); 57 LLConstant* DtoConstString(const char*);
89 LLConstant* DtoConstStringPtr(const char* str, const char* section = 0); 58 LLConstant* DtoConstStringPtr(const char* str, const char* section = 0);
90 LLConstant* DtoConstBool(bool); 59 LLConstant* DtoConstBool(bool);
91 60
92 // is template instance check
93 bool DtoIsTemplateInstance(Dsymbol* s);
94
95 // generates lazy static initialization code for a global variable
96 void DtoLazyStaticInit(bool istempl, LLValue* gvar, Initializer* init, Type* t);
97
98 // these are all basically drivers for the codegeneration called by the main loop
99 void DtoResolveDsymbol(Dsymbol* dsym);
100 void DtoDeclareDsymbol(Dsymbol* dsym);
101 void DtoDefineDsymbol(Dsymbol* dsym);
102 void DtoConstInitDsymbol(Dsymbol* dsym);
103 void DtoConstInitGlobal(VarDeclaration* vd);
104 void DtoEmptyResolveList();
105 void DtoEmptyDeclareList();
106 void DtoEmptyConstInitList();
107 void DtoEmptyAllLists();
108 void DtoForceDeclareDsymbol(Dsymbol* dsym);
109 void DtoForceConstInitDsymbol(Dsymbol* dsym);
110 void DtoForceDefineDsymbol(Dsymbol* dsym);
111
112 // llvm wrappers 61 // llvm wrappers
113 void DtoMemSetZero(LLValue* dst, LLValue* nbytes);
114 void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes);
115 void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device=false);
116 bool DtoCanLoad(LLValue* ptr); 62 bool DtoCanLoad(LLValue* ptr);
117 LLValue* DtoLoad(LLValue* src, const char* name=0); 63 LLValue* DtoLoad(LLValue* src, const char* name=0);
118 void DtoStore(LLValue* src, LLValue* dst); 64 void DtoStore(LLValue* src, LLValue* dst);
119 LLValue* DtoBitCast(LLValue* v, const LLType* t, const char* name=0); 65 LLValue* DtoBitCast(LLValue* v, const LLType* t, const char* name=0);
120 66
121 // llvm::dyn_cast wrappers 67 // llvm::dyn_cast wrappers
122 const llvm::PointerType* isaPointer(LLValue* v); 68 const LLPointerType* isaPointer(LLValue* v);
123 const llvm::PointerType* isaPointer(const LLType* t); 69 const LLPointerType* isaPointer(const LLType* t);
124 const llvm::ArrayType* isaArray(LLValue* v); 70 const LLArrayType* isaArray(LLValue* v);
125 const llvm::ArrayType* isaArray(const LLType* t); 71 const LLArrayType* isaArray(const LLType* t);
126 const llvm::StructType* isaStruct(LLValue* v); 72 const LLStructType* isaStruct(LLValue* v);
127 const llvm::StructType* isaStruct(const LLType* t); 73 const LLStructType* isaStruct(const LLType* t);
128 LLConstant* isaConstant(LLValue* v); 74 LLConstant* isaConstant(LLValue* v);
129 llvm::ConstantInt* isaConstantInt(LLValue* v); 75 LLConstantInt* isaConstantInt(LLValue* v);
130 llvm::Argument* isaArgument(LLValue* v); 76 llvm::Argument* isaArgument(LLValue* v);
131 llvm::GlobalVariable* isaGlobalVar(LLValue* v); 77 LLGlobalVariable* isaGlobalVar(LLValue* v);
132 78
133 // llvm::T::get(...) wrappers 79 // llvm::T::get(...) wrappers
134 const llvm::PointerType* getPtrToType(const LLType* t); 80 const LLPointerType* getPtrToType(const LLType* t);
135 const llvm::PointerType* getVoidPtrType(); 81 const LLPointerType* getVoidPtrType();
136 llvm::ConstantPointerNull* getNullPtr(const LLType* t); 82 llvm::ConstantPointerNull* getNullPtr(const LLType* t);
137 83
138 // type sizes 84 // type sizes
139 size_t getTypeBitSize(const LLType* t); 85 size_t getTypeBitSize(const LLType* t);
140 size_t getTypeStoreSize(const LLType* t); 86 size_t getTypeStoreSize(const LLType* t);
141 size_t getABITypeSize(const LLType* t); 87 size_t getABITypeSize(const LLType* t);
88 // type alignments
89 unsigned char getABITypeAlign(const LLType* t);
90 unsigned char getPrefTypeAlign(const LLType* t);
142 91
143 // basic operations 92 /**
144 void DtoAssign(DValue* lhs, DValue* rhs); 93 * Generates a call to llvm.memset.i32 (or i64 depending on architecture).
94 * @param dst Destination memory.
95 * @param nbytes Number of bytes to overwrite.
96 */
97 void DtoMemSetZero(LLValue* dst, LLValue* nbytes);
145 98
146 // casts 99 /**
147 DValue* DtoCastInt(DValue* val, Type* to); 100 * Generates a call to llvm.memcpy.i32 (or i64 depending on architecture).
148 DValue* DtoCastPtr(DValue* val, Type* to); 101 * @param dst Destination memory.
149 DValue* DtoCastFloat(DValue* val, Type* to); 102 * @param src Source memory.
150 DValue* DtoCastComplex(DValue* val, Type* to); 103 * @param nbytes Number of bytes to copy.
151 DValue* DtoCast(DValue* val, Type* to); 104 */
105 void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes);
152 106
153 // binary operations 107 /**
154 DValue* DtoBinAdd(DValue* lhs, DValue* rhs); 108 * The same as DtoMemSetZero but figures out the size itself by "dereferencing" the v pointer once.
155 DValue* DtoBinSub(DValue* lhs, DValue* rhs); 109 * @param v Destination memory.
156 DValue* DtoBinMul(DValue* lhs, DValue* rhs); 110 */
157 DValue* DtoBinDiv(DValue* lhs, DValue* rhs); 111 void DtoAggrZeroInit(LLValue* v);
158 DValue* DtoBinRem(DValue* lhs, DValue* rhs); 112
113 /**
114 * The same as DtoMemCpy but figures out the size itself by "dereferencing" dst the pointer once.
115 * @param dst Destination memory.
116 * @param src Source memory.
117 */
118 void DtoAggrCopy(LLValue* dst, LLValue* src);
119
120 /**
121 * Generates a call to llvm.memory.barrier
122 * @param ll load-load
123 * @param ls load-store
124 * @param sl store-load
125 * @param ss store-store
126 * @param device special device flag
127 */
128 void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device=false);
159 129
160 #include "enums.h" 130 #include "enums.h"
161 131
162 #endif // LLVMDC_GEN_TOLLVM_H 132 #endif // LLVMDC_GEN_TOLLVM_H