Mercurial > projects > ldc
annotate gen/llvmhelpers.cpp @ 1243:9c2dbbdd34f8
Updated the interal runtime's ClassInfo type to match the one in object.di .
Runtime now compiles and runminitest is back to normal except for typeinfo10.d .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Fri, 17 Apr 2009 02:54:16 +0200 |
parents | 79758fd2f48a |
children | 9014d7f0433f |
rev | line source |
---|---|
1206
a5bfed1f6775
Reduce include-order dependencies
Frits van Bommel <fvbommel wxs.nl>
parents:
1189
diff
changeset
|
1 #include "gen/llvmhelpers.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
2 #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
|
3 #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
|
4 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
5 #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
|
6 #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
|
7 #include "id.h" |
365 | 8 #include "expression.h" |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
9 #include "template.h" |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
670
diff
changeset
|
10 #include "module.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
11 |
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/tollvm.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/irstate.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/runtime.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/logger.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/arrays.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/dvalue.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/complex.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/classes.h" |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
20 #include "gen/functions.h" |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
21 #include "gen/typeinf.h" |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
22 #include "gen/todebug.h" |
1067
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
23 #include "gen/cl_options.h" |
1207
83d3b25c2213
Isolate all knowledge of what a function's nested context looks like in a
Frits van Bommel <fvbommel wxs.nl>
parents:
1206
diff
changeset
|
24 #include "gen/nested.h" |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
670
diff
changeset
|
25 #include "ir/irmodule.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
26 |
482
aa8c050dfd19
Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents:
481
diff
changeset
|
27 #include <stack> |
aa8c050dfd19
Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents:
481
diff
changeset
|
28 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
29 /****************************************************************************************/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
30 /*//////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
31 // 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
|
32 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
33 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
34 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
|
35 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
36 // 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
|
37 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
|
38 // 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
|
39 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
|
40 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
|
41 // call runtime allocator |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
1004
diff
changeset
|
42 LLValue* mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_mem").getInstruction(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
43 // cast |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
44 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
|
45 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
46 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
47 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
|
48 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
49 // 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
|
50 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
|
51 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
52 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
|
53 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
|
54 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
55 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
|
56 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
57 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
58 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
|
59 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
60 // 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
|
61 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
|
62 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
63 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
|
64 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
|
65 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
66 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
|
67 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
68 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
69 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
|
70 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
71 // 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
|
72 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
|
73 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
74 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
|
75 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
|
76 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
77 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
|
78 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
79 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
80 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
|
81 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
82 // 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
|
83 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
|
84 // build args |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
85 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
|
86 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
|
87 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
|
88 // call |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
309
diff
changeset
|
89 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
|
90 } |
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 /****************************************************************************************/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
93 /*//////////////////////////////////////////////////////////////////////////////////////// |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
94 // ALLOCA HELPERS |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
95 ////////////////////////////////////////////////////////////////////////////////////////*/ |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
96 |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
97 |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
98 llvm::AllocaInst* DtoAlloca(const LLType* lltype, const std::string& name) |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
99 { |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
100 return new llvm::AllocaInst(lltype, name, gIR->topallocapoint()); |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
101 } |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
102 |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
103 llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std::string& name) |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
104 { |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
105 return new llvm::AllocaInst(lltype, arraysize, name, gIR->topallocapoint()); |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
106 } |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
107 |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
108 |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
109 /****************************************************************************************/ |
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
110 /*//////////////////////////////////////////////////////////////////////////////////////// |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
111 // ASSERT HELPER |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
112 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
113 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
114 void DtoAssert(Module* M, Loc loc, DValue* msg) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
115 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
116 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
|
117 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
118 // func |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
119 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
|
120 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
|
121 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
122 // msg param |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
123 if (msg) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
124 { |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
125 args.push_back(msg->getRVal()); |
244
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
128 // file param |
936
2ebac4750adb
Removed some dead code.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
934
diff
changeset
|
129 |
2ebac4750adb
Removed some dead code.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
934
diff
changeset
|
130 // we might be generating for an imported template function |
2ebac4750adb
Removed some dead code.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
934
diff
changeset
|
131 if (!M->ir.irModule) |
2ebac4750adb
Removed some dead code.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
934
diff
changeset
|
132 M->ir.irModule = new IrModule(M, M->srcfile->toChars()); |
2ebac4750adb
Removed some dead code.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
934
diff
changeset
|
133 |
2ebac4750adb
Removed some dead code.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
934
diff
changeset
|
134 args.push_back(DtoLoad(M->ir.irModule->fileName)); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
135 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
136 // line param |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
137 LLConstant* c = DtoConstUint(loc.linnum); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
138 args.push_back(c); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
139 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
140 // call |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
1004
diff
changeset
|
141 gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
142 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
143 // end debug info |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
144 if (global.params.symdebug) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
145 DtoDwarfFuncEnd(gIR->func()->decl); |
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
|
146 |
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
|
147 // 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
|
148 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
|
149 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
150 |
439
47b64d06eb9f
Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents:
435
diff
changeset
|
151 |
47b64d06eb9f
Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents:
435
diff
changeset
|
152 /****************************************************************************************/ |
47b64d06eb9f
Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents:
435
diff
changeset
|
153 /*//////////////////////////////////////////////////////////////////////////////////////// |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
154 // LABEL HELPER |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
155 ////////////////////////////////////////////////////////////////////////////////////////*/ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
156 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
|
157 { |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 { |
357
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
162 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
|
163 { |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
164 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
|
165 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
|
166 } |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
167 return NULL; |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
168 } |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
169 return iter->second; |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
170 } |
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 /****************************************************************************************/ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
173 /*//////////////////////////////////////////////////////////////////////////////////////// |
302 | 174 // GOTO HELPER |
175 ////////////////////////////////////////////////////////////////////////////////////////*/ | |
1160
7d28dcbff23e
Reenable error for gotos into or out of finally blocks.
Christian Kamm <kamm incasoftware de>
parents:
1151
diff
changeset
|
176 void DtoGoto(Loc loc, Identifier* target, TryFinallyStatement* sourceFinally) |
302 | 177 { |
178 assert(!gIR->scopereturned()); | |
179 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
180 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
|
181 if(!lblstmt) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
182 error(loc, "the label %s does not exist", target->toChars()); |
357
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
183 fatal(); |
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
184 } |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
185 |
304 | 186 // 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
|
187 if(lblstmt->asmLabel) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
188 error(loc, "cannot goto to label %s inside an inline asm block", target->toChars()); |
357
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
189 fatal(); |
82af71383b8a
[svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents:
356
diff
changeset
|
190 } |
304 | 191 |
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
|
192 // 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
|
193 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
|
194 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
|
195 if (targetBB == NULL) |
980
ae710cba0884
Clean up the code generated when jumping out of inline asm and make label names more expressive.
Frits van Bommel <fvbommel wxs.nl>
parents:
948
diff
changeset
|
196 targetBB = llvm::BasicBlock::Create("label_" + labelname, gIR->topfunc()); |
302 | 197 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
198 // emit code for finallys between goto and label |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
199 DtoEnclosingHandlers(loc, lblstmt); |
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
|
200 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
201 // goto into finally blocks is forbidden by the spec |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
202 // but should work fine |
1160
7d28dcbff23e
Reenable error for gotos into or out of finally blocks.
Christian Kamm <kamm incasoftware de>
parents:
1151
diff
changeset
|
203 if(lblstmt->enclosingFinally != sourceFinally) { |
7d28dcbff23e
Reenable error for gotos into or out of finally blocks.
Christian Kamm <kamm incasoftware de>
parents:
1151
diff
changeset
|
204 error(loc, "spec disallows goto into or out of 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
|
205 fatal(); |
1160
7d28dcbff23e
Reenable error for gotos into or out of finally blocks.
Christian Kamm <kamm incasoftware de>
parents:
1151
diff
changeset
|
206 } |
302 | 207 |
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
|
208 llvm::BranchInst::Create(targetBB, gIR->scopebb()); |
302 | 209 } |
210 | |
211 /****************************************************************************************/ | |
212 /*//////////////////////////////////////////////////////////////////////////////////////// | |
309 | 213 // TRY-FINALLY, VOLATILE AND SYNCHRONIZED HELPER |
302 | 214 ////////////////////////////////////////////////////////////////////////////////////////*/ |
309 | 215 |
216 void EnclosingSynchro::emitCode(IRState * p) | |
217 { | |
218 if (s->exp) | |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
219 DtoLeaveMonitor(s->exp->toElem(p)->getRVal()); |
309 | 220 else |
221 DtoLeaveCritical(s->llsync); | |
222 } | |
223 | |
224 //////////////////////////////////////////////////////////////////////////////////////// | |
225 | |
226 void EnclosingVolatile::emitCode(IRState * p) | |
227 { | |
228 // store-load barrier | |
229 DtoMemoryBarrier(false, false, true, false); | |
230 } | |
231 | |
232 //////////////////////////////////////////////////////////////////////////////////////// | |
233 | |
234 void EnclosingTryFinally::emitCode(IRState * p) | |
235 { | |
845
d128381e086e
Only emit finalbody if there is one. Fixes #147.
Christian Kamm <kamm incasoftware de>
parents:
812
diff
changeset
|
236 if (tf->finalbody) |
d128381e086e
Only emit finalbody if there is one. Fixes #147.
Christian Kamm <kamm incasoftware de>
parents:
812
diff
changeset
|
237 tf->finalbody->toIR(p); |
309 | 238 } |
239 | |
240 //////////////////////////////////////////////////////////////////////////////////////// | |
241 | |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
242 void DtoEnclosingHandlers(Loc loc, Statement* target) |
302 | 243 { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
244 // labels are a special case: they are not required to enclose the current scope |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
245 // for them we use the enclosing scope handler as a reference point |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
246 LabelStatement* lblstmt = dynamic_cast<LabelStatement*>(target); |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
247 if (lblstmt) |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
248 target = lblstmt->enclosingScopeExit; |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
249 |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
250 // figure out up until what handler we need to emit |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
251 IrFunction::TargetScopeVec::reverse_iterator targetit = gIR->func()->targetScopes.rbegin(); |
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
252 IrFunction::TargetScopeVec::reverse_iterator it_end = gIR->func()->targetScopes.rend(); |
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
253 while(targetit != it_end) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
254 if (targetit->s == target) { |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
255 break; |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
256 } |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
257 ++targetit; |
302 | 258 } |
259 | |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
260 if (target && targetit == it_end) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
261 if (lblstmt) |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
262 error(loc, "cannot goto into try, volatile or synchronized statement at %s", target->loc.toChars()); |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
263 else |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
264 error(loc, "internal error, cannot find jump path to statement at %s", target->loc.toChars()); |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
265 return; |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
266 } |
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
|
267 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
268 // |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
269 // emit code for enclosing handlers |
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
|
270 // |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
271 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
272 // 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
|
273 // 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
|
274 gIR->func()->pushUniqueLabelScope("enclosing"); |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
275 IrFunction::TargetScopeVec::reverse_iterator it = gIR->func()->targetScopes.rbegin(); |
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
276 while (it != targetit) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
277 if (it->enclosinghandler) |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1088
diff
changeset
|
278 it->enclosinghandler->emitCode(gIR); |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
279 ++it; |
302 | 280 } |
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
|
281 gIR->func()->popLabelScope(); |
302 | 282 } |
283 | |
284 /****************************************************************************************/ | |
285 /*//////////////////////////////////////////////////////////////////////////////////////// | |
309 | 286 // SYNCHRONIZED SECTION HELPERS |
287 ////////////////////////////////////////////////////////////////////////////////////////*/ | |
288 | |
289 void DtoEnterCritical(LLValue* g) | |
290 { | |
291 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
|
292 gIR->CreateCallOrInvoke(fn, g); |
309 | 293 } |
294 | |
295 void DtoLeaveCritical(LLValue* g) | |
296 { | |
297 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
|
298 gIR->CreateCallOrInvoke(fn, g); |
309 | 299 } |
300 | |
301 void DtoEnterMonitor(LLValue* v) | |
302 { | |
303 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorenter"); | |
304 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
|
305 gIR->CreateCallOrInvoke(fn, v); |
309 | 306 } |
307 | |
308 void DtoLeaveMonitor(LLValue* v) | |
309 { | |
310 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorexit"); | |
311 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
|
312 gIR->CreateCallOrInvoke(fn, v); |
309 | 313 } |
314 | |
315 /****************************************************************************************/ | |
316 /*//////////////////////////////////////////////////////////////////////////////////////// | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
317 // 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
|
318 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
319 |
1018
e8c6dbcd33d1
- Fixed x86-32 C ABI for complex number return values.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1013
diff
changeset
|
320 // is this a good approach at all ? |
e8c6dbcd33d1
- Fixed x86-32 C ABI for complex number return values.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1013
diff
changeset
|
321 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
322 void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
323 { |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
324 Logger::println("DtoAssign(...);\n"); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
325 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
326 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
327 Type* t = lhs->getType()->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
328 Type* t2 = rhs->getType()->toBasetype(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
329 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
330 if (t->ty == Tstruct) { |
295
895e1b50cf2a
[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents:
294
diff
changeset
|
331 if (!t->equals(t2)) { |
1018
e8c6dbcd33d1
- Fixed x86-32 C ABI for complex number return values.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1013
diff
changeset
|
332 // FIXME: use 'rhs' for something !?! |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
333 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
|
334 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
335 else { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
336 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
|
337 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
338 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
339 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
|
340 // 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
|
341 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
|
342 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
|
343 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
|
344 } |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
345 else if (t->nextOf()->toBasetype()->equals(t2)) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
346 DtoArrayInit(loc, s, rhs); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
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 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
|
350 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
351 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
352 // 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
|
353 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
|
354 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
|
355 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
|
356 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
357 // null |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
358 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
|
359 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
|
360 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
361 // reference assignment |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
362 else if (t2->ty == Tarray) { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
363 DtoStore(rhs->getRVal(), lhs->getLVal()); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
364 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
365 // some implicitly converting ref assignment |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
366 else { |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
367 DtoSetArray(lhs->getLVal(), DtoArrayLen(rhs), DtoArrayPtr(rhs)); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
368 } |
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 else if (t->ty == Tsarray) { |
709
b972fb129d37
Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents:
704
diff
changeset
|
371 // T[n] = T[n] |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
372 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
|
373 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
|
374 } |
709
b972fb129d37
Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents:
704
diff
changeset
|
375 // T[n] = T |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
376 else if (t->nextOf()->toBasetype()->equals(t2)) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
377 DtoArrayInit(loc, lhs, rhs); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
378 } |
709
b972fb129d37
Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents:
704
diff
changeset
|
379 // T[n] = T[] - generally only generated by frontend in rare cases |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
380 else if (t2->ty == Tarray && t->nextOf()->toBasetype()->equals(t2->nextOf()->toBasetype())) { |
709
b972fb129d37
Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents:
704
diff
changeset
|
381 DtoMemCpy(lhs->getLVal(), DtoArrayPtr(rhs), DtoArrayLen(rhs)); |
b972fb129d37
Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents:
704
diff
changeset
|
382 } else { |
b972fb129d37
Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents:
704
diff
changeset
|
383 assert(0 && "Unimplemented static array assign!"); |
b972fb129d37
Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents:
704
diff
changeset
|
384 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
385 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
386 else if (t->ty == Tdelegate) { |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
387 LLValue* l = lhs->getLVal(); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
388 LLValue* r = rhs->getRVal(); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
389 if (Logger::enabled()) |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
390 Logger::cout() << "assign\nlhs: " << *l << "rhs: " << *r << '\n'; |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
391 DtoStore(r, l); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
392 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
393 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
|
394 assert(t2->ty == Tclass); |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
453
diff
changeset
|
395 LLValue* l = lhs->getLVal(); |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
453
diff
changeset
|
396 LLValue* r = rhs->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
397 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
398 { |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
399 Logger::cout() << "l : " << *l << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
400 Logger::cout() << "r : " << *r << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
401 } |
468
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
453
diff
changeset
|
402 r = DtoBitCast(r, l->getType()->getContainedType(0)); |
45a67b6f1310
Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
453
diff
changeset
|
403 DtoStore(r, l); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
404 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
405 else if (t->iscomplex()) { |
1151
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
406 LLValue* dst = lhs->getLVal(); |
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
407 LLValue* src = DtoCast(loc, rhs, lhs->getType())->getRVal(); |
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
408 DtoStore(src, dst); |
244
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 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
411 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
|
412 LLValue* r = rhs->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
413 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
414 Logger::cout() << "assign\nlhs: " << *l << "rhs: " << *r << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
415 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
|
416 if (r->getType() != lit) { |
1151
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
417 r = DtoCast(loc, rhs, lhs->getType())->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
418 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
419 Logger::cout() << "really assign\nlhs: " << *l << "rhs: " << *r << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
420 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
|
421 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
422 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
|
423 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
424 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
425 |
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 /*//////////////////////////////////////////////////////////////////////////////////////// |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
428 // NULL VALUE HELPER |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
429 ////////////////////////////////////////////////////////////////////////////////////////*/ |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
430 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
431 DValue* DtoNullValue(Type* type) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
432 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
433 Type* basetype = type->toBasetype(); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
434 TY basety = basetype->ty; |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
435 const LLType* lltype = DtoType(basetype); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
436 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
437 // complex, needs to be first since complex are also floating |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
438 if (basetype->iscomplex()) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
439 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
440 const LLType* basefp = DtoComplexBaseType(basetype); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
583
diff
changeset
|
441 LLValue* res = DtoAggrPair(DtoType(type), LLConstant::getNullValue(basefp), LLConstant::getNullValue(basefp)); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
583
diff
changeset
|
442 return new DImValue(type, res); |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
443 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
444 // integer, floating, pointer and class have no special representation |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
445 else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
446 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
447 return new DConstValue(type, LLConstant::getNullValue(lltype)); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
448 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
449 // dynamic array |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
450 else if (basety == Tarray) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
451 { |
373 | 452 LLValue* len = DtoConstSize_t(0); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
453 LLValue* ptr = getNullPtr(getPtrToType(DtoType(basetype->nextOf()))); |
373 | 454 return new DSliceValue(type, len, ptr); |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
455 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
456 // delegate |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
457 else if (basety == Tdelegate) |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
458 { |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
459 return new DNullValue(type, LLConstant::getNullValue(lltype)); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
460 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
461 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
462 // unknown |
994
18ad5601dff7
Use LLVM OStream wrapper instead of <iostream> in the logger.
Frits van Bommel <fvbommel wxs.nl>
parents:
980
diff
changeset
|
463 llvm::cout << "unsupported: null value for " << type->toChars() << '\n'; |
372
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
464 assert(0); |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
465 return 0; |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
466 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
467 } |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
468 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
469 |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
470 /****************************************************************************************/ |
83ade4f4025a
[svn r393] Started implementation for DtoNullValue.
ChristianK
parents:
370
diff
changeset
|
471 /*//////////////////////////////////////////////////////////////////////////////////////// |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
472 // CASTING HELPERS |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
473 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
474 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
475 DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
476 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
477 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
|
478 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
479 Type* to = _to->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
480 Type* from = val->getType()->toBasetype(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
481 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
|
482 |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
483 size_t fromsz = from->size(); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
484 size_t tosz = to->size(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
485 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
486 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
|
487 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
|
488 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
|
489 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
490 |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
491 if (to->ty == Tbool) { |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
492 LLValue* zero = LLConstantInt::get(rval->getType(), 0, false); |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
493 rval = gIR->ir->CreateICmpNE(rval, zero, "tmp"); |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
494 } |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
495 else if (to->isintegral()) { |
757
2c730d530c98
Special case DtoCastInt for bool.
Christian Kamm <kamm incasoftware de>
parents:
747
diff
changeset
|
496 if (fromsz < tosz || from->ty == Tbool) { |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
497 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
498 Logger::cout() << "cast to: " << *tolltype << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
499 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
|
500 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
|
501 } else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
502 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
|
503 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
504 } |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
505 else if (fromsz > tosz) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
506 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
|
507 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
508 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
509 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
|
510 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
511 } |
359 | 512 else if (to->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
513 return DtoComplex(loc, to, val); |
359 | 514 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
515 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
|
516 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
|
517 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
|
518 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
519 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
520 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
|
521 } |
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 else if (to->ty == Tpointer) { |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
524 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
525 Logger::cout() << "cast pointer: " << *tolltype << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
526 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
|
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 { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
529 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), _to->toChars()); |
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
530 fatal(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
531 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
532 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
533 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
|
534 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
535 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
536 DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
537 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
538 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
|
539 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
540 Type* totype = to->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
541 Type* fromtype = val->getType()->toBasetype(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
542 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
|
543 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
544 LLValue* rval; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
545 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
546 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
|
547 LLValue* src = val->getRVal(); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
548 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
549 Logger::cout() << "src: " << *src << "to type: " << *tolltype << '\n'; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
550 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
|
551 } |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
552 else if (totype->ty == Tbool) { |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
553 LLValue* src = val->getRVal(); |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
554 LLValue* zero = LLConstant::getNullValue(src->getType()); |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
555 rval = gIR->ir->CreateICmpNE(src, zero, "tmp"); |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
556 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
557 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
|
558 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
|
559 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
560 else { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
561 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars()); |
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
562 fatal(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
563 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
564 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
565 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
|
566 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
567 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
568 DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
569 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
570 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
|
571 return val; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
572 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
573 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
|
574 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
575 Type* totype = to->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
576 Type* fromtype = val->getType()->toBasetype(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
577 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
|
578 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
579 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
|
580 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
|
581 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
582 LLValue* rval; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
583 |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
584 if (totype->ty == Tbool) { |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
585 rval = val->getRVal(); |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
586 LLValue* zero = LLConstant::getNullValue(rval->getType()); |
784
a45179dfaa43
Fix float->bool, #130. Thanks fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
778
diff
changeset
|
587 rval = gIR->ir->CreateFCmpUNE(rval, zero, "tmp"); |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
588 } |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
589 else if (totype->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
590 return DtoComplex(loc, to, val); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
591 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
592 else if (totype->isfloating()) { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
442
diff
changeset
|
593 if (fromsz == tosz) { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
594 rval = val->getRVal(); |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
442
diff
changeset
|
595 assert(rval->getType() == tolltype); |
359 | 596 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
597 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
|
598 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
|
599 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
600 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
|
601 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
|
602 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
603 else { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
604 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars()); |
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
605 fatal(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
606 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
607 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
608 else 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
|
609 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
|
610 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
|
611 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
612 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
613 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
|
614 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
615 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
616 else { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
617 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars()); |
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
618 fatal(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
619 } |
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 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
|
622 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
623 |
419
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
624 DValue* DtoCastDelegate(Loc& loc, DValue* val, Type* to) |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
625 { |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
626 if (to->toBasetype()->ty == Tdelegate) |
419
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
627 { |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
628 return DtoPaintType(loc, val, to); |
419
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
629 } |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
630 else if (to->toBasetype()->ty == Tbool) |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
631 { |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
632 return new DImValue(to, DtoDelegateEquals(TOKnotequal, val->getRVal(), NULL)); |
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
773
diff
changeset
|
633 } |
419
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
634 else |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
635 { |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
636 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars()); |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
637 fatal(); |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
638 } |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
639 } |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
640 |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
641 DValue* DtoCast(Loc& loc, DValue* val, Type* to) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
642 { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
643 Type* fromtype = val->getType()->toBasetype(); |
1151
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
644 Type* totype = to->toBasetype(); |
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
645 if (fromtype->equals(totype)) |
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
646 return val; |
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
647 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
648 Logger::println("Casting from '%s' to '%s'", fromtype->toChars(), to->toChars()); |
1151
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
649 LOG_SCOPE; |
3cf0066e6faf
- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1148
diff
changeset
|
650 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
651 if (fromtype->isintegral()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
652 return DtoCastInt(loc, val, to); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
653 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
654 else if (fromtype->iscomplex()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
655 return DtoCastComplex(loc, val, to); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
656 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
657 else if (fromtype->isfloating()) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
658 return DtoCastFloat(loc, val, to); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
659 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
660 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
|
661 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
|
662 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
663 else if (fromtype->ty == Tarray || fromtype->ty == Tsarray) { |
424
c8d98ccad0cc
Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
Christian Kamm <kamm incasoftware de>
parents:
419
diff
changeset
|
664 return DtoCastArray(loc, val, to); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
665 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
666 else if (fromtype->ty == Tpointer || fromtype->ty == Tfunction) { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
667 return DtoCastPtr(loc, val, to); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
668 } |
419
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
669 else if (fromtype->ty == Tdelegate) { |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
670 return DtoCastDelegate(loc, val, to); |
023fa78c1203
Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
399
diff
changeset
|
671 } |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
672 else { |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
673 error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars()); |
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
373
diff
changeset
|
674 fatal(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
675 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
676 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
677 |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
678 ////////////////////////////////////////////////////////////////////////////////////////// |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
679 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
680 DValue* DtoPaintType(Loc& loc, DValue* val, Type* to) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
681 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
682 Type* from = val->getType()->toBasetype(); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
683 Logger::println("repainting from '%s' to '%s'", from->toChars(), to->toChars()); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
684 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
685 if (from->ty == Tarray) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
686 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
687 Type* at = to->toBasetype(); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
688 assert(at->ty == Tarray); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
689 Type* elem = at->nextOf()->pointerTo(); |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
690 if (DSliceValue* slice = val->isSlice()) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
691 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
692 return new DSliceValue(to, slice->len, DtoBitCast(slice->ptr, DtoType(elem))); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
693 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
694 else if (val->isLVal()) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
695 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
696 LLValue* ptr = val->getLVal(); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
697 ptr = DtoBitCast(ptr, DtoType(at->pointerTo())); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
698 return new DVarValue(to, ptr); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
699 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
700 else |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
701 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
702 LLValue *len, *ptr; |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
703 len = DtoArrayLen(val); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
704 ptr = DtoArrayPtr(val); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
705 ptr = DtoBitCast(ptr, DtoType(elem)); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
706 return new DImValue(to, DtoAggrPair(len, ptr, "tmp")); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
707 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
708 } |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
709 else if (from->ty == Tdelegate) |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
710 { |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
711 Type* dgty = to->toBasetype(); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
712 assert(dgty->ty == Tdelegate); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
713 if (val->isLVal()) |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
714 { |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
715 LLValue* ptr = val->getLVal(); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
716 assert(isaPointer(ptr)); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
717 ptr = DtoBitCast(ptr, getPtrToType(DtoType(dgty))); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
718 if (Logger::enabled()) |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
719 Logger::cout() << "dg ptr: " << *ptr << '\n'; |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
720 return new DVarValue(to, ptr); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
721 } |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
722 else |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
723 { |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
724 LLValue* dg = val->getRVal(); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
725 LLValue* context = gIR->ir->CreateExtractValue(dg, 0, ".context"); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
726 LLValue* funcptr = gIR->ir->CreateExtractValue(dg, 1, ".funcptr"); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
727 funcptr = DtoBitCast(funcptr, DtoType(dgty)->getContainedType(1)); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
728 LLValue* aggr = DtoAggrPair(context, funcptr, "tmp"); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
729 if (Logger::enabled()) |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
730 Logger::cout() << "dg: " << *aggr << '\n'; |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
731 return new DImValue(to, aggr); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
732 } |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
733 } |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
734 else if (from->ty == Tpointer || from->ty == Tclass || from->ty == Taarray) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
735 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
736 Type* b = to->toBasetype(); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
737 assert(b->ty == Tpointer || b->ty == Tclass || b->ty == Taarray); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
738 LLValue* ptr = DtoBitCast(val->getRVal(), DtoType(b)); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
739 return new DImValue(to, ptr); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
740 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
741 else |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
742 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
743 assert(!val->isLVal()); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
744 assert(DtoType(to) == DtoType(to)); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
745 return new DImValue(to, val->getRVal()); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
746 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
747 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
748 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
749 /****************************************************************************************/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
750 /*//////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
751 // TEMPLATE HELPERS |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
752 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
753 |
1067
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
754 TemplateInstance* DtoIsTemplateInstance(Dsymbol* s) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
755 { |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
756 if (!s) return NULL; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
757 if (s->isTemplateInstance() && !s->isTemplateMixin()) |
1067
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
758 return s->isTemplateInstance(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
759 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
|
760 return DtoIsTemplateInstance(s->parent); |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
761 return NULL; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
762 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
763 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
764 /****************************************************************************************/ |
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 // 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
|
767 ////////////////////////////////////////////////////////////////////////////////////////*/ |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
768 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
769 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
|
770 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
771 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
|
772 DtoResolveStruct(sd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
773 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
774 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
|
775 DtoResolveClass(cd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
776 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
777 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
|
778 DtoResolveFunction(fd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
779 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
780 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
|
781 DtoResolveTypeInfo(fd); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
782 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
783 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
784 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
|
785 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
|
786 } |
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 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
789 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
790 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
791 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
|
792 { |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
793 vd->codegen(Type::sir); |
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
794 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
795 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
|
796 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
|
797 |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
798 Logger::println("DtoConstInitGlobal(%s) @ %s", vd->toChars(), vd->locToChars()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
799 LOG_SCOPE; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
800 |
798
92ea3015ace6
Use toParent instead of toParent2 to determine whether inside a function body.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
801 Dsymbol* par = vd->toParent(); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
802 |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
918
diff
changeset
|
803 // build the initializer |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
918
diff
changeset
|
804 LLConstant* initVal = DtoConstInitializer(vd->loc, vd->type, vd->init); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
805 |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
806 // set the initializer if appropriate |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
807 IrGlobal* glob = vd->ir.irGlobal; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
808 llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(glob->value); |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
809 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
810 // refine the global's opaque type to the type of the initializer |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
811 llvm::cast<LLOpaqueType>(glob->type.get())->refineAbstractTypeTo(initVal->getType()); |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
812 |
812
6c2ff06c4201
Fixed a nasty bug with how interface vtables for class initializers were output, causing some class fields to be skipped.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
803
diff
changeset
|
813 assert(!glob->constInit); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
814 glob->constInit = initVal; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
815 |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
816 // assign the initializer |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
817 llvm::GlobalVariable* globalvar = llvm::cast<llvm::GlobalVariable>(glob->value); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
818 |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
819 if (!(vd->storage_class & STCextern) && mustDefineSymbol(vd)) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
820 { |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
821 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
822 { |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
823 Logger::println("setting initializer"); |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
824 Logger::cout() << "global: " << *gvar << '\n'; |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
825 Logger::cout() << "init: " << *initVal << '\n'; |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
826 } |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
827 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
828 gvar->setInitializer(initVal); |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
829 |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
830 // do debug info |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
831 if (global.params.symdebug) |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
832 { |
946
1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
833 LLGlobalVariable* gv = DtoDwarfGlobalVariable(gvar, vd).getGV(); |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
834 // keep a reference so GDCE doesn't delete it ! |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
835 gIR->usedArray.push_back(llvm::ConstantExpr::getBitCast(gv, getVoidPtrType())); |
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
244
diff
changeset
|
836 } |
244
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 |
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 /*//////////////////////////////////////////////////////////////////////////////////////// |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
842 // DECLARATION EXP HELPER |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
843 ////////////////////////////////////////////////////////////////////////////////////////*/ |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
844 DValue* DtoDeclarationExp(Dsymbol* declaration) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
845 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
846 Logger::print("DtoDeclarationExp: %s\n", declaration->toChars()); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
847 LOG_SCOPE; |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
848 |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
849 // variable declaration |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
850 if (VarDeclaration* vd = declaration->isVarDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
851 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
852 Logger::println("VarDeclaration"); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
853 |
648
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
854 // if aliassym is set, this VarDecl is redone as an alias to another symbol |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
855 // this seems to be done to rewrite Tuple!(...) v; |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
856 // as a TupleDecl that contains a bunch of individual VarDecls |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
857 if (vd->aliassym) |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
858 return DtoDeclarationExp(vd->aliassym); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
859 |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
860 // static |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
861 if (vd->isDataseg()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
862 { |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1145
diff
changeset
|
863 vd->codegen(Type::sir); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
864 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
865 else |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
866 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
867 if (global.params.llvmAnnotate) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
868 DtoAnnotation(declaration->toChars()); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
869 |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
870 Logger::println("vdtype = %s", vd->type->toChars()); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
871 |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
872 // referenced by nested delegate? |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
873 #if DMDV2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
874 if (vd->nestedrefs.dim) { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
875 #else |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
876 if (vd->nestedref) { |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
877 #endif |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
878 Logger::println("has nestedref set"); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
879 assert(vd->ir.irLocal); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
880 |
1207
83d3b25c2213
Isolate all knowledge of what a function's nested context looks like in a
Frits van Bommel <fvbommel wxs.nl>
parents:
1206
diff
changeset
|
881 DtoNestedInit(vd); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
882 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
883 // normal stack variable, allocate storage on the stack if it has not already been done |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
884 else if(!vd->ir.irLocal) { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
885 const LLType* lltype = DtoType(vd->type); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
886 |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
887 llvm::Value* allocainst; |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
888 if(gTargetData->getTypeSizeInBits(lltype) == 0) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
889 allocainst = llvm::ConstantPointerNull::get(getPtrToType(lltype)); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
890 else |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
468
diff
changeset
|
891 allocainst = DtoAlloca(lltype, vd->toChars()); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
892 |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
893 //allocainst->setAlignment(vd->type->alignsize()); // TODO |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
894 vd->ir.irLocal = new IrLocal(vd); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
895 vd->ir.irLocal->value = allocainst; |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
896 |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
897 if (global.params.symdebug) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
898 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
899 DtoDwarfLocalVariable(allocainst, vd); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
900 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
901 } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
902 else |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
903 { |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
904 assert(vd->ir.irLocal->value); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
483
diff
changeset
|
905 } |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
906 |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
907 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
908 Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n'; |
482
aa8c050dfd19
Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents:
481
diff
changeset
|
909 DValue* ie = DtoInitializer(vd->ir.irLocal->value, vd->init); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
910 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
911 |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
583
diff
changeset
|
912 return new DVarValue(vd->type, vd, vd->ir.getIrValue()); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
913 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
914 // struct declaration |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
915 else if (StructDeclaration* s = declaration->isStructDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
916 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
917 Logger::println("StructDeclaration"); |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
918 s->codegen(Type::sir); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
919 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
920 // function declaration |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
921 else if (FuncDeclaration* f = declaration->isFuncDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
922 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
923 Logger::println("FuncDeclaration"); |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
924 f->codegen(Type::sir); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
925 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
926 // alias declaration |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
927 else if (AliasDeclaration* a = declaration->isAliasDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
928 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
929 Logger::println("AliasDeclaration - no work"); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
930 // do nothing |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
931 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
932 // enum |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
933 else if (EnumDeclaration* e = declaration->isEnumDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
934 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
935 Logger::println("EnumDeclaration - no work"); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
936 // do nothing |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
937 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
938 // class |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
939 else if (ClassDeclaration* e = declaration->isClassDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
940 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
941 Logger::println("ClassDeclaration"); |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
942 e->codegen(Type::sir); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
943 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
944 // typedef |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
945 else if (TypedefDeclaration* tdef = declaration->isTypedefDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
946 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
947 Logger::println("TypedefDeclaration"); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
948 DtoTypeInfoOf(tdef->type, false); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
949 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
950 // attribute declaration |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
951 else if (AttribDeclaration* a = declaration->isAttribDeclaration()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
952 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
953 Logger::println("AttribDeclaration"); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
954 for (int i=0; i < a->decl->dim; ++i) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
955 { |
590
1ecb43102d12
Allow VarDecl inside AttributeDecl inside DeclExp.
Christian Kamm <kamm incasoftware de>
parents:
585
diff
changeset
|
956 DtoDeclarationExp((Dsymbol*)a->decl->data[i]); |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
957 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
958 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
959 // mixin declaration |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
960 else if (TemplateMixin* m = declaration->isTemplateMixin()) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
961 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
962 Logger::println("TemplateMixin"); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
963 for (int i=0; i < m->members->dim; ++i) |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
964 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
965 Dsymbol* mdsym = (Dsymbol*)m->members->data[i]; |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
966 DtoDeclarationExp(mdsym); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
967 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
968 } |
648
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
969 // tuple declaration |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
970 else if (TupleDeclaration* tupled = declaration->isTupleDeclaration()) |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
971 { |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
972 Logger::println("TupleDeclaration"); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
973 if(!tupled->isexp) { |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
974 error(declaration->loc, "don't know how to handle non-expression tuple decls yet"); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
975 assert(0); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
976 } |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
977 |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
978 assert(tupled->objects); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
979 for (int i=0; i < tupled->objects->dim; ++i) |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
980 { |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
981 DsymbolExp* exp = (DsymbolExp*)tupled->objects->data[i]; |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
982 DtoDeclarationExp(exp->s); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
983 } |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
639
diff
changeset
|
984 } |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
985 // unsupported declaration |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
986 else |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
987 { |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
988 error(declaration->loc, "Unimplemented Declaration type for DeclarationExp. kind: %s", declaration->kind()); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
989 assert(0); |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
990 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
991 return NULL; |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
992 } |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
993 |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
994 // does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
995 LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr) |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
996 { |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
997 // we don't handle globals with this one |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
998 assert(!var->isDataseg()); |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
999 |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1000 // we don't handle aliases either |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1001 assert(!var->aliassym); |
1189
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1002 |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1003 // alloca if necessary |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1004 LLValue* allocaval = NULL; |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1005 if (!addr && (!var->ir.irLocal || !var->ir.irLocal->value)) |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1006 { |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1007 addr = DtoAlloca(DtoType(var->type), var->toChars()); |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1008 |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1009 // add debug info |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1010 if (global.params.symdebug) |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1011 DtoDwarfLocalVariable(addr, var); |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1012 } |
773
5696a7167b21
Fix RawVarDecl double codegen bug. Thanks to downs for the testcase.
Christian Kamm <kamm incasoftware de>
parents:
758
diff
changeset
|
1013 |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1014 // referenced by nested function? |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
1015 #if DMDV2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
1016 if (var->nestedrefs.dim) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
1017 #else |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1018 if (var->nestedref) |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
1019 #endif |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1020 { |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1021 assert(var->ir.irLocal); |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1022 if(!var->ir.irLocal->value) |
1189
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1023 { |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1024 assert(addr); |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1025 var->ir.irLocal->value = addr; |
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1026 } |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1027 else |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1028 assert(!addr || addr == var->ir.irLocal->value); |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1029 |
1207
83d3b25c2213
Isolate all knowledge of what a function's nested context looks like in a
Frits van Bommel <fvbommel wxs.nl>
parents:
1206
diff
changeset
|
1030 DtoNestedInit(var); |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1031 } |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1032 // normal local variable |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1033 else |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1034 { |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1035 // if this already has storage, it must've been handled already |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1036 if (var->ir.irLocal && var->ir.irLocal->value) { |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1037 assert(!addr || addr == var->ir.irLocal->value); |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1038 return var->ir.irLocal->value; |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1039 } |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1167
diff
changeset
|
1040 |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1041 assert(!var->ir.isSet()); |
1189
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1042 assert(addr); |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1043 var->ir.irLocal = new IrLocal(var); |
1189
c0091f3b72f1
Make sure debug info is only declared once per alloca.
Christian Kamm <kamm incasoftware de>
parents:
1185
diff
changeset
|
1044 var->ir.irLocal->value = addr; |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1045 } |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1046 |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1047 // return the alloca |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1048 return var->ir.irLocal->value; |
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
1049 } |
433
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
1050 |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
1051 /****************************************************************************************/ |
b5f55f471e0b
Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents:
424
diff
changeset
|
1052 /*//////////////////////////////////////////////////////////////////////////////////////// |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1053 // INITIALIZER HELPERS |
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 |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1056 LLConstant* DtoConstInitializer(Loc loc, Type* type, Initializer* init) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1057 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1058 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
|
1059 if (!init) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1060 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1061 Logger::println("const default initializer for %s", type->toChars()); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1062 _init = DtoConstExpInit(loc, type, type->defaultInit()); |
244
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 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
|
1065 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1066 Logger::println("const expression initializer"); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1067 _init = DtoConstExpInit(loc, type, ex->exp);; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1068 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1069 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
|
1070 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1071 Logger::println("const struct initializer"); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1207
diff
changeset
|
1072 si->ad->codegen(Type::sir); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1207
diff
changeset
|
1073 return si->ad->ir.irStruct->createStructInitializer(si); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1074 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1075 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
|
1076 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1077 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
|
1078 _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
|
1079 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1080 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
|
1081 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1082 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
|
1083 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
|
1084 _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
|
1085 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1086 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1087 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
|
1088 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1089 return _init; |
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 |
482
aa8c050dfd19
Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents:
481
diff
changeset
|
1094 DValue* DtoInitializer(LLValue* target, Initializer* init) |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1095 { |
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
|
1096 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
|
1097 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
|
1098 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
|
1099 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1100 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
|
1101 assert(ex->exp); |
1004
45ed9e125a00
Remove initialization of padding of reals, ireals and creals.
Frits van Bommel <fvbommel wxs.nl>
parents:
994
diff
changeset
|
1102 return ex->exp->toElem(gIR); |
244
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 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
|
1105 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1106 // do nothing |
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 else { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1109 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
|
1110 assert(0); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1111 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1112 return 0; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1113 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1114 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1115 ////////////////////////////////////////////////////////////////////////////////////////// |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1116 |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1117 static LLConstant* expand_to_sarray(Type *base, Expression* exp) |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1118 { |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1119 Logger::println("building type %s from expression (%s) of type %s", base->toChars(), exp->toChars(), exp->type->toChars()); |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1120 const LLType* dstTy = DtoType(base); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
1121 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
1122 Logger::cout() << "final llvm type requested: " << *dstTy << '\n'; |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1123 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1124 LLConstant* val = exp->toConstElem(gIR); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1125 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1126 Type* expbase = exp->type->toBasetype(); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1127 Logger::println("expbase: %s", expbase->toChars()); |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1128 Type* t = base->toBasetype(); |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1129 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1130 LLSmallVector<size_t, 4> dims; |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1131 |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1132 while(1) |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1133 { |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1134 Logger::println("t: %s", t->toChars()); |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1135 if (t->equals(expbase)) |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1136 break; |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1137 assert(t->ty == Tsarray); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1138 TypeSArray* tsa = (TypeSArray*)t; |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1139 dims.push_back(tsa->dim->toInteger()); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
1140 assert(t->nextOf()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
757
diff
changeset
|
1141 t = t->nextOf()->toBasetype(); |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1142 } |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1143 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1144 size_t i = dims.size(); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1145 assert(i); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1146 |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1147 std::vector<LLConstant*> inits; |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1148 while (i--) |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1149 { |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1150 const LLArrayType* arrty = LLArrayType::get(val->getType(), dims[i]); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1151 inits.clear(); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1152 inits.insert(inits.end(), dims[i], val); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1153 val = LLConstantArray::get(arrty, inits); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1154 } |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1155 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1156 return val; |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1157 } |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1158 |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1159 LLConstant* DtoConstExpInit(Loc loc, Type* type, Expression* exp) |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1160 { |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1161 Type* expbase = exp->type->toBasetype(); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1162 Type* base = type->toBasetype(); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1163 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1164 // if not the same basetypes, we won't get the same llvm types either |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1165 if (!expbase->equals(base)) |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1166 { |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1167 if (base->ty == Tsarray) |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1168 { |
796
6e7a4c3b64d2
Error instead of assert when trying to build a default initializer for void[n].
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
1169 if (base->nextOf()->toBasetype()->ty == Tvoid) { |
6e7a4c3b64d2
Error instead of assert when trying to build a default initializer for void[n].
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
1170 error(loc, "static arrays of voids have no default initializer"); |
6e7a4c3b64d2
Error instead of assert when trying to build a default initializer for void[n].
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
1171 fatal(); |
6e7a4c3b64d2
Error instead of assert when trying to build a default initializer for void[n].
Christian Kamm <kamm incasoftware de>
parents:
794
diff
changeset
|
1172 } |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
1173 Logger::println("type is a static array, building constant array initializer to single value"); |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1174 return expand_to_sarray(base, exp); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1175 } |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1176 else |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1177 { |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
709
diff
changeset
|
1178 error("cannot yet convert default initializer %s to type %s to %s", exp->toChars(), exp->type->toChars(), type->toChars()); |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1179 fatal(); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1180 } |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1181 assert(0); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1182 } |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1183 |
502
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1184 return exp->toConstElem(gIR); |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1185 } |
837af2a63564
Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
486
diff
changeset
|
1186 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1187 ////////////////////////////////////////////////////////////////////////////////////////// |
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 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
|
1190 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1191 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
|
1192 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
|
1193 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
|
1194 while (*p) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1195 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1196 if (*p == '"') |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1197 *p = '\''; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1198 ++p; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1199 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1200 // create a noop with the code as the result name! |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
796
diff
changeset
|
1201 // FIXME: this is const folded and eliminated immediately ... :/ |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1202 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
|
1203 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1204 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1205 ////////////////////////////////////////////////////////////////////////////////////////// |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1206 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1207 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
|
1208 { |
290
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1209 type = type->merge(); // needed.. getTypeInfo does the same |
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1210 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
|
1211 TypeInfoDeclaration* tidecl = type->vtinfo; |
290
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1212 assert(tidecl); |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1213 tidecl->codegen(Type::sir); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1214 assert(tidecl->ir.irGlobal != NULL); |
1148
3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
1215 assert(tidecl->ir.irGlobal->value != NULL); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1216 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
|
1217 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
|
1218 if (base) |
290
ebaf65fc4726
[svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents:
289
diff
changeset
|
1219 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
|
1220 return c; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff
changeset
|
1221 } |
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
|
1222 |
289
17d3b3236334
[svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents:
284
diff
changeset
|
1223 ////////////////////////////////////////////////////////////////////////////////////////// |
17d3b3236334
[svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents:
284
diff
changeset
|
1224 |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1225 void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, std::string& name) |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1226 { |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1227 Logger::println("DtoOverloadedIntrinsicName"); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1228 LOG_SCOPE; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1229 |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1230 Logger::println("template instance: %s", ti->toChars()); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1231 Logger::println("template declaration: %s", td->toChars()); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1232 Logger::println("intrinsic name: %s", td->intrinsicName.c_str()); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1233 |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1234 // for now use the size in bits of the first template param in the instance |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1235 assert(ti->tdtypes.dim == 1); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1236 Type* T = (Type*)ti->tdtypes.data[0]; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1237 |
1079 | 1238 char prefix = T->isreal() ? 'f' : T->isintegral() ? 'i' : 0; |
1239 if (!prefix) { | |
1240 ti->error("has invalid template parameter for intrinsic: %s", T->toChars()); | |
1241 fatal(); // or LLVM asserts | |
1242 } | |
1243 | |
1244 char tmp[21]; // probably excessive, but covers a uint64_t | |
1167
ed4b050ada45
Another big-endian fix. (Don't lie to [s]printf...)
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1245 sprintf(tmp, "%lu", (unsigned long) gTargetData->getTypeSizeInBits(DtoType(T))); |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1246 |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1247 // replace # in name with bitsize |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1248 name = td->intrinsicName; |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1249 |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1250 std::string needle("#"); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1251 size_t pos; |
1079 | 1252 while(std::string::npos != (pos = name.find(needle))) { |
1253 if (pos > 0 && name[pos-1] == prefix) { | |
1254 // Properly prefixed, insert bitwidth. | |
1255 name.replace(pos, 1, tmp); | |
1256 } else { | |
1257 if (pos && (name[pos-1] == 'i' || name[pos-1] == 'f')) { | |
1258 // Wrong type character. | |
1259 ti->error("has invalid parameter type for intrinsic %s: %s is not a%s type", | |
1260 name.c_str(), T->toChars(), | |
1261 (name[pos-1] == 'i' ? "n integral" : " floating-point")); | |
1262 } else { | |
1088
a08983bf972e
Move "invalid intrinsic name" error to declaration, not instantiation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1079
diff
changeset
|
1263 // Just plain wrong. (Error in declaration, not instantiation) |
a08983bf972e
Move "invalid intrinsic name" error to declaration, not instantiation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1079
diff
changeset
|
1264 td->error("has an invalid intrinsic name: %s", name.c_str()); |
1079 | 1265 } |
1266 fatal(); // or LLVM asserts | |
1267 } | |
1268 } | |
527
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1269 |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1270 Logger::println("final intrinsic name: %s", name.c_str()); |
cecfee2d01a8
Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
505
diff
changeset
|
1271 } |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1272 |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1273 ////////////////////////////////////////////////////////////////////////////////////////// |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1274 |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1275 bool mustDefineSymbol(Dsymbol* s) |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1276 { |
1067
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1277 TemplateInstance* tinst = DtoIsTemplateInstance(s); |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1278 if (tinst) |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1279 { |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1280 if (!opts::singleObj) |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1281 return true; |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1282 |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1283 if (!tinst->emittedInModule) |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1284 tinst->emittedInModule = gIR->dmodule; |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1285 return tinst->emittedInModule == gIR->dmodule; |
947
9a10fa839dc5
Switch some getModule to getCompilationModule to make sure templates are
Christian Kamm <kamm incasoftware de>
parents:
946
diff
changeset
|
1286 } |
1067
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1287 |
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1288 return s->getModule() == gIR->dmodule; |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1289 } |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1290 |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1291 ////////////////////////////////////////////////////////////////////////////////////////// |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1292 |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1293 bool needsTemplateLinkage(Dsymbol* s) |
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1294 { |
1067
7ce8355fbcc6
Improved template emission control for singleobj building.
Christian Kamm <kamm incasoftware de>
parents:
1044
diff
changeset
|
1295 return DtoIsTemplateInstance(s) && mustDefineSymbol(s); |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
936
diff
changeset
|
1296 } |
1029
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1297 |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1298 ////////////////////////////////////////////////////////////////////////////////////////// |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1299 |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1300 bool hasUnalignedFields(Type* t) |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1301 { |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1302 t = t->toBasetype(); |
1044
39f12f5aa515
Fix hasUnalignedFields(): take static arrays into account too.
Frits van Bommel <fvbommel wxs.nl>
parents:
1029
diff
changeset
|
1303 if (t->ty == Tsarray) { |
39f12f5aa515
Fix hasUnalignedFields(): take static arrays into account too.
Frits van Bommel <fvbommel wxs.nl>
parents:
1029
diff
changeset
|
1304 assert(t->next->size() % t->next->alignsize() == 0); |
39f12f5aa515
Fix hasUnalignedFields(): take static arrays into account too.
Frits van Bommel <fvbommel wxs.nl>
parents:
1029
diff
changeset
|
1305 return hasUnalignedFields(t->next); |
39f12f5aa515
Fix hasUnalignedFields(): take static arrays into account too.
Frits van Bommel <fvbommel wxs.nl>
parents:
1029
diff
changeset
|
1306 } else if (t->ty != Tstruct) |
1029
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1307 return false; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1308 |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1309 TypeStruct* ts = (TypeStruct*)t; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1310 if (ts->unaligned) |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1311 return (ts->unaligned == 2); |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1312 |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1313 StructDeclaration* sym = ts->sym; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1314 |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1315 // go through all the fields and try to find something unaligned |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1316 ts->unaligned = 2; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1317 for (int i = 0; i < sym->fields.dim; i++) |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1318 { |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1319 VarDeclaration* f = (VarDeclaration*)sym->fields.data[i]; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1320 unsigned a = f->type->alignsize() - 1; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1321 if (((f->offset + a) & ~a) != f->offset) |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1322 return true; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1323 else if (f->type->toBasetype()->ty == Tstruct && hasUnalignedFields(f->type)) |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1324 return true; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1325 } |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1326 |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1327 ts->unaligned = 1; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1328 return false; |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1019
diff
changeset
|
1329 } |