Mercurial > projects > ldc
annotate gen/llvmhelpers.h @ 424:c8d98ccad0cc
Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 29 Jul 2008 12:32:01 +0200 |
parents | fa91b03d9cd7 |
children | b5f55f471e0b |
rev | line source |
---|---|
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1 #ifndef LLVMDC_GEN_LLVMHELPERS_H |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
2 #define LLVMDC_GEN_LLVMHELPERS_H |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
3 |
347
6057fdf797d8
[svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents:
309
diff
changeset
|
4 #include "gen/llvm.h" |
302 | 5 #include "statement.h" |
6 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
7 // dynamic memory helpers |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
8 LLValue* DtoNew(Type* newtype); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
9 void DtoDeleteMemory(LLValue* ptr); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
10 void DtoDeleteClass(LLValue* inst); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
11 void DtoDeleteInterface(LLValue* inst); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
12 void DtoDeleteArray(DValue* arr); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
13 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
14 // assertion generator |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
15 void DtoAssert(Loc* loc, DValue* msg); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
16 |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
302
diff
changeset
|
17 // return the LabelStatement from the current function with the given identifier or NULL if not found |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
302
diff
changeset
|
18 LabelStatement* DtoLabelStatement(Identifier* ident); |
302 | 19 // emit goto |
356
44daf304421c
[svn r377] The previous check was too strict, it completely disallowed gotos within finally blocks. This reenables them as long as they don't cross a finally boundary.
ChristianK
parents:
347
diff
changeset
|
20 void DtoGoto(Loc* loc, Identifier* target, EnclosingHandler* enclosingtryfinally, TryFinallyStatement* sourcetf); |
302 | 21 |
22 // generates IR for finally blocks between the 'start' and 'end' statements | |
23 // will begin with the finally block belonging to 'start' and does not include | |
24 // the finally block of 'end' | |
309 | 25 void DtoEnclosingHandlers(EnclosingHandler* start, EnclosingHandler* end); |
26 | |
27 // enters a critical section | |
28 void DtoEnterCritical(LLValue* g); | |
29 // leaves a critical section | |
30 void DtoLeaveCritical(LLValue* g); | |
31 | |
32 // enters a monitor lock | |
33 void DtoEnterMonitor(LLValue* v); | |
34 // leaves a monitor lock | |
35 void DtoLeaveMonitor(LLValue* v); | |
302 | 36 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
37 // nested variable/class helpers |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
38 LLValue* DtoNestedContext(FuncDeclaration* func); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
39 LLValue* DtoNestedVariable(VarDeclaration* vd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
40 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
41 // basic operations |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
372
diff
changeset
|
42 void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
43 |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
365
diff
changeset
|
44 // create a null dvalue |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
365
diff
changeset
|
45 DValue* DtoNullValue(Type* t); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
365
diff
changeset
|
46 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
47 // casts |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
372
diff
changeset
|
48 DValue* DtoCastInt(Loc& loc, DValue* val, Type* to); |
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
372
diff
changeset
|
49 DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to); |
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
372
diff
changeset
|
50 DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to); |
419
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
51 DValue* DtoCastDelegate(Loc& loc, DValue* val, Type* to); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
372
diff
changeset
|
52 DValue* DtoCast(Loc& loc, DValue* val, Type* to); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
53 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
54 // is template instance check |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
55 bool DtoIsTemplateInstance(Dsymbol* s); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
56 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
57 // generates lazy static initialization code for a global variable |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
58 void DtoLazyStaticInit(bool istempl, LLValue* gvar, Initializer* init, Type* t); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
59 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
60 // these are all basically drivers for the codegeneration called by the main loop |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
61 void DtoResolveDsymbol(Dsymbol* dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
62 void DtoDeclareDsymbol(Dsymbol* dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
63 void DtoDefineDsymbol(Dsymbol* dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
64 void DtoConstInitDsymbol(Dsymbol* dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
65 void DtoConstInitGlobal(VarDeclaration* vd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
66 void DtoEmptyResolveList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
67 void DtoEmptyDeclareList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
68 void DtoEmptyConstInitList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
69 void DtoEmptyAllLists(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
70 void DtoForceDeclareDsymbol(Dsymbol* dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
71 void DtoForceConstInitDsymbol(Dsymbol* dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
72 void DtoForceDefineDsymbol(Dsymbol* dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
73 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
74 // initializer helpers |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
75 LLConstant* DtoConstInitializer(Type* type, Initializer* init); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
76 LLConstant* DtoConstFieldInitializer(Type* type, Initializer* init); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
77 DValue* DtoInitializer(Initializer* init); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
78 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
79 // annotation generator |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
80 void DtoAnnotation(const char* str); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
81 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
82 // getting typeinfo of type, base=true casts to object.TypeInfo |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
83 LLConstant* DtoTypeInfoOf(Type* ty, bool base=true); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
84 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
85 // binary operations |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
86 DValue* DtoBinAdd(DValue* lhs, DValue* rhs); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
87 DValue* DtoBinSub(DValue* lhs, DValue* rhs); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
88 DValue* DtoBinMul(DValue* lhs, DValue* rhs); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
89 DValue* DtoBinDiv(DValue* lhs, DValue* rhs); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
90 DValue* DtoBinRem(DValue* lhs, DValue* rhs); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
91 |
284
70c370e97944
[svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents:
244
diff
changeset
|
92 // target stuff |
70c370e97944
[svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents:
244
diff
changeset
|
93 void findDefaultTarget(); |
70c370e97944
[svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents:
244
diff
changeset
|
94 |
365 | 95 /// Converts any value to a boolean (llvm i1) |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
372
diff
changeset
|
96 LLValue* DtoBoolean(Loc& loc, DValue* dval); |
365 | 97 |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
98 //////////////////////////////////////////// |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
99 // gen/tocall.cpp stuff below |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
100 //////////////////////////////////////////// |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
101 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
102 /// convert DMD calling conv to LLVM |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
103 unsigned DtoCallingConv(LINK l); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
104 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
105 /// |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
106 TypeFunction* DtoTypeFunction(Type* type); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
107 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
108 /// |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
109 DValue* DtoVaArg(Loc& loc, Type* type, Expression* valistArg); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
110 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
111 /// |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
112 LLValue* DtoCallableValue(DValue* fn); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
113 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
114 /// |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
115 const LLFunctionType* DtoExtractFunctionType(const LLType* type); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
116 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
117 /// |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
118 void DtoBuildDVarArgList(std::vector<LLValue*>& args, llvm::PAListPtr& palist, TypeFunction* tf, Expressions* arguments, size_t argidx); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
119 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
120 /// |
422
fa91b03d9cd7
Error message for calling a function with a missing 'this' arg.
Christian Kamm <kamm incasoftware de>
parents:
419
diff
changeset
|
121 DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* arguments); |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
122 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
123 #endif |