annotate gen/llvmhelpers.h @ 399:0e6b4d65d3f8

Give error messages for invalid casts. This required passing Loc information to certain functions. Fixes nocompile/b/bug_cgcs_354_A/B.
author Christian Kamm <kamm incasoftware de>
date Sat, 26 Jul 2008 17:19:16 +0200
parents 83ade4f4025a
children ac1fcc138e42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
5 #include "statement.h"
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
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
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
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
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
21
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
22 // generates IR for finally blocks between the 'start' and 'end' statements
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
23 // will begin with the finally block belonging to 'start' and does not include
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
24 // the finally block of 'end'
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
25 void DtoEnclosingHandlers(EnclosingHandler* start, EnclosingHandler* end);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
26
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
27 // enters a critical section
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
28 void DtoEnterCritical(LLValue* g);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
29 // leaves a critical section
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
30 void DtoLeaveCritical(LLValue* g);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
31
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
32 // enters a monitor lock
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
33 void DtoEnterMonitor(LLValue* v);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
34 // leaves a monitor lock
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
35 void DtoLeaveMonitor(LLValue* v);
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 284
diff changeset
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);
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 372
diff changeset
51 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
52
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
53 // 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
54 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
55
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
56 // 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
57 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
58
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
59 // 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
60 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
61 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
62 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
63 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
64 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
65 void DtoEmptyResolveList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
66 void DtoEmptyDeclareList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
67 void DtoEmptyConstInitList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
68 void DtoEmptyAllLists();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
69 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
70 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
71 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
72
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
73 // initializer helpers
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
74 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
75 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
76 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
77
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
78 // annotation generator
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
79 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
80
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
81 // 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
82 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
83
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
84 // binary operations
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
85 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
86 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
87 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
88 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
89 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
90
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
91 // 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
92 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
93
347
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
94 /**
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
95 * Calls a D function (with D calling conv).
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
96 * @param fdecl The FuncDeclaration to call
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
97 * @param arguments The Array of ExpressionS to pass as arguments.
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
98 * @param type Optionally the TypeClass of the 'this' arguement.
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
99 * @param thismem Optionally the LLValue for the 'this' argument.
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
100 * @return The function call's return value.
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
101 */
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
102 DValue* DtoCallDFunc(FuncDeclaration* fdecl, Array* arguments, TypeClass* type=0, LLValue* thismem=0);
6057fdf797d8 [svn r368] Fixed custom class allocators with arbitrary user arguments. Closes #25
lindquist
parents: 309
diff changeset
103
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 356
diff changeset
104 /// 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
105 LLValue* DtoBoolean(Loc& loc, DValue* dval);
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 356
diff changeset
106
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
107 #endif