annotate gen/llvmhelpers.cpp @ 486:a34078905d01

Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in. Reimplemented support for nested functions/class using a new approach. Added error on taking address of intrinsic. Fixed problems with the ->syntaxCopy of TypeFunction delegate exp. Removed DtoDType and replaced all uses with ->toBasetype() instead. Removed unused inplace stuff. Fixed a bunch of issues in the runtime unittests, not complete yet. Added mini tests.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 10 Aug 2008 08:37:38 +0200
parents d86af825e8d9
children a3d6c9eedcb6 837af2a63564
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 #include "gen/llvm.h"
284
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
2 #include "llvm/Target/TargetMachineRegistry.h"
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
3
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
4 #include "mars.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
5 #include "init.h"
339
385a18242485 [svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents: 328
diff changeset
6 #include "id.h"
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
7 #include "expression.h"
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
8 #include "template.h"
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
9
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
10 #include "gen/tollvm.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
11 #include "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
12 #include "gen/irstate.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
13 #include "gen/runtime.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
14 #include "gen/logger.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
15 #include "gen/arrays.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
16 #include "gen/dvalue.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
17 #include "gen/complex.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
18 #include "gen/classes.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
19 #include "gen/functions.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
20 #include "gen/typeinf.h"
250
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
21 #include "gen/todebug.h"
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
22
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
23 #include <stack>
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
24
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
25 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
26 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
27 // 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
28 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
29
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
30 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
31 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
32 // get runtime function
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
33 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_allocmemoryT");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
34 // get type info
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
35 LLConstant* ti = DtoTypeInfoOf(newtype);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
36 assert(isaPointer(ti));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
37 // call runtime allocator
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
38 LLValue* mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_mem")->get();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
39 // cast
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
40 return DtoBitCast(mem, getPtrToType(DtoType(newtype)), ".gc_mem");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
41 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
42
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
43 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
44 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
45 // get runtime function
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
46 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delmemory");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
47 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
48 LLSmallVector<LLValue*,1> arg;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
49 arg.push_back(DtoBitCast(ptr, getVoidPtrType(), ".tmp"));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
50 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
51 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end());
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
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
54 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
55 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
56 // get runtime function
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
57 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
58 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
59 LLSmallVector<LLValue*,1> arg;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
60 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp"));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
61 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
62 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
63 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
64
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
65 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
66 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
67 // get runtime function
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
68 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delinterface");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
69 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
70 LLSmallVector<LLValue*,1> arg;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
71 arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp"));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
72 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
73 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
74 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
75
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
76 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
77 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
78 // get runtime function
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
79 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delarray");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
80 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
81 LLSmallVector<LLValue*,2> arg;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
82 arg.push_back(DtoArrayLen(arr));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
83 arg.push_back(DtoBitCast(DtoArrayPtr(arr), getVoidPtrType(), ".tmp"));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
84 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
85 gIR->CreateCallOrInvoke(fn, arg.begin(), arg.end());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
86 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
87
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
88 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
89 /*////////////////////////////////////////////////////////////////////////////////////////
479
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
90 // ALLOCA HELPERS
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
91 ////////////////////////////////////////////////////////////////////////////////////////*/
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
92
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
93
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
94 llvm::AllocaInst* DtoAlloca(const LLType* lltype, const std::string& name)
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
95 {
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
96 return new llvm::AllocaInst(lltype, name, gIR->topallocapoint());
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
97 }
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
98
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
99 llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std::string& name)
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
100 {
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
101 return new llvm::AllocaInst(lltype, arraysize, name, gIR->topallocapoint());
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
102 }
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
103
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
104
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
105 /****************************************************************************************/
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
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 // ASSERT HELPER
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
108 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
109
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
110 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
111 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
112 std::vector<LLValue*> args;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
113 LLConstant* c;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
114
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
115 // func
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
116 const char* fname = msg ? "_d_assert_msg" : "_d_assert";
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
117 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
118
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
119 // param attrs
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
120 llvm::PAListPtr palist;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
121 int idx = 1;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
122
291
068cb3c60afb [svn r312] Changed assert codegen to insert an unreachable terminator after the call to the assert function, which currently calls abort().
lindquist
parents: 290
diff changeset
123 // FIXME: every assert creates a global for the filename !!!
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
124 c = DtoConstString(loc->filename);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
125
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
126 // msg param
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
127 if (msg)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
128 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
129 if (DSliceValue* s = msg->isSlice())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
130 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
131 llvm::AllocaInst* alloc = gIR->func()->msgArg;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
132 if (!alloc)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
133 {
479
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
134 alloc = DtoAlloca(c->getType(), ".assertmsg");
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
135 DtoSetArray(alloc, DtoArrayLen(s), DtoArrayPtr(s));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
136 gIR->func()->msgArg = alloc;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
137 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
138 args.push_back(alloc);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
139 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
140 else
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
141 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
142 args.push_back(msg->getRVal());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
143 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
144 palist = palist.addAttr(idx++, llvm::ParamAttr::ByVal);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
145 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
146
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
147 // file param
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
148 llvm::AllocaInst* alloc = gIR->func()->srcfileArg;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
149 if (!alloc)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
150 {
479
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
151 alloc = DtoAlloca(c->getType(), ".srcfile");
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
152 gIR->func()->srcfileArg = alloc;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
153 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
154 LLValue* ptr = DtoGEPi(alloc, 0,0, "tmp");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
155 DtoStore(c->getOperand(0), ptr);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
156 ptr = DtoGEPi(alloc, 0,1, "tmp");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
157 DtoStore(c->getOperand(1), ptr);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
158
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
159 args.push_back(alloc);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
160 palist = palist.addAttr(idx++, llvm::ParamAttr::ByVal);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
161
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
162
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
163 // line param
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
164 c = DtoConstUint(loc->linnum);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
165 args.push_back(c);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
166
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
167 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
168 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
169 call->setParamAttrs(palist);
291
068cb3c60afb [svn r312] Changed assert codegen to insert an unreachable terminator after the call to the assert function, which currently calls abort().
lindquist
parents: 290
diff changeset
170
068cb3c60afb [svn r312] Changed assert codegen to insert an unreachable terminator after the call to the assert function, which currently calls abort().
lindquist
parents: 290
diff changeset
171 // after assert is always unreachable
068cb3c60afb [svn r312] Changed assert codegen to insert an unreachable terminator after the call to the assert function, which currently calls abort().
lindquist
parents: 290
diff changeset
172 gIR->ir->CreateUnreachable();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
173 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
174
439
47b64d06eb9f Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents: 435
diff changeset
175
47b64d06eb9f Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents: 435
diff changeset
176 /****************************************************************************************/
47b64d06eb9f Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents: 435
diff changeset
177 /*////////////////////////////////////////////////////////////////////////////////////////
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
178 // LABEL HELPER
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
179 ////////////////////////////////////////////////////////////////////////////////////////*/
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
180 LabelStatement* DtoLabelStatement(Identifier* ident)
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
181 {
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
182 FuncDeclaration* fd = gIR->func()->decl;
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
183 FuncDeclaration::LabelMap::iterator iter = fd->labmap.find(ident->toChars());
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
184 if (iter == fd->labmap.end())
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
185 {
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
186 if (fd->returnLabel && fd->returnLabel->ident->equals(ident))
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
187 {
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
188 assert(fd->returnLabel->statement);
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
189 return fd->returnLabel->statement;
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
190 }
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
191 return NULL;
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
192 }
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
193 return iter->second;
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
194 }
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
195
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
196 /****************************************************************************************/
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
197 /*////////////////////////////////////////////////////////////////////////////////////////
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
198 // GOTO HELPER
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
199 ////////////////////////////////////////////////////////////////////////////////////////*/
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: 355
diff changeset
200 void DtoGoto(Loc* loc, Identifier* target, EnclosingHandler* enclosinghandler, TryFinallyStatement* sourcetf)
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
201 {
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
202 assert(!gIR->scopereturned());
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
203
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
204 LabelStatement* lblstmt = DtoLabelStatement(target);
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
205 if(!lblstmt) {
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
206 error(*loc, "the label %s does not exist", target->toChars());
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
207 fatal();
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
208 }
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
209
304
3ebc136702dd [svn r325] Removed dead code.
ChristianK
parents: 302
diff changeset
210 // if the target label is inside inline asm, error
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
211 if(lblstmt->asmLabel) {
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
212 error(*loc, "cannot goto to label %s inside an inline asm block", target->toChars());
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
213 fatal();
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
214 }
304
3ebc136702dd [svn r325] Removed dead code.
ChristianK
parents: 302
diff changeset
215
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 339
diff changeset
216 // find target basic block
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
217 std::string labelname = gIR->func()->getScopedLabelName(target->toChars());
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 339
diff changeset
218 llvm::BasicBlock*& targetBB = gIR->func()->labelToBB[labelname];
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 339
diff changeset
219 if (targetBB == NULL)
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 339
diff changeset
220 targetBB = llvm::BasicBlock::Create("label", gIR->topfunc());
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
221
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
222 // find finallys between goto and label
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
223 EnclosingHandler* endfinally = enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
224 while(endfinally != NULL && endfinally != lblstmt->enclosinghandler) {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
225 endfinally = endfinally->getEnclosing();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
226 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
227
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
228 // error if didn't find tf statement of label
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
229 if(endfinally != lblstmt->enclosinghandler)
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
230 error(*loc, "cannot goto into try block");
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
231
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
232 // goto into finally blocks is forbidden by the spec
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
233 // though it should not be problematic to implement
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
234 if(lblstmt->tf != sourcetf) {
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
235 error(*loc, "spec disallows goto into finally block");
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
236 fatal();
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
237 }
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
238
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
239 // emit code for finallys between goto and label
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
240 DtoEnclosingHandlers(enclosinghandler, endfinally);
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
241
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 339
diff changeset
242 llvm::BranchInst::Create(targetBB, gIR->scopebb());
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
243 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
244
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
245 /****************************************************************************************/
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
246 /*////////////////////////////////////////////////////////////////////////////////////////
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
247 // TRY-FINALLY, VOLATILE AND SYNCHRONIZED HELPER
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
248 ////////////////////////////////////////////////////////////////////////////////////////*/
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
249
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
250 void EnclosingSynchro::emitCode(IRState * p)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
251 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
252 if (s->exp)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
253 DtoLeaveMonitor(s->llsync);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
254 else
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
255 DtoLeaveCritical(s->llsync);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
256 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
257
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
258 EnclosingHandler* EnclosingSynchro::getEnclosing()
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
259 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
260 return s->enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
261 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
262
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
263 ////////////////////////////////////////////////////////////////////////////////////////
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
264
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
265 void EnclosingVolatile::emitCode(IRState * p)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
266 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
267 // store-load barrier
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
268 DtoMemoryBarrier(false, false, true, false);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
269 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
270
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
271 EnclosingHandler* EnclosingVolatile::getEnclosing()
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
272 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
273 return v->enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
274 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
275
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
276 ////////////////////////////////////////////////////////////////////////////////////////
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
277
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
278 void EnclosingTryFinally::emitCode(IRState * p)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
279 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
280 assert(tf->finalbody);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
281 tf->finalbody->toIR(p);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
282 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
283
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
284 EnclosingHandler* EnclosingTryFinally::getEnclosing()
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
285 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
286 return tf->enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
287 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
288
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
289 ////////////////////////////////////////////////////////////////////////////////////////
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
290
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
291 void DtoEnclosingHandlers(EnclosingHandler* start, EnclosingHandler* end)
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
292 {
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
293 // verify that end encloses start
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
294 EnclosingHandler* endfinally = start;
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
295 while(endfinally != NULL && endfinally != end) {
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
296 endfinally = endfinally->getEnclosing();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
297 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
298 assert(endfinally == end);
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
299
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
300
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
301 //
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
302 // emit code for finallys between start and end
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
303 //
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
304
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
305 // since the labelstatements possibly inside are private
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
306 // and might already exist push a label scope
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
307 gIR->func()->pushUniqueLabelScope("enclosing");
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
308 EnclosingHandler* tf = start;
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
309 while(tf != end) {
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
310 tf->emitCode(gIR);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
311 tf = tf->getEnclosing();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
312 }
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
313 gIR->func()->popLabelScope();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
314 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
315
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
316 /****************************************************************************************/
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
317 /*////////////////////////////////////////////////////////////////////////////////////////
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
318 // SYNCHRONIZED SECTION HELPERS
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
319 ////////////////////////////////////////////////////////////////////////////////////////*/
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
320
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
321 void DtoEnterCritical(LLValue* g)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
322 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
323 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalenter");
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
324 gIR->CreateCallOrInvoke(fn, g);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
325 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
326
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
327 void DtoLeaveCritical(LLValue* g)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
328 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
329 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalexit");
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
330 gIR->CreateCallOrInvoke(fn, g);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
331 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
332
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
333 void DtoEnterMonitor(LLValue* v)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
334 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
335 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorenter");
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
336 v = DtoBitCast(v, fn->getFunctionType()->getParamType(0));
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
337 gIR->CreateCallOrInvoke(fn, v);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
338 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
339
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
340 void DtoLeaveMonitor(LLValue* v)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
341 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
342 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorexit");
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
343 v = DtoBitCast(v, fn->getFunctionType()->getParamType(0));
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
344 gIR->CreateCallOrInvoke(fn, v);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
345 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
346
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
347 /****************************************************************************************/
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
348 /*////////////////////////////////////////////////////////////////////////////////////////
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
349 // NESTED VARIABLE HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
350 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
351
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
352 DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd)
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
353 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
354 Dsymbol* vdparent = vd->toParent2();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
355 assert(vdparent);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
356
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
357 IrFunction* irfunc = gIR->func();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
358
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
359 // is the nested variable in this scope?
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
360 if (vdparent == irfunc->decl)
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
361 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
362 LLValue* val = vd->ir.getIrValue();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
363 return new DVarValue(astype, vd, val, true);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
364 }
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
365
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
366 // get it from the nested context
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
367 LLValue* ctx = 0;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
368 if (irfunc->decl->isMember2())
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
369 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
370 ClassDeclaration* cd = irfunc->decl->isMember2()->isClassDeclaration();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
371 LLValue* val = DtoLoad(irfunc->thisArg);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
372 ctx = DtoLoad(DtoGEPi(val, 0,2+cd->vthis->ir.irField->index, ".vthis"));
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
373 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
374 else
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
375 ctx = irfunc->nestArg;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
376 assert(ctx);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
377
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
378 assert(vd->ir.irLocal);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
379 LLValue* val = DtoBitCast(ctx, getPtrToType(getVoidPtrType()));
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
380 val = DtoGEPi1(val, vd->ir.irLocal->nestedIndex);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
381 val = DtoLoad(val);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
382 assert(vd->ir.irLocal->value);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
383 val = DtoBitCast(val, vd->ir.irLocal->value->getType(), vd->toChars());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
384 return new DVarValue(astype, vd, val, true);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
385 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
386
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
387 LLValue* DtoNestedContext(Loc loc, Dsymbol* sym)
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
388 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
389 Logger::println("DtoNestedContext for %s", sym->toPrettyChars());
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
390 LOG_SCOPE;
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
391
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
392 IrFunction* irfunc = gIR->func();
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
393
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
394 if (irfunc->nestedVar)
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
395 return irfunc->nestedVar;
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
396 else if (irfunc->nestArg)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
397 return irfunc->nestArg;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
398 else if (irfunc->thisArg)
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
399 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
400 ClassDeclaration* cd = irfunc->decl->isMember2()->isClassDeclaration();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
401 assert(cd);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
402 if (!cd->vthis)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
403 return getNullPtr(getVoidPtrType());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
404 LLValue* val = DtoLoad(irfunc->thisArg);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
405 return DtoLoad(DtoGEPi(val, 0,2+cd->vthis->ir.irField->index, ".vthis"));
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
406 }
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
407 else
453
60332cd85308 Fixed regressions
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 452
diff changeset
408 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
409 if (irfunc->decl->isStatic())
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
410 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
411 irfunc->decl->error("is static and cannot access nested %s %s", sym->kind(), sym->toChars());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
412 fatal();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
413 }
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
414 return getNullPtr(getVoidPtrType());
453
60332cd85308 Fixed regressions
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 452
diff changeset
415 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
416 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
417
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
418 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
419 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
420 // ASSIGNMENT HELPER (store this in that)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
421 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
422
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
423 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
424 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
425 Logger::cout() << "DtoAssign(...);\n";
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
426 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
427
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
428 Type* t = lhs->getType()->toBasetype();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
429 Type* t2 = rhs->getType()->toBasetype();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
430
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
431 if (t->ty == Tstruct) {
295
895e1b50cf2a [svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents: 294
diff changeset
432 if (!t->equals(t2)) {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
433 // TODO: fix this, use 'rhs' for something
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
434 DtoAggrZeroInit(lhs->getLVal());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
435 }
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
436 else {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
437 DtoAggrCopy(lhs->getLVal(), rhs->getRVal());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
438 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
439 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
440 else if (t->ty == Tarray) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
441 // lhs is slice
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
442 if (DSliceValue* s = lhs->isSlice()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
443 if (DSliceValue* s2 = rhs->isSlice()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
444 DtoArrayCopySlices(s, s2);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
445 }
358
051f5b550d9c [svn r379] Fix slice assigns of the form T[] = T when T is a typedef.
ChristianK
parents: 357
diff changeset
446 else if (t->next->toBasetype()->equals(t2)) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
447 DtoArrayInit(loc, s, rhs);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
448 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
449 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
450 DtoArrayCopyToSlice(s, rhs);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
451 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
452 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
453 // rhs is slice
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
454 else if (DSliceValue* s = rhs->isSlice()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
455 assert(s->getType()->toBasetype() == lhs->getType()->toBasetype());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
456 DtoSetArray(lhs->getLVal(),DtoArrayLen(s),DtoArrayPtr(s));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
457 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
458 // null
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
459 else if (rhs->isNull()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
460 DtoSetArrayToNull(lhs->getLVal());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
461 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
462 // reference assignment
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
463 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
464 DtoArrayAssign(lhs->getLVal(), rhs->getRVal());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
465 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
466 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
467 else if (t->ty == Tsarray) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
468 if (DtoType(lhs->getType()) == DtoType(rhs->getType())) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
469 DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
470 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
471 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
472 DtoArrayInit(loc, lhs, rhs);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
473 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
474 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
475 else if (t->ty == Tdelegate) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
476 if (rhs->isNull())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
477 DtoAggrZeroInit(lhs->getLVal());
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
478 else {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
479 LLValue* l = lhs->getLVal();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
480 LLValue* r = rhs->getRVal();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
481 Logger::cout() << "assign\nlhs: " << *l << "rhs: " << *r << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
482 DtoAggrCopy(l, r);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
483 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
484 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
485 else if (t->ty == Tclass) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
486 assert(t2->ty == Tclass);
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
487 LLValue* l = lhs->getLVal();
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
488 LLValue* r = rhs->getRVal();
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
489 Logger::cout() << "l : " << *l << '\n';
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
490 Logger::cout() << "r : " << *r << '\n';
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
491 r = DtoBitCast(r, l->getType()->getContainedType(0));
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
492 DtoStore(r, l);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
493 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
494 else if (t->iscomplex()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
495 assert(!lhs->isComplex());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
496
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
497 LLValue* dst;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
498 if (DLRValue* lr = lhs->isLRValue()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
499 dst = lr->getLVal();
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
500 rhs = DtoCastComplex(loc, rhs, lr->getLType());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
501 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
502 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
503 dst = lhs->getRVal();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
504 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
505
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
506 if (DComplexValue* cx = rhs->isComplex())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
507 DtoComplexSet(dst, cx->re, cx->im);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
508 else
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
509 DtoComplexAssign(dst, rhs->getRVal());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
510 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
511 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
512 LLValue* l = lhs->getLVal();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
513 LLValue* r = rhs->getRVal();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
514 Logger::cout() << "assign\nlhs: " << *l << "rhs: " << *r << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
515 const LLType* lit = l->getType()->getContainedType(0);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
516 if (r->getType() != lit) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
517 // handle lvalue cast assignments
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
518 if (DLRValue* lr = lhs->isLRValue()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
519 Logger::println("lvalue cast!");
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
520 r = DtoCast(loc, rhs, lr->getLType())->getRVal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
521 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
522 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
523 r = DtoCast(loc, rhs, lhs->getType())->getRVal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
524 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
525 Logger::cout() << "really assign\nlhs: " << *l << "rhs: " << *r << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
526 assert(r->getType() == l->getType()->getContainedType(0));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
527 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
528 gIR->ir->CreateStore(r, l);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
529 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
530 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
531
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
532 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
533 /*////////////////////////////////////////////////////////////////////////////////////////
372
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
534 // NULL VALUE HELPER
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
535 ////////////////////////////////////////////////////////////////////////////////////////*/
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
536
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
537 DValue* DtoNullValue(Type* type)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
538 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
539 Type* basetype = type->toBasetype();
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
540 TY basety = basetype->ty;
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
541 const LLType* lltype = DtoType(basetype);
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
542
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
543 // complex, needs to be first since complex are also floating
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
544 if (basetype->iscomplex())
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
545 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
546 const LLType* basefp = DtoComplexBaseType(basetype);
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
547 return new DComplexValue(type, LLConstant::getNullValue(basefp), LLConstant::getNullValue(basefp));
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
548 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
549 // integer, floating, pointer and class have no special representation
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
550 else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
551 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
552 return new DConstValue(type, LLConstant::getNullValue(lltype));
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
553 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
554 // dynamic array
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
555 else if (basety == Tarray)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
556 {
373
d1574e142e93 [svn r394] Fixed the new DtoNullValue function
lindquist
parents: 372
diff changeset
557 LLValue* len = DtoConstSize_t(0);
d1574e142e93 [svn r394] Fixed the new DtoNullValue function
lindquist
parents: 372
diff changeset
558 LLValue* ptr = getNullPtr(getPtrToType(DtoType(basetype->next)));
d1574e142e93 [svn r394] Fixed the new DtoNullValue function
lindquist
parents: 372
diff changeset
559 return new DSliceValue(type, len, ptr);
372
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
560 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
561 // delegate
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
562 else if (basety == Tdelegate)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
563 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
564 return new DNullValue(type, LLConstant::getNullValue(lltype));
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
565 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
566
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
567 // unknown
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
568 std::cout << "unsupported: null value for " << type->toChars() << '\n';
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
569 assert(0);
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
570 return 0;
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
571
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
572 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
573
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
574
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
575 /****************************************************************************************/
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
576 /*////////////////////////////////////////////////////////////////////////////////////////
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
577 // CASTING HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
578 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
579
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
580 DValue* DtoCastInt(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
581 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
582 const LLType* tolltype = DtoType(_to);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
583
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
584 Type* to = _to->toBasetype();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
585 Type* from = val->getType()->toBasetype();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
586 assert(from->isintegral());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
587
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
588 size_t fromsz = from->size();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
589 size_t tosz = to->size();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
590
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
591 LLValue* rval = val->getRVal();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
592 if (rval->getType() == tolltype) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
593 return new DImValue(_to, rval);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
594 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
595
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
596 if (to->isintegral()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
597 if (fromsz < tosz) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
598 Logger::cout() << "cast to: " << *tolltype << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
599 if (from->isunsigned() || from->ty == Tbool) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
600 rval = new llvm::ZExtInst(rval, tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
601 } else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
602 rval = new llvm::SExtInst(rval, tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
603 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
604 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
605 else if (fromsz > tosz) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
606 rval = new llvm::TruncInst(rval, tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
607 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
608 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
609 rval = DtoBitCast(rval, tolltype);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
610 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
611 }
359
926f65e39246 [svn r380] Improve complex number support.
ChristianK
parents: 358
diff changeset
612 else if (to->iscomplex()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
613 return DtoComplex(loc, to, val);
359
926f65e39246 [svn r380] Improve complex number support.
ChristianK
parents: 358
diff changeset
614 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
615 else if (to->isfloating()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
616 if (from->isunsigned()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
617 rval = new llvm::UIToFPInst(rval, tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
618 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
619 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
620 rval = new llvm::SIToFPInst(rval, tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
621 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
622 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
623 else if (to->ty == Tpointer) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
624 Logger::cout() << "cast pointer: " << *tolltype << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
625 rval = gIR->ir->CreateIntToPtr(rval, tolltype, "tmp");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
626 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
627 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
628 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), _to->toChars());
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
629 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
630 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
631
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
632 return new DImValue(_to, rval);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
633 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
634
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
635 DValue* DtoCastPtr(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
636 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
637 const LLType* tolltype = DtoType(to);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
638
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
639 Type* totype = to->toBasetype();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
640 Type* fromtype = val->getType()->toBasetype();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
641 assert(fromtype->ty == Tpointer || fromtype->ty == Tfunction);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
642
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
643 LLValue* rval;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
644
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
645 if (totype->ty == Tpointer || totype->ty == Tclass) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
646 LLValue* src = val->getRVal();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
647 Logger::cout() << "src: " << *src << "to type: " << *tolltype << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
648 rval = DtoBitCast(src, tolltype);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
649 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
650 else if (totype->isintegral()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
651 rval = new llvm::PtrToIntInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
652 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
653 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
654 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
655 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
656 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
657
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
658 return new DImValue(to, rval);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
659 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
660
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
661 DValue* DtoCastFloat(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
662 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
663 if (val->getType() == to)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
664 return val;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
665
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
666 const LLType* tolltype = DtoType(to);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
667
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
668 Type* totype = to->toBasetype();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
669 Type* fromtype = val->getType()->toBasetype();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
670 assert(fromtype->isfloating());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
671
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
672 size_t fromsz = fromtype->size();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
673 size_t tosz = totype->size();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
674
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
675 LLValue* rval;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
676
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
677 if (totype->iscomplex()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
678 return DtoComplex(loc, to, val);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
679 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
680 else if (totype->isfloating()) {
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 442
diff changeset
681 if (fromsz == tosz) {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
682 rval = val->getRVal();
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 442
diff changeset
683 assert(rval->getType() == tolltype);
359
926f65e39246 [svn r380] Improve complex number support.
ChristianK
parents: 358
diff changeset
684 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
685 else if (fromsz < tosz) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
686 rval = new llvm::FPExtInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
687 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
688 else if (fromsz > tosz) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
689 rval = new llvm::FPTruncInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
690 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
691 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
692 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
693 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
694 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
695 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
696 else if (totype->isintegral()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
697 if (totype->isunsigned()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
698 rval = new llvm::FPToUIInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
699 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
700 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
701 rval = new llvm::FPToSIInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
702 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
703 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
704 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
705 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
706 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
707 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
708
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
709 return new DImValue(to, rval);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
710 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
711
419
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
712 DValue* DtoCastDelegate(Loc& loc, DValue* val, Type* to)
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
713 {
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
714 LLValue* res = 0;
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
715 to = to->toBasetype();
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
716
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
717 if (to->ty == Tdelegate)
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
718 {
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
719 const LLType* toll = getPtrToType(DtoType(to));
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
720 res = DtoBitCast(val->getRVal(), toll);
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
721 }
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
722 else
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
723 {
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
724 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
725 fatal();
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
726 }
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
727
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
728 return new DImValue(to, res);
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
729 }
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
730
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
731 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
732 {
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
733 Type* fromtype = val->getType()->toBasetype();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
734 Logger::println("Casting from '%s' to '%s'", fromtype->toChars(), to->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
735 if (fromtype->isintegral()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
736 return DtoCastInt(loc, val, to);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
737 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
738 else if (fromtype->iscomplex()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
739 return DtoCastComplex(loc, val, to);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
740 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
741 else if (fromtype->isfloating()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
742 return DtoCastFloat(loc, val, to);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
743 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
744 else if (fromtype->ty == Tclass) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
745 return DtoCastClass(val, to);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
746 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
747 else if (fromtype->ty == Tarray || fromtype->ty == Tsarray) {
424
c8d98ccad0cc Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
Christian Kamm <kamm incasoftware de>
parents: 419
diff changeset
748 return DtoCastArray(loc, val, to);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
749 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
750 else if (fromtype->ty == Tpointer || fromtype->ty == Tfunction) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
751 return DtoCastPtr(loc, val, to);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
752 }
419
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
753 else if (fromtype->ty == Tdelegate) {
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
754 return DtoCastDelegate(loc, val, to);
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
755 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
756 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
757 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
758 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
759 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
760 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
761
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
762 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
763 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
764 // TEMPLATE HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
765 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
766
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
767 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
768 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
769 if (!s) return false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
770 if (s->isTemplateInstance() && !s->isTemplateMixin())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
771 return true;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
772 else if (s->parent)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
773 return DtoIsTemplateInstance(s->parent);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
774 return false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
775 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
776
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
777 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
778 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
779 // LAZY STATIC INIT HELPER
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
780 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
781
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
782 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
783 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
784 // create a flag to make sure initialization only happens once
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
785 llvm::GlobalValue::LinkageTypes gflaglink = istempl ? llvm::GlobalValue::WeakLinkage : llvm::GlobalValue::InternalLinkage;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
786 std::string gflagname(gvar->getName());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
787 gflagname.append("__initflag");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
788 llvm::GlobalVariable* gflag = new llvm::GlobalVariable(LLType::Int1Ty,false,gflaglink,DtoConstBool(false),gflagname,gIR->module);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
789
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
790 // check flag and do init if not already done
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
791 llvm::BasicBlock* oldend = gIR->scopeend();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
792 llvm::BasicBlock* initbb = llvm::BasicBlock::Create("ifnotinit",gIR->topfunc(),oldend);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
793 llvm::BasicBlock* endinitbb = llvm::BasicBlock::Create("ifnotinitend",gIR->topfunc(),oldend);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
794 LLValue* cond = gIR->ir->CreateICmpEQ(gIR->ir->CreateLoad(gflag,"tmp"),DtoConstBool(false));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
795 gIR->ir->CreateCondBr(cond, initbb, endinitbb);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
796 gIR->scope() = IRScope(initbb,endinitbb);
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
797 DValue* ie = DtoInitializer(gvar, init);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
798
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
799 DVarValue dst(t, gvar, true);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
800 DtoAssign(init->loc, &dst, ie);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
801
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
802 gIR->ir->CreateStore(DtoConstBool(true), gflag);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
803 gIR->ir->CreateBr(endinitbb);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
804 gIR->scope() = IRScope(endinitbb,oldend);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
805 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
806
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
807 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
808 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
809 // PROCESSING QUEUE HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
810 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
811
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
812 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
813 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
814 if (StructDeclaration* sd = dsym->isStructDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
815 DtoResolveStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
816 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
817 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
818 DtoResolveClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
819 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
820 else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
821 DtoResolveFunction(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
822 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
823 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
824 DtoResolveTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
825 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
826 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
827 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
828 assert(0 && "unsupported dsymbol for DtoResolveDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
829 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
830 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
831
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
832 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
833
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
834 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
835 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
836 if (StructDeclaration* sd = dsym->isStructDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
837 DtoDeclareStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
838 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
839 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
840 DtoDeclareClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
841 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
842 else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
843 DtoDeclareFunction(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
844 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
845 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
846 DtoDeclareTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
847 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
848 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
849 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
850 assert(0 && "unsupported dsymbol for DtoDeclareDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
851 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
852 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
853
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
854 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
855
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
856 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
857 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
858 if (StructDeclaration* sd = dsym->isStructDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
859 DtoConstInitStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
860 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
861 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
862 DtoConstInitClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
863 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
864 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
865 DtoConstInitTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
866 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
867 else if (VarDeclaration* vd = dsym->isVarDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
868 DtoConstInitGlobal(vd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
869 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
870 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
871 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
872 assert(0 && "unsupported dsymbol for DtoConstInitDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
873 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
874 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
875
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
876 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
877
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
878 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
879 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
880 if (StructDeclaration* sd = dsym->isStructDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
881 DtoDefineStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
882 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
883 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
884 DtoDefineClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
885 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
886 else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
887 DtoDefineFunc(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
888 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
889 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
890 DtoDefineTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
891 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
892 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
893 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
894 assert(0 && "unsupported dsymbol for DtoDefineDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
895 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
896 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
897
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
898 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
899
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
900 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
901 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
902 if (vd->ir.initialized) return;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
903 vd->ir.initialized = gIR->dmodule;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
904
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
905 Logger::println("* DtoConstInitGlobal(%s)", vd->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
906 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
907
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
908 bool emitRTstaticInit = false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
909
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
910 LLConstant* _init = 0;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
911 if (vd->parent && vd->parent->isFuncDeclaration() && vd->init && vd->init->isExpInitializer()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
912 _init = DtoConstInitializer(vd->type, NULL);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
913 emitRTstaticInit = true;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
914 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
915 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
916 _init = DtoConstInitializer(vd->type, vd->init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
917 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
918
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
919 const LLType* _type = DtoType(vd->type);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
920 Type* t = vd->type->toBasetype();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
921
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
922 //Logger::cout() << "initializer: " << *_init << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
923 if (_type != _init->getType()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
924 Logger::cout() << "got type '" << *_init->getType() << "' expected '" << *_type << "'\n";
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
925 // zero initalizer
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
926 if (_init->isNullValue())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
927 _init = llvm::Constant::getNullValue(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
928 // pointer to global constant (struct.init)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
929 else if (llvm::isa<llvm::GlobalVariable>(_init))
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
930 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
931 assert(_init->getType()->getContainedType(0) == _type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
932 llvm::GlobalVariable* gv = llvm::cast<llvm::GlobalVariable>(_init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
933 assert(t->ty == Tstruct);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
934 TypeStruct* ts = (TypeStruct*)t;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
935 assert(ts->sym->ir.irStruct->constInit);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
936 _init = ts->sym->ir.irStruct->constInit;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
937 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
938 // array single value init
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
939 else if (isaArray(_type))
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
940 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
941 _init = DtoConstStaticArray(_type, _init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
942 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
943 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
944 Logger::cout() << "Unexpected initializer type: " << *_type << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
945 //assert(0);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
946 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
947 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
948
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
949 bool istempl = false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
950 if ((vd->storage_class & STCcomdat) || (vd->parent && DtoIsTemplateInstance(vd->parent))) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
951 istempl = true;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
952 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
953
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
954 if (_init && _init->getType() != _type)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
955 _type = _init->getType();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
956 llvm::cast<LLOpaqueType>(vd->ir.irGlobal->type.get())->refineAbstractTypeTo(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
957 _type = vd->ir.irGlobal->type.get();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
958 //_type->dump();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
959 assert(!_type->isAbstract());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
960
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
961 llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(vd->ir.irGlobal->value);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
962 if (!(vd->storage_class & STCextern) && (vd->getModule() == gIR->dmodule || istempl))
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
963 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
964 gvar->setInitializer(_init);
250
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
965 // do debug info
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
966 if (global.params.symdebug)
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
967 {
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
968 LLGlobalVariable* gv = DtoDwarfGlobalVariable(gvar, vd);
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
969 // keep a reference so GDCE doesn't delete it !
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
970 gIR->usedArray.push_back(llvm::ConstantExpr::getBitCast(gv, getVoidPtrType()));
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
971 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
972 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
973
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
974 if (emitRTstaticInit)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
975 DtoLazyStaticInit(istempl, gvar, vd->init, t);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
976 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
977
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
978 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
979
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
980 void DtoEmptyResolveList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
981 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
982 //Logger::println("DtoEmptyResolveList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
983 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
984 while (!gIR->resolveList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
985 dsym = gIR->resolveList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
986 gIR->resolveList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
987 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
988 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
989 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
990
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
991 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
992
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
993 void DtoEmptyDeclareList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
994 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
995 //Logger::println("DtoEmptyDeclareList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
996 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
997 while (!gIR->declareList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
998 dsym = gIR->declareList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
999 gIR->declareList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1000 DtoDeclareDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1001 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1002 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1003
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1004 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1005
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1006 void DtoEmptyConstInitList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1007 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1008 //Logger::println("DtoEmptyConstInitList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1009 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1010 while (!gIR->constInitList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1011 dsym = gIR->constInitList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1012 gIR->constInitList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1013 DtoConstInitDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1014 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1015 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1016
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1017 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1018
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1019 void DtoEmptyDefineList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1020 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1021 //Logger::println("DtoEmptyDefineList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1022 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1023 while (!gIR->defineList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1024 dsym = gIR->defineList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1025 gIR->defineList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1026 DtoDefineDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1027 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1028 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1029
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1030 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1031 void DtoEmptyAllLists()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1032 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1033 for(;;)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1034 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1035 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1036 if (!gIR->resolveList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1037 dsym = gIR->resolveList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1038 gIR->resolveList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1039 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1040 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1041 else if (!gIR->declareList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1042 dsym = gIR->declareList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1043 gIR->declareList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1044 DtoDeclareDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1045 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1046 else if (!gIR->constInitList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1047 dsym = gIR->constInitList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1048 gIR->constInitList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1049 DtoConstInitDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1050 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1051 else if (!gIR->defineList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1052 dsym = gIR->defineList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1053 gIR->defineList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1054 DtoDefineDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1055 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1056 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1057 break;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1058 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1059 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1060 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1061
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1062 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1063
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1064 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
1065 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1066 if (dsym->ir.declared) return;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1067 Logger::println("DtoForceDeclareDsymbol(%s)", dsym->toPrettyChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1068 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1069 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1070
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1071 DtoEmptyResolveList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1072
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1073 DtoDeclareDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1074 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1075
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1076 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1077
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1078 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
1079 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1080 if (dsym->ir.initialized) return;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1081 Logger::println("DtoForceConstInitDsymbol(%s)", dsym->toPrettyChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1082 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1083 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1084
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1085 DtoEmptyResolveList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1086 DtoEmptyDeclareList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1087
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1088 DtoConstInitDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1089 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1090
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1091 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1092
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1093 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
1094 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1095 if (dsym->ir.defined) return;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1096 Logger::println("DtoForceDefineDsymbol(%s)", dsym->toPrettyChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1097 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1098 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1099
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1100 DtoEmptyResolveList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1101 DtoEmptyDeclareList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1102 DtoEmptyConstInitList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1103
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1104 DtoDefineDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1105 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1106
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1107 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1108 /*////////////////////////////////////////////////////////////////////////////////////////
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1109 // DECLARATION EXP HELPER
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1110 ////////////////////////////////////////////////////////////////////////////////////////*/
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1111 DValue* DtoDeclarationExp(Dsymbol* declaration)
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1112 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1113 Logger::print("DtoDeclarationExp: %s\n", declaration->toChars());
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1114 LOG_SCOPE;
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1115
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1116 // variable declaration
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1117 if (VarDeclaration* vd = declaration->isVarDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1118 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1119 Logger::println("VarDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1120
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1121 // static
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1122 if (vd->isDataseg())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1123 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1124 vd->toObjFile(0); // TODO: multiobj
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1125 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1126 else
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1127 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1128 if (global.params.llvmAnnotate)
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1129 DtoAnnotation(declaration->toChars());
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1130
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1131 Logger::println("vdtype = %s", vd->type->toChars());
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1132
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1133 // referenced by nested delegate?
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1134 if (vd->nestedref) {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1135 Logger::println("has nestedref set");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1136 assert(vd->ir.irLocal);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1137
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1138 // alloca as usual is no value already
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1139 if (!vd->ir.irLocal->value)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1140 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1141 vd->ir.irLocal->value = DtoAlloca(DtoType(vd->type), vd->toChars());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1142 }
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1143
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1144 // store the address into the nested vars array
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1145
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1146 assert(vd->ir.irLocal->nestedIndex >= 0);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1147 LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, vd->ir.irLocal->nestedIndex);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1148
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1149 assert(isaPointer(vd->ir.irLocal->value));
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1150 LLValue* val = DtoBitCast(vd->ir.irLocal->value, getVoidPtrType());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1151
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1152 DtoStore(val, gep);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1153
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1154 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1155 // normal stack variable, allocate storage on the stack if it has not already been done
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1156 else if(!vd->ir.irLocal) {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1157 const LLType* lltype = DtoType(vd->type);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1158
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1159 llvm::Value* allocainst;
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1160 if(gTargetData->getTypeSizeInBits(lltype) == 0)
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1161 allocainst = llvm::ConstantPointerNull::get(getPtrToType(lltype));
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1162 else
479
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
1163 allocainst = DtoAlloca(lltype, vd->toChars());
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1164
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1165 //allocainst->setAlignment(vd->type->alignsize()); // TODO
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1166 vd->ir.irLocal = new IrLocal(vd);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1167 vd->ir.irLocal->value = allocainst;
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1168
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1169 if (global.params.symdebug)
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1170 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1171 DtoDwarfLocalVariable(allocainst, vd);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1172 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1173 }
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1174 else
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1175 {
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1176 assert(vd->ir.irLocal->value);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1177 }
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1178
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1179 Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n';
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1180 DValue* ie = DtoInitializer(vd->ir.irLocal->value, vd->init);
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1181 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1182
435
74101be2a553 Added type param to DVarValue as DMD sometimes overrides the type of the VarDeclaration.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 433
diff changeset
1183 return new DVarValue(vd->type, vd, vd->ir.getIrValue(), true);
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1184 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1185 // struct declaration
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1186 else if (StructDeclaration* s = declaration->isStructDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1187 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1188 Logger::println("StructDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1189 DtoForceConstInitDsymbol(s);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1190 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1191 // function declaration
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1192 else if (FuncDeclaration* f = declaration->isFuncDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1193 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1194 Logger::println("FuncDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1195 DtoForceDeclareDsymbol(f);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1196 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1197 // alias declaration
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1198 else if (AliasDeclaration* a = declaration->isAliasDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1199 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1200 Logger::println("AliasDeclaration - no work");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1201 // do nothing
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1202 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1203 // enum
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1204 else if (EnumDeclaration* e = declaration->isEnumDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1205 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1206 Logger::println("EnumDeclaration - no work");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1207 // do nothing
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1208 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1209 // class
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1210 else if (ClassDeclaration* e = declaration->isClassDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1211 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1212 Logger::println("ClassDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1213 DtoForceConstInitDsymbol(e);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1214 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1215 // typedef
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1216 else if (TypedefDeclaration* tdef = declaration->isTypedefDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1217 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1218 Logger::println("TypedefDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1219 DtoTypeInfoOf(tdef->type, false);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1220 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1221 // attribute declaration
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1222 else if (AttribDeclaration* a = declaration->isAttribDeclaration())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1223 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1224 Logger::println("AttribDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1225 for (int i=0; i < a->decl->dim; ++i)
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1226 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1227 DtoForceDeclareDsymbol((Dsymbol*)a->decl->data[i]);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1228 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1229 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1230 // mixin declaration
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1231 else if (TemplateMixin* m = declaration->isTemplateMixin())
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1232 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1233 Logger::println("TemplateMixin");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1234 for (int i=0; i < m->members->dim; ++i)
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1235 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1236 Dsymbol* mdsym = (Dsymbol*)m->members->data[i];
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1237 DtoDeclarationExp(mdsym);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1238 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1239 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1240 // unsupported declaration
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1241 else
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1242 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1243 error(declaration->loc, "Unimplemented Declaration type for DeclarationExp. kind: %s", declaration->kind());
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1244 assert(0);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1245 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1246 return NULL;
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1247 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1248
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1249
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1250 /****************************************************************************************/
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1251 /*////////////////////////////////////////////////////////////////////////////////////////
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1252 // INITIALIZER HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1253 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1254
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1255 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
1256 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1257 LLConstant* _init = 0; // may return zero
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1258 if (!init)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1259 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1260 Logger::println("const default initializer for %s", type->toChars());
294
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1261
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1262 if(type->ty == Tsarray)
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1263 {
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1264 Logger::println("type is a static array, building constant array initializer");
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1265 TypeSArray* arrtype = (TypeSArray*)type;
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1266 Type* elemtype = type->next;
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1267
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1268 integer_t arraydim;
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1269 arraydim = arrtype->dim->toInteger();
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1270
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1271 std::vector<LLConstant*> inits(arraydim, elemtype->defaultInit()->toConstElem(gIR));
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1272 const LLArrayType* arrty = LLArrayType::get(DtoType(elemtype),arraydim);
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1273 _init = LLConstantArray::get(arrty, inits);
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1274 }
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1275 else
94435b0ab2dd [svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents: 291
diff changeset
1276 _init = type->defaultInit()->toConstElem(gIR);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1277 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1278 else if (ExpInitializer* ex = init->isExpInitializer())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1279 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1280 Logger::println("const expression initializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1281 _init = ex->exp->toConstElem(gIR);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1282 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1283 else if (StructInitializer* si = init->isStructInitializer())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1284 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1285 Logger::println("const struct initializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1286 _init = DtoConstStructInitializer(si);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1287 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1288 else if (ArrayInitializer* ai = init->isArrayInitializer())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1289 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1290 Logger::println("const array initializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1291 _init = DtoConstArrayInitializer(ai);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1292 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1293 else if (init->isVoidInitializer())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1294 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1295 Logger::println("const void initializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1296 const LLType* ty = DtoType(type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1297 _init = llvm::Constant::getNullValue(ty);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1298 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1299 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1300 Logger::println("unsupported const initializer: %s", init->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1301 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1302 return _init;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1303 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1304
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1305 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1306
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1307 LLConstant* DtoConstFieldInitializer(Type* t, Initializer* init)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1308 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1309 Logger::println("DtoConstFieldInitializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1310 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1311
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1312 const LLType* _type = DtoType(t);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1313
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1314 LLConstant* _init = DtoConstInitializer(t, init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1315 assert(_init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1316 if (_type != _init->getType())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1317 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1318 Logger::cout() << "field init is: " << *_init << " type should be " << *_type << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1319 if (t->ty == Tsarray)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1320 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1321 const LLArrayType* arrty = isaArray(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1322 uint64_t n = arrty->getNumElements();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1323 std::vector<LLConstant*> vals(n,_init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1324 _init = llvm::ConstantArray::get(arrty, vals);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1325 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1326 else if (t->ty == Tarray)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1327 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1328 assert(isaStruct(_type));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1329 _init = llvm::ConstantAggregateZero::get(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1330 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1331 else if (t->ty == Tstruct)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1332 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1333 const LLStructType* structty = isaStruct(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1334 TypeStruct* ts = (TypeStruct*)t;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1335 assert(ts);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1336 assert(ts->sym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1337 assert(ts->sym->ir.irStruct->constInit);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1338 _init = ts->sym->ir.irStruct->constInit;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1339 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1340 else if (t->ty == Tclass)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1341 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1342 _init = llvm::Constant::getNullValue(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1343 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1344 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1345 Logger::println("failed for type %s", t->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1346 assert(0);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1347 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1348 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1349
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1350 return _init;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1351 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1352
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1353 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1354
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1355 DValue* DtoInitializer(LLValue* target, Initializer* init)
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1356 {
328
7086a84ab3d6 [svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents: 315
diff changeset
1357 if (!init)
7086a84ab3d6 [svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents: 315
diff changeset
1358 return 0;
7086a84ab3d6 [svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents: 315
diff changeset
1359 else if (ExpInitializer* ex = init->isExpInitializer())
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1360 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1361 Logger::println("expression initializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1362 assert(ex->exp);
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1363 DValue* res = ex->exp->toElem(gIR);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1364
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1365 assert(llvm::isa<llvm::PointerType>(target->getType()) && "init target must be ptr");
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1366 const LLType* targetty = target->getType()->getContainedType(0);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1367 if(targetty == LLType::X86_FP80Ty)
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1368 {
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1369 Logger::println("setting fp80 padding to zero");
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1370
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1371 LLValue* castv = DtoBitCast(target, getPtrToType(LLType::Int16Ty));
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1372 LLValue* padding = DtoGEPi1(castv, 5);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1373 DtoStore(llvm::Constant::getNullValue(LLType::Int16Ty), padding);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1374 }
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1375 else if(targetty == DtoComplexType(Type::tcomplex80))
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1376 {
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1377 Logger::println("setting complex fp80 padding to zero");
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1378
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1379 LLValue* castv = DtoBitCast(target, getPtrToType(LLType::Int16Ty));
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1380 LLValue* padding = DtoGEPi1(castv, 5);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1381 DtoStore(llvm::Constant::getNullValue(LLType::Int16Ty), padding);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1382 padding = DtoGEPi1(castv, 11);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1383 DtoStore(llvm::Constant::getNullValue(LLType::Int16Ty), padding);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1384 }
483
d86af825e8d9 Forgot return in DtoInitializer
Christian Kamm <kamm incasoftware de>
parents: 482
diff changeset
1385
d86af825e8d9 Forgot return in DtoInitializer
Christian Kamm <kamm incasoftware de>
parents: 482
diff changeset
1386 return res;
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1387 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1388 else if (init->isVoidInitializer())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1389 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1390 // do nothing
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1391 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1392 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1393 Logger::println("unsupported initializer: %s", init->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1394 assert(0);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1395 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1396 return 0;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1397 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1398
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1399
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1400 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1401
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1402 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
1403 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1404 std::string s("CODE: ");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1405 s.append(str);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1406 char* p = &s[0];
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1407 while (*p)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1408 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1409 if (*p == '"')
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1410 *p = '\'';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1411 ++p;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1412 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1413 // create a noop with the code as the result name!
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1414 gIR->ir->CreateAnd(DtoConstSize_t(0),DtoConstSize_t(0),s.c_str());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1415 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1416
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1417 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1418
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1419 LLConstant* DtoTypeInfoOf(Type* type, bool base)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1420 {
290
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1421 type = type->merge(); // needed.. getTypeInfo does the same
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1422 type->getTypeInfo(NULL);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1423 TypeInfoDeclaration* tidecl = type->vtinfo;
290
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1424 assert(tidecl);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1425 DtoForceDeclareDsymbol(tidecl);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1426 assert(tidecl->ir.irGlobal != NULL);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1427 LLConstant* c = isaConstant(tidecl->ir.irGlobal->value);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1428 assert(c != NULL);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1429 if (base)
290
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1430 return llvm::ConstantExpr::getBitCast(c, DtoType(Type::typeinfo->type));
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1431 return c;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1432 }
284
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1433
289
17d3b3236334 [svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents: 284
diff changeset
1434 //////////////////////////////////////////////////////////////////////////////////////////
17d3b3236334 [svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents: 284
diff changeset
1435
284
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1436 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: 250
diff changeset
1437 {
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1438 std::string err_str;
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1439 const llvm::TargetMachineRegistry::entry* e = llvm::TargetMachineRegistry::getClosestTargetForJIT(err_str);
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1440 if (e == 0)
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1441 {
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1442 error("Failed to find a default target machine: %s", err_str.c_str());
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1443 fatal();
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1444 }
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1445 else
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1446 {
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1447 global.params.llvmArch = const_cast<char*>(e->Name);
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1448 }
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
1449 }
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1450
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1451 //////////////////////////////////////////////////////////////////////////////////////////
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1452
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
1453 LLValue* DtoBoolean(Loc& loc, DValue* dval)
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1454 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1455 Type* dtype = dval->getType()->toBasetype();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1456 TY ty = dtype->ty;
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1457
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1458 // integer
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1459 if (dtype->isintegral())
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1460 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1461 LLValue* val = dval->getRVal();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1462 if (val->getType() == LLType::Int1Ty)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1463 return val;
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1464 else {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1465 LLValue* zero = LLConstantInt::get(val->getType(), 0, false);
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1466 return gIR->ir->CreateICmpNE(val, zero, "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1467 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1468 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1469 // complex
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1470 else if (dtype->iscomplex())
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1471 {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
1472 return DtoComplexEquals(loc, TOKnotequal, dval, DtoNullValue(dtype));
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1473 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1474 // floating point
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1475 else if (dtype->isfloating())
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1476 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1477 LLValue* val = dval->getRVal();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1478 LLValue* zero = LLConstant::getNullValue(val->getType());
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1479 return gIR->ir->CreateFCmpONE(val, zero, "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1480 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1481 // pointer/class
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1482 else if (ty == Tpointer || ty == Tclass) {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1483 LLValue* val = dval->getRVal();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1484 LLValue* zero = LLConstant::getNullValue(val->getType());
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
1485 Logger::cout() << "val: " << *val << '\n';
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
1486 Logger::cout() << "zero: " << *zero << '\n';
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1487 return gIR->ir->CreateICmpNE(val, zero, "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1488 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1489 // dynamic array
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1490 else if (ty == Tarray)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1491 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1492 // return (arr.length != 0)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1493 return gIR->ir->CreateICmpNE(DtoArrayLen(dval), DtoConstSize_t(0), "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1494 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1495 // delegate
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1496 else if (ty == Tdelegate)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1497 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1498 // return (dg !is null)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1499 return DtoDelegateEquals(TOKnotequal, dval->getRVal(), NULL);
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1500 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1501 // unknown
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1502 std::cout << "unsupported -> bool : " << dtype->toChars() << '\n';
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1503 assert(0);
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1504 return 0;
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1505 }