Mercurial > projects > ldc
annotate gen/llvmhelpers.cpp @ 383:c028fd91b3b0
.hgignore updates. runminitest stores object files separately.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Wed, 23 Jul 2008 18:53:44 +0200 |
parents | d1574e142e93 |
children | 0e6b4d65d3f8 |
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 | 7 #include "expression.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
8 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
9 #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
|
10 #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
|
11 #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
|
12 #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
|
13 #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
|
14 #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
|
15 #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
|
16 #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
|
17 #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
|
18 #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
|
19 #include "gen/typeinf.h" |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
20 #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
|
21 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
22 /****************************************************************************************/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
23 /*//////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
24 // 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
|
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 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
|
28 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
29 // 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
|
30 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
|
31 // 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
|
32 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
|
33 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
|
34 // call runtime allocator |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
35 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
|
36 // cast |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
37 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
|
38 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
39 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
40 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
|
41 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
42 // 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
|
43 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
|
44 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
45 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
|
46 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
|
47 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
48 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
|
49 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
50 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
51 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
|
52 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
53 // 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
|
54 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
|
55 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
56 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
|
57 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
|
58 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
59 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
|
60 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
61 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
62 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
|
63 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
64 // 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
|
65 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
|
66 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
67 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
|
68 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
|
69 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
70 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
|
71 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
72 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
73 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
|
74 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
75 // 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
|
76 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
|
77 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
82 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
|
83 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
84 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
85 /****************************************************************************************/ |
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 // ASSERT HELPER |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
90 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
|
91 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
92 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
|
93 LLConstant* c; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
94 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
95 // func |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
96 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
|
97 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
|
98 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
99 // param attrs |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
100 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
|
101 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
|
102 |
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
|
103 // 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
|
104 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
|
105 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
106 // msg param |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
107 if (msg) |
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 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
|
110 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
111 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
|
112 if (!alloc) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
113 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
114 alloc = new llvm::AllocaInst(c->getType(), ".assertmsg", gIR->topallocapoint()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
115 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
|
116 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
|
117 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
118 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
|
119 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
120 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
121 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
122 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
|
123 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
124 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
|
125 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
126 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
127 // file param |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
128 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
|
129 if (!alloc) |
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 alloc = new llvm::AllocaInst(c->getType(), ".srcfile", gIR->topallocapoint()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
132 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
|
133 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 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
|
138 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
139 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
|
140 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
|
141 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
142 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
143 // line param |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
144 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
|
145 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
|
146 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
147 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
148 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
|
149 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
|
150 |
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
|
151 // 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
|
152 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
|
153 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
154 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
155 /****************************************************************************************/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
156 /*//////////////////////////////////////////////////////////////////////////////////////// |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
157 // LABEL HELPER |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
158 ////////////////////////////////////////////////////////////////////////////////////////*/ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
159 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
|
160 { |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 { |
357
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
165 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
|
166 { |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
167 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
|
168 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
|
169 } |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
170 return NULL; |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
171 } |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
172 return iter->second; |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
173 } |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
174 |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
175 /****************************************************************************************/ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
176 /*//////////////////////////////////////////////////////////////////////////////////////// |
302 | 177 // GOTO HELPER |
178 ////////////////////////////////////////////////////////////////////////////////////////*/ | |
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
|
179 void DtoGoto(Loc* loc, Identifier* target, EnclosingHandler* enclosinghandler, TryFinallyStatement* sourcetf) |
302 | 180 { |
181 assert(!gIR->scopereturned()); | |
182 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
183 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
|
184 if(!lblstmt) { |
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
185 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
|
186 fatal(); |
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
187 } |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
188 |
304 | 189 // 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
|
190 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
|
191 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
|
192 fatal(); |
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
193 } |
304 | 194 |
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
|
195 // 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
|
196 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
|
197 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
|
198 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
|
199 targetBB = llvm::BasicBlock::Create("label", gIR->topfunc()); |
302 | 200 |
201 // find finallys between goto and label | |
309 | 202 EnclosingHandler* endfinally = enclosinghandler; |
203 while(endfinally != NULL && endfinally != lblstmt->enclosinghandler) { | |
204 endfinally = endfinally->getEnclosing(); | |
302 | 205 } |
206 | |
207 // error if didn't find tf statement of label | |
309 | 208 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
|
209 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
|
210 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
211 // 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
|
212 // 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
|
213 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
|
214 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
|
215 fatal(); |
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
216 } |
302 | 217 |
218 // emit code for finallys between goto and label | |
309 | 219 DtoEnclosingHandlers(enclosinghandler, endfinally); |
302 | 220 |
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
|
221 llvm::BranchInst::Create(targetBB, gIR->scopebb()); |
302 | 222 } |
223 | |
224 /****************************************************************************************/ | |
225 /*//////////////////////////////////////////////////////////////////////////////////////// | |
309 | 226 // TRY-FINALLY, VOLATILE AND SYNCHRONIZED HELPER |
302 | 227 ////////////////////////////////////////////////////////////////////////////////////////*/ |
309 | 228 |
229 void EnclosingSynchro::emitCode(IRState * p) | |
230 { | |
231 if (s->exp) | |
232 DtoLeaveMonitor(s->llsync); | |
233 else | |
234 DtoLeaveCritical(s->llsync); | |
235 } | |
236 | |
237 EnclosingHandler* EnclosingSynchro::getEnclosing() | |
238 { | |
239 return s->enclosinghandler; | |
240 } | |
241 | |
242 //////////////////////////////////////////////////////////////////////////////////////// | |
243 | |
244 void EnclosingVolatile::emitCode(IRState * p) | |
245 { | |
246 // store-load barrier | |
247 DtoMemoryBarrier(false, false, true, false); | |
248 } | |
249 | |
250 EnclosingHandler* EnclosingVolatile::getEnclosing() | |
251 { | |
252 return v->enclosinghandler; | |
253 } | |
254 | |
255 //////////////////////////////////////////////////////////////////////////////////////// | |
256 | |
257 void EnclosingTryFinally::emitCode(IRState * p) | |
258 { | |
259 assert(tf->finalbody); | |
260 tf->finalbody->toIR(p); | |
261 } | |
262 | |
263 EnclosingHandler* EnclosingTryFinally::getEnclosing() | |
264 { | |
265 return tf->enclosinghandler; | |
266 } | |
267 | |
268 //////////////////////////////////////////////////////////////////////////////////////// | |
269 | |
270 void DtoEnclosingHandlers(EnclosingHandler* start, EnclosingHandler* end) | |
302 | 271 { |
272 // verify that end encloses start | |
309 | 273 EnclosingHandler* endfinally = start; |
302 | 274 while(endfinally != NULL && endfinally != end) { |
309 | 275 endfinally = endfinally->getEnclosing(); |
302 | 276 } |
277 assert(endfinally == end); | |
278 | |
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
|
279 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
280 // |
302 | 281 // 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
|
282 // |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
283 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
284 // 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
|
285 // 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
|
286 gIR->func()->pushUniqueLabelScope("enclosing"); |
309 | 287 EnclosingHandler* tf = start; |
302 | 288 while(tf != end) { |
309 | 289 tf->emitCode(gIR); |
290 tf = tf->getEnclosing(); | |
302 | 291 } |
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
|
292 gIR->func()->popLabelScope(); |
302 | 293 } |
294 | |
295 /****************************************************************************************/ | |
296 /*//////////////////////////////////////////////////////////////////////////////////////// | |
309 | 297 // SYNCHRONIZED SECTION HELPERS |
298 ////////////////////////////////////////////////////////////////////////////////////////*/ | |
299 | |
300 void DtoEnterCritical(LLValue* g) | |
301 { | |
302 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
|
303 gIR->CreateCallOrInvoke(fn, g); |
309 | 304 } |
305 | |
306 void DtoLeaveCritical(LLValue* g) | |
307 { | |
308 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
|
309 gIR->CreateCallOrInvoke(fn, g); |
309 | 310 } |
311 | |
312 void DtoEnterMonitor(LLValue* v) | |
313 { | |
314 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorenter"); | |
315 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
|
316 gIR->CreateCallOrInvoke(fn, v); |
309 | 317 } |
318 | |
319 void DtoLeaveMonitor(LLValue* v) | |
320 { | |
321 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorexit"); | |
322 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
|
323 gIR->CreateCallOrInvoke(fn, v); |
309 | 324 } |
325 | |
326 /****************************************************************************************/ | |
327 /*//////////////////////////////////////////////////////////////////////////////////////// | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
328 // 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
|
329 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
330 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
331 static const LLType* get_next_frame_ptr_type(Dsymbol* sc) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
332 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
333 assert(sc->isFuncDeclaration() || sc->isClassDeclaration()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
334 Dsymbol* p = sc->toParent2(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
335 if (!p->isFuncDeclaration() && !p->isClassDeclaration()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
336 Logger::println("unexpected parent symbol found while resolving frame pointer - '%s' kind: '%s'", p->toChars(), p->kind()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
337 assert(p->isFuncDeclaration() || p->isClassDeclaration()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
338 if (FuncDeclaration* fd = p->isFuncDeclaration()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
339 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
340 LLValue* v = fd->ir.irFunc->nestedVar; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
341 assert(v); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
342 return v->getType(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
343 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
344 else if (ClassDeclaration* cd = p->isClassDeclaration()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
345 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
346 return DtoType(cd->type); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
347 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
348 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
349 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
350 Logger::println("symbol: '%s' kind: '%s'", sc->toChars(), sc->kind()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
351 assert(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
352 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
353 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
354 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
355 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
356 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
357 static LLValue* get_frame_ptr_impl(FuncDeclaration* func, Dsymbol* sc, LLValue* v) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
358 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
359 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
360 if (sc == func) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
361 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
362 return v; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
363 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
364 else if (FuncDeclaration* fd = sc->isFuncDeclaration()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
365 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
366 Logger::println("scope is function: %s", fd->toChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
367 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
368 if (fd->toParent2() == func) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
369 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
370 if (!func->ir.irFunc->nestedVar) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
371 return NULL; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
372 return DtoBitCast(v, func->ir.irFunc->nestedVar->getType()); |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
375 v = DtoBitCast(v, get_next_frame_ptr_type(fd)); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
376 Logger::cout() << "v = " << *v << '\n'; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
377 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
378 if (fd->toParent2()->isFuncDeclaration()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
379 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
380 v = DtoGEPi(v, 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
|
381 v = DtoLoad(v); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
382 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
383 else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
384 { |
370
051ab876fe11
[svn r391] Fix classes nested inside functions for real.
ChristianK
parents:
365
diff
changeset
|
385 v = DtoGEPi(v,0,2+cd->vthis->ir.irField->index,"tmp"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
386 v = DtoLoad(v); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
387 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
388 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
389 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
390 assert(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
391 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
392 return get_frame_ptr_impl(func, fd->toParent2(), v); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
393 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
394 else if (ClassDeclaration* cd = sc->isClassDeclaration()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
395 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
396 Logger::println("scope is class: %s", cd->toChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
397 return get_frame_ptr_impl(func, cd->toParent2(), v); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
398 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
399 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
400 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
401 Logger::println("symbol: '%s'", sc->toPrettyChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
402 assert(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
403 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
404 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
405 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
406 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
407 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
408 static LLValue* get_frame_ptr(FuncDeclaration* func) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
409 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
410 Logger::println("Resolving context pointer for nested function: '%s'", func->toPrettyChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
411 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
412 IrFunction* irfunc = gIR->func(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
413 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
414 // in the right scope already |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
415 if (func == irfunc->decl) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
416 return irfunc->decl->ir.irFunc->nestedVar; |
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 // use the 'this' pointer |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
419 LLValue* ptr = irfunc->decl->ir.irFunc->thisVar; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
420 assert(ptr); |
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 // return the fully resolved frame pointer |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
423 ptr = get_frame_ptr_impl(func, irfunc->decl, ptr); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
424 if (ptr) Logger::cout() << "Found context!" << *ptr; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
425 else Logger::cout() << "NULL context!\n"; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
426 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
427 return ptr; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
428 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
429 |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
432 LLValue* DtoNestedContext(FuncDeclaration* func) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
433 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
434 // resolve frame ptr |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
435 LLValue* ptr = get_frame_ptr(func); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
436 Logger::cout() << "Nested context ptr = "; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
437 if (ptr) Logger::cout() << *ptr; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
438 else Logger::cout() << "NULL"; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
439 Logger::cout() << '\n'; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
440 return ptr; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
441 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
442 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
443 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
444 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
445 static void print_frame_worker(VarDeclaration* vd, Dsymbol* par) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
446 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
447 if (vd->toParent2() == par) |
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 Logger::println("found: '%s' kind: '%s'", par->toChars(), par->kind()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
450 return; |
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 Logger::println("diving into: '%s' kind: '%s'", par->toChars(), par->kind()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
454 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
455 print_frame_worker(vd, par->toParent2()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
456 } |
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 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
459 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
460 static void print_nested_frame_list(VarDeclaration* vd, Dsymbol* par) |
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 Logger::println("Frame pointer list for nested var: '%s'", vd->toPrettyChars()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
463 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
464 if (vd->toParent2() != par) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
465 print_frame_worker(vd, par); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
466 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
467 Logger::println("Found at level 0"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
468 Logger::println("Done"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
469 } |
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 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
472 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
473 LLValue* DtoNestedVariable(VarDeclaration* vd) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
474 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
475 // log the frame list |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
476 IrFunction* irfunc = gIR->func(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
477 if (Logger::enabled()) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
478 print_nested_frame_list(vd, irfunc->decl); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
479 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
480 // resolve frame ptr |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
481 FuncDeclaration* func = vd->toParent2()->isFuncDeclaration(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
482 assert(func); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
483 LLValue* ptr = DtoNestedContext(func); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
484 assert(ptr && "nested var, but no context"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
485 |
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
|
486 // if the nested var is a this pointer it's a class member and not a magic struct |
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
|
487 // so we're done here! |
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
|
488 // this happens since 1.033 for some reason... always correct ? |
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
|
489 if (vd->ident == Id::This) |
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
|
490 { |
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
|
491 return ptr; |
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
|
492 } |
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
|
493 |
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
|
494 // handle a "normal" nested variable |
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
|
495 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
496 // we must cast here to be sure. nested classes just have a void* |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
497 ptr = DtoBitCast(ptr, func->ir.irFunc->nestedVar->getType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
498 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
499 // index nested var and load (if necessary) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
500 LLValue* v = DtoGEPi(ptr, 0, vd->ir.irLocal->nestedIndex, "tmp"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
501 // references must be loaded, for normal variables this IS already the variable storage!!! |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
502 if (vd->isParameter() && (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type))) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
503 v = DtoLoad(v); |
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 // log and return |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
506 Logger::cout() << "Nested var ptr = " << *v << '\n'; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
507 return v; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
508 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
509 |
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 /*//////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
512 // 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
|
513 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
514 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
515 void DtoAssign(DValue* lhs, DValue* rhs) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
516 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
517 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
|
518 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
519 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
520 Type* t = DtoDType(lhs->getType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
521 Type* t2 = DtoDType(rhs->getType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
522 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
523 if (t->ty == Tstruct) { |
295
895e1b50cf2a
[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents:
294
diff
changeset
|
524 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
|
525 // 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
|
526 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
|
527 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
528 else if (!rhs->inPlace()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
529 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
|
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 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
|
533 // 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
|
534 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
|
535 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
|
536 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
|
537 } |
358
051f5b550d9c
[svn r379] Fix slice assigns of the form T[] = T when T is a typedef.
ChristianK
parents:
357
diff
changeset
|
538 else if (t->next->toBasetype()->equals(t2)) { |
295
895e1b50cf2a
[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents:
294
diff
changeset
|
539 DtoArrayInit(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
|
540 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
541 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
542 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
|
543 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
544 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
545 // 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
|
546 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
|
547 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
|
548 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
|
549 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
550 // null |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
551 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
|
552 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
|
553 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
554 // reference assignment |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
555 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
556 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
|
557 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
558 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
559 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
|
560 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
|
561 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
|
562 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
563 else { |
295
895e1b50cf2a
[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents:
294
diff
changeset
|
564 DtoArrayInit(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
|
565 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
566 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
567 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
|
568 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
|
569 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
|
570 else if (!rhs->inPlace()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
571 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
|
572 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
|
573 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
|
574 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
|
575 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
576 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
577 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
|
578 assert(t2->ty == Tclass); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
579 // assignment to this in constructor special case |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
580 if (lhs->isThis()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
581 LLValue* tmp = rhs->getRVal(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
582 FuncDeclaration* fdecl = gIR->func()->decl; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
583 // respecify the this param |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
584 if (!llvm::isa<llvm::AllocaInst>(fdecl->ir.irFunc->thisVar)) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
585 fdecl->ir.irFunc->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
586 DtoStore(tmp, fdecl->ir.irFunc->thisVar); |
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 // regular class ref -> class ref assignment |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
589 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
590 DtoStore(rhs->getRVal(), lhs->getLVal()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
591 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
592 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
593 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
|
594 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
|
595 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
596 LLValue* dst; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
597 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
|
598 dst = lr->getLVal(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
599 rhs = DtoCastComplex(rhs, lr->getLType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
600 } |
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 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
|
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 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
|
606 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
|
607 else |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
608 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
|
609 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
610 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
611 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
|
612 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
|
613 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
|
614 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
|
615 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
|
616 // 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
|
617 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
|
618 Logger::println("lvalue cast!"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
619 r = DtoCast(rhs, lr->getLType())->getRVal(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
620 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
621 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
622 r = DtoCast(rhs, lhs->getType())->getRVal(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
623 } |
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() << "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
|
625 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
|
626 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
627 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
|
628 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
629 } |
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 /*//////////////////////////////////////////////////////////////////////////////////////// |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
633 // NULL VALUE HELPER |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
634 ////////////////////////////////////////////////////////////////////////////////////////*/ |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
635 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
636 DValue* DtoNullValue(Type* type) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
637 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
638 Type* basetype = type->toBasetype(); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
639 TY basety = basetype->ty; |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
640 const LLType* lltype = DtoType(basetype); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
641 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
642 // complex, needs to be first since complex are also floating |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
643 if (basetype->iscomplex()) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
644 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
645 const LLType* basefp = DtoComplexBaseType(basetype); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
646 return new DComplexValue(type, LLConstant::getNullValue(basefp), LLConstant::getNullValue(basefp)); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
647 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
648 // integer, floating, pointer and class have no special representation |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
649 else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
650 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
651 return new DConstValue(type, LLConstant::getNullValue(lltype)); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
652 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
653 // dynamic array |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
654 else if (basety == Tarray) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
655 { |
373 | 656 LLValue* len = DtoConstSize_t(0); |
657 LLValue* ptr = getNullPtr(getPtrToType(DtoType(basetype->next))); | |
658 return new DSliceValue(type, len, ptr); | |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
659 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
660 // delegate |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
661 else if (basety == Tdelegate) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
662 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
663 return new DNullValue(type, LLConstant::getNullValue(lltype)); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
664 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
665 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
666 // unknown |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
667 std::cout << "unsupported: null value for " << type->toChars() << '\n'; |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
668 assert(0); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
669 return 0; |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
670 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
671 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
672 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
673 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
674 /****************************************************************************************/ |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
675 /*//////////////////////////////////////////////////////////////////////////////////////// |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
676 // CASTING HELPERS |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
677 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
678 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
679 DValue* DtoCastInt(DValue* val, Type* _to) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
680 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
681 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
|
682 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
683 Type* to = DtoDType(_to); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
684 Type* from = DtoDType(val->getType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
685 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
|
686 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
687 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
|
688 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
|
689 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
690 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
|
691 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
|
692 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
|
693 } |
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 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
|
696 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
|
697 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
|
698 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
|
699 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
|
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::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
|
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 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
|
705 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
|
706 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
707 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
708 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
|
709 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
710 } |
359 | 711 else if (to->iscomplex()) { |
712 return DtoComplex(to, val); | |
713 } | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
714 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
|
715 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
|
716 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
|
717 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
718 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
719 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
|
720 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
721 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
722 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
|
723 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
|
724 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
|
725 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
726 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
727 assert(0 && "bad int cast"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
728 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
729 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
730 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
|
731 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
732 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
733 DValue* DtoCastPtr(DValue* val, Type* to) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
734 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
735 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
|
736 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
737 Type* totype = DtoDType(to); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
738 Type* fromtype = DtoDType(val->getType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
739 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
|
740 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
741 LLValue* rval; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
742 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
743 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
|
744 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
|
745 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
|
746 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
|
747 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
748 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
|
749 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
|
750 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
751 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
752 Logger::println("invalid cast from '%s' to '%s'", val->getType()->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
|
753 assert(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
754 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
755 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
756 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
|
757 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
758 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
759 DValue* DtoCastFloat(DValue* val, Type* to) |
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 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
|
762 return val; |
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 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
|
765 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
766 Type* totype = DtoDType(to); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
767 Type* fromtype = DtoDType(val->getType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
768 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
|
769 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
770 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
|
771 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
|
772 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
773 LLValue* rval; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
774 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
775 if (totype->iscomplex()) { |
359 | 776 return DtoComplex(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
|
777 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
778 else if (totype->isfloating()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
779 if ((fromtype->ty == Tfloat80 || fromtype->ty == Tfloat64) && (totype->ty == Tfloat80 || totype->ty == Tfloat64)) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
780 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
|
781 } |
359 | 782 else if ((fromtype->ty == Timaginary80 || fromtype->ty == Timaginary64) && (totype->ty == Timaginary80 || totype->ty == Timaginary64)) { |
783 rval = val->getRVal(); | |
784 } | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
785 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
|
786 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
|
787 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
788 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
|
789 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
|
790 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
791 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
792 assert(0 && "bad float cast"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
793 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
794 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
795 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
|
796 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
|
797 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
|
798 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
799 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
800 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
|
801 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
802 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
803 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
804 assert(0 && "bad float cast"); |
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 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
|
808 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
809 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
810 DValue* DtoCast(DValue* val, Type* to) |
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 Type* fromtype = DtoDType(val->getType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
813 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
|
814 if (fromtype->isintegral()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
815 return DtoCastInt(val, to); |
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 (fromtype->iscomplex()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
818 return DtoCastComplex(val, to); |
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 (fromtype->isfloating()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
821 return DtoCastFloat(val, to); |
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 (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
|
824 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
|
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 if (fromtype->ty == Tarray || fromtype->ty == Tsarray) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
827 return DtoCastArray(val, to); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
828 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
829 else if (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
|
830 return DtoCastPtr(val, to); |
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 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
833 assert(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
834 } |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
837 /****************************************************************************************/ |
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 // TEMPLATE HELPERS |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
840 ////////////////////////////////////////////////////////////////////////////////////////*/ |
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 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
|
843 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
844 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
|
845 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
|
846 return true; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
847 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
|
848 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
|
849 return false; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
850 } |
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 // 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
|
855 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
856 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
857 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
|
858 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
859 // 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
|
860 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
|
861 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
|
862 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
|
863 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
|
864 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
865 // 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
|
866 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
|
867 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
|
868 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
|
869 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
|
870 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
|
871 gIR->scope() = IRScope(initbb,endinitbb); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
872 DValue* ie = DtoInitializer(init); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
873 if (!ie->inPlace()) { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
874 DValue* dst = new DVarValue(t, gvar, true); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
875 DtoAssign(dst, ie); |
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 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
|
878 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
|
879 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
|
880 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
881 |
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 /*//////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
884 // 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
|
885 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
886 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
887 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
|
888 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
889 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
|
890 DtoResolveStruct(sd); |
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 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
|
893 DtoResolveClass(cd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
894 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
895 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
|
896 DtoResolveFunction(fd); |
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 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
|
899 DtoResolveTypeInfo(fd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
900 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
901 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
902 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
|
903 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
|
904 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
905 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
906 |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
909 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
|
910 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
911 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
|
912 DtoDeclareStruct(sd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
913 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
914 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
|
915 DtoDeclareClass(cd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
916 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
917 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
|
918 DtoDeclareFunction(fd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
919 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
920 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
|
921 DtoDeclareTypeInfo(fd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
922 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
923 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
924 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
|
925 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
|
926 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
927 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
928 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
929 ////////////////////////////////////////////////////////////////////////////////////////// |
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 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
|
932 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
933 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
|
934 DtoConstInitStruct(sd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
935 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
936 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
|
937 DtoConstInitClass(cd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
938 } |
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 (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
|
940 DtoConstInitTypeInfo(fd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
941 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
942 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
|
943 DtoConstInitGlobal(vd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
944 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
945 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
946 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
|
947 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
|
948 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
949 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
950 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
951 ////////////////////////////////////////////////////////////////////////////////////////// |
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 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
|
954 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
955 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
|
956 DtoDefineStruct(sd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
957 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
958 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
|
959 DtoDefineClass(cd); |
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 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
|
962 DtoDefineFunc(fd); |
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 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
|
965 DtoDefineTypeInfo(fd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
966 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
967 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
968 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
|
969 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
|
970 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
971 } |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
975 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
|
976 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
977 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
|
978 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
|
979 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
980 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
|
981 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
982 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
983 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
|
984 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
985 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
|
986 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
|
987 _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
|
988 emitRTstaticInit = true; |
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 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
991 _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
|
992 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
993 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
994 const LLType* _type = DtoType(vd->type); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
995 Type* t = DtoDType(vd->type); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
996 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
997 //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
|
998 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
|
999 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
|
1000 // zero initalizer |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1001 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
|
1002 _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
|
1003 // 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
|
1004 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
|
1005 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1006 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
|
1007 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
|
1008 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
|
1009 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
|
1010 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
|
1011 _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
|
1012 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1013 // 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
|
1014 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
|
1015 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1016 _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
|
1017 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1018 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1019 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
|
1020 //assert(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1021 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1022 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1023 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1024 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
|
1025 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
|
1026 istempl = true; |
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 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
|
1030 _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
|
1031 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
|
1032 _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
|
1033 //_type->dump(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1034 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
|
1035 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1036 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
|
1037 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
|
1038 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1039 gvar->setInitializer(_init); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
1040 // do debug info |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
1041 if (global.params.symdebug) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
1042 { |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
1043 LLGlobalVariable* gv = DtoDwarfGlobalVariable(gvar, vd); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
1044 // keep a reference so GDCE doesn't delete it ! |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
1045 gIR->usedArray.push_back(llvm::ConstantExpr::getBitCast(gv, getVoidPtrType())); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
1046 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1047 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1048 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1049 if (emitRTstaticInit) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1050 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
|
1051 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1052 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1053 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1054 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1055 void DtoEmptyResolveList() |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1056 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1057 //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
|
1058 Dsymbol* dsym; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1059 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
|
1060 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
|
1061 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
|
1062 DtoResolveDsymbol(dsym); |
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 } |
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 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1067 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1068 void DtoEmptyDeclareList() |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1069 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1070 //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
|
1071 Dsymbol* dsym; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1072 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
|
1073 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
|
1074 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
|
1075 DtoDeclareDsymbol(dsym); |
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 |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1081 void DtoEmptyConstInitList() |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1082 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1083 //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
|
1084 Dsymbol* dsym; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1085 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
|
1086 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
|
1087 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
|
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1094 void DtoEmptyDefineList() |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1095 { |
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("DtoEmptyDefineList()"); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1097 Dsymbol* dsym; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1098 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
|
1099 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
|
1100 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
|
1101 DtoDefineDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1102 } |
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 |
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 void DtoEmptyAllLists() |
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 for(;;) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1109 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1110 Dsymbol* dsym; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1111 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
|
1112 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
|
1113 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
|
1114 DtoResolveDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1115 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1116 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
|
1117 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
|
1118 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
|
1119 DtoDeclareDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1120 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1121 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
|
1122 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
|
1123 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
|
1124 DtoConstInitDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1125 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1126 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
|
1127 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
|
1128 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
|
1129 DtoDefineDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1130 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1131 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1132 break; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1133 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1134 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1135 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1136 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1137 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1138 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1139 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
|
1140 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1141 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
|
1142 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
|
1143 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1144 DtoResolveDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1145 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1146 DtoEmptyResolveList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1147 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1148 DtoDeclareDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1149 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1150 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1151 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1152 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1153 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
|
1154 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1155 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
|
1156 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
|
1157 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1158 DtoResolveDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1159 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1160 DtoEmptyResolveList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1161 DtoEmptyDeclareList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1162 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1163 DtoConstInitDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1164 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1165 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1166 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1167 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1168 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
|
1169 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1170 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
|
1171 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
|
1172 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1173 DtoResolveDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1174 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1175 DtoEmptyResolveList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1176 DtoEmptyDeclareList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1177 DtoEmptyConstInitList(); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1178 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1179 DtoDefineDsymbol(dsym); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1180 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1181 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1182 /****************************************************************************************/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1183 /*//////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1184 // INITIALIZER HELPERS |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1185 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1186 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1187 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
|
1188 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1189 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
|
1190 if (!init) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1191 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1192 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
|
1193 |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1194 if(type->ty == Tsarray) |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1195 { |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1196 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
|
1197 TypeSArray* arrtype = (TypeSArray*)type; |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1198 Type* elemtype = type->next; |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1199 |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1200 integer_t arraydim; |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1201 arraydim = arrtype->dim->toInteger(); |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1202 |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1203 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
|
1204 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
|
1205 _init = LLConstantArray::get(arrty, inits); |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1206 } |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1207 else |
94435b0ab2dd
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
ChristianK
parents:
291
diff
changeset
|
1208 _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
|
1209 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1210 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
|
1211 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1212 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
|
1213 _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
|
1214 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1215 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
|
1216 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1217 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
|
1218 _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
|
1219 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1220 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
|
1221 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1222 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
|
1223 _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
|
1224 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1225 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
|
1226 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1227 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
|
1228 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
|
1229 _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
|
1230 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1231 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1232 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
|
1233 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1234 return _init; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1235 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1236 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1237 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1238 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1239 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
|
1240 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1241 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
|
1242 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1243 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1244 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
|
1245 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1246 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
|
1247 assert(_init); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1248 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
|
1249 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1250 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
|
1251 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
|
1252 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1253 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
|
1254 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
|
1255 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
|
1256 _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
|
1257 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1258 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
|
1259 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1260 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
|
1261 _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
|
1262 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1263 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
|
1264 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1265 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
|
1266 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
|
1267 assert(ts); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1268 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
|
1269 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
|
1270 _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
|
1271 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1272 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
|
1273 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1274 _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
|
1275 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1276 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1277 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
|
1278 assert(0); |
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 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1281 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1282 return _init; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1283 } |
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 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1286 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1287 DValue* DtoInitializer(Initializer* init) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1288 { |
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
|
1289 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
|
1290 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
|
1291 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
|
1292 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1293 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
|
1294 assert(ex->exp); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1295 return ex->exp->toElem(gIR); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1296 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1297 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
|
1298 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1299 // do nothing |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1300 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1301 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1302 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
|
1303 assert(0); |
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 return 0; |
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 |
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 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1310 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1311 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
|
1312 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1313 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
|
1314 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
|
1315 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
|
1316 while (*p) |
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 if (*p == '"') |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1319 *p = '\''; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1320 ++p; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1321 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1322 // 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
|
1323 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
|
1324 } |
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 ////////////////////////////////////////////////////////////////////////////////////////// |
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 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
|
1329 { |
290
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1330 type = type->merge(); // needed.. getTypeInfo does the same |
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1331 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
|
1332 TypeInfoDeclaration* tidecl = type->vtinfo; |
290
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1333 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
|
1334 DtoForceDeclareDsymbol(tidecl); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1335 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
|
1336 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
|
1337 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
|
1338 if (base) |
290
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1339 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
|
1340 return c; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1341 } |
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
|
1342 |
289
17d3b3236334
[svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents:
284
diff
changeset
|
1343 ////////////////////////////////////////////////////////////////////////////////////////// |
17d3b3236334
[svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents:
284
diff
changeset
|
1344 |
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
|
1345 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
|
1346 { |
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
|
1347 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
|
1348 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
|
1349 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
|
1350 { |
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
|
1351 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
|
1352 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
|
1353 } |
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
|
1354 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
|
1355 { |
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
|
1356 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
|
1357 } |
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
|
1358 } |
365 | 1359 |
1360 ////////////////////////////////////////////////////////////////////////////////////////// | |
1361 | |
1362 LLValue* DtoBoolean(DValue* dval) | |
1363 { | |
1364 Type* dtype = dval->getType()->toBasetype(); | |
1365 TY ty = dtype->ty; | |
1366 | |
1367 // integer | |
1368 if (dtype->isintegral()) | |
1369 { | |
1370 LLValue* val = dval->getRVal(); | |
1371 if (val->getType() == LLType::Int1Ty) | |
1372 return val; | |
1373 else { | |
1374 LLValue* zero = LLConstantInt::get(val->getType(), 0, false); | |
1375 return gIR->ir->CreateICmpNE(val, zero, "tmp"); | |
1376 } | |
1377 } | |
1378 // complex | |
1379 else if (dtype->iscomplex()) | |
1380 { | |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
1381 return DtoComplexEquals(TOKnotequal, dval, DtoNullValue(dtype)); |
365 | 1382 } |
1383 // floating point | |
1384 else if (dtype->isfloating()) | |
1385 { | |
1386 LLValue* val = dval->getRVal(); | |
1387 LLValue* zero = LLConstant::getNullValue(val->getType()); | |
1388 return gIR->ir->CreateFCmpONE(val, zero, "tmp"); | |
1389 } | |
1390 // pointer/class | |
1391 else if (ty == Tpointer || ty == Tclass) { | |
1392 LLValue* val = dval->getRVal(); | |
1393 LLValue* zero = LLConstant::getNullValue(val->getType()); | |
1394 return gIR->ir->CreateICmpNE(val, zero, "tmp"); | |
1395 } | |
1396 // dynamic array | |
1397 else if (ty == Tarray) | |
1398 { | |
1399 // return (arr.length != 0) | |
1400 return gIR->ir->CreateICmpNE(DtoArrayLen(dval), DtoConstSize_t(0), "tmp"); | |
1401 } | |
1402 // delegate | |
1403 else if (ty == Tdelegate) | |
1404 { | |
1405 // return (dg !is null) | |
1406 return DtoDelegateEquals(TOKnotequal, dval->getRVal(), NULL); | |
1407 } | |
1408 // unknown | |
1409 std::cout << "unsupported -> bool : " << dtype->toChars() << '\n'; | |
1410 assert(0); | |
1411 return 0; | |
1412 } |