annotate gen/llvmhelpers.cpp @ 773:5696a7167b21

Fix RawVarDecl double codegen bug. Thanks to downs for the testcase.
author Christian Kamm <kamm incasoftware de>
date Tue, 18 Nov 2008 18:07:57 +0100
parents f04dde6e882c
children 4adf0f742896
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1 #include "gen/llvm.h"
284
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 250
diff changeset
2 #include "llvm/Target/TargetMachineRegistry.h"
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
3
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
4 #include "mars.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
5 #include "init.h"
339
385a18242485 [svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
lindquist
parents: 328
diff changeset
6 #include "id.h"
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
7 #include "expression.h"
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
8 #include "template.h"
683
b411c41a9716 Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents: 670
diff changeset
9 #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
10
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
11 #include "gen/tollvm.h"
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
12 #include "gen/llvmhelpers.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"
683
b411c41a9716 Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents: 670
diff changeset
23 #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
24
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
25 #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
26
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
27 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
28 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
29 // 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
30 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
31
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
32 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
33 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
34 // 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
35 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
36 // 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
37 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
38 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
39 // call runtime allocator
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
40 LLValue* mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_mem")->get();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
41 // cast
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
42 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
43 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
44
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
45 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
46 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
47 // 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
48 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
49 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
50 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
51 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
52 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
53 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
54 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
55
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
56 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
57 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
58 // 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
59 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
60 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
61 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
62 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
63 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
64 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
65 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
66
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
67 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
68 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
69 // 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
70 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
71 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
72 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
73 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
74 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
75 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
76 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
77
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
78 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
79 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
80 // 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
81 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
82 // build args
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
83 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
84 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
85 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
86 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
87 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
88 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
89
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
90 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
91 /*////////////////////////////////////////////////////////////////////////////////////////
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
92 // 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
93 ////////////////////////////////////////////////////////////////////////////////////////*/
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
94
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 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
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 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
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
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 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
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 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
104 }
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
105
672eb4893b55 Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents: 468
diff changeset
106
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 /*////////////////////////////////////////////////////////////////////////////////////////
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
109 // ASSERT HELPER
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
110 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
111
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
112 void DtoAssert(Loc* loc, DValue* msg)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
113 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
114 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
115
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
116 // func
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
117 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
118 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
119
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
120 // msg param
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
121 if (msg)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
122 {
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
123 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
124 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
125
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
126 // file param
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
127 args.push_back(DtoLoad(gIR->dmodule->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
128
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
129 // line param
683
b411c41a9716 Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents: 670
diff changeset
130 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
131 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
132
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
133 // call
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 309
diff changeset
134 CallOrInvoke* call = 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
135
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
136 // end debug info
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
137 if (global.params.symdebug)
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
138 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
139
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
140 // 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
141 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
142 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
143
439
47b64d06eb9f Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents: 435
diff changeset
144
47b64d06eb9f Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents: 435
diff changeset
145 /****************************************************************************************/
47b64d06eb9f Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents: 435
diff changeset
146 /*////////////////////////////////////////////////////////////////////////////////////////
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
147 // LABEL HELPER
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
148 ////////////////////////////////////////////////////////////////////////////////////////*/
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
149 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
150 {
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
151 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
152 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
153 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
154 {
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
155 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
156 {
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
157 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
158 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
159 }
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
160 return NULL;
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
161 }
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
162 return iter->second;
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
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
165 /****************************************************************************************/
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
166 /*////////////////////////////////////////////////////////////////////////////////////////
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
167 // GOTO HELPER
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
168 ////////////////////////////////////////////////////////////////////////////////////////*/
356
44daf304421c [svn r377] The previous check was too strict, it completely disallowed gotos within finally blocks. This reenables them as long as they don't cross a finally boundary.
ChristianK
parents: 355
diff changeset
169 void DtoGoto(Loc* loc, Identifier* target, EnclosingHandler* enclosinghandler, TryFinallyStatement* sourcetf)
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
170 {
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
171 assert(!gIR->scopereturned());
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
172
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
173 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
174 if(!lblstmt) {
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
175 error(*loc, "the label %s does not exist", target->toChars());
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
176 fatal();
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
177 }
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
178
304
3ebc136702dd [svn r325] Removed dead code.
ChristianK
parents: 302
diff changeset
179 // 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
180 if(lblstmt->asmLabel) {
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
181 error(*loc, "cannot goto to label %s inside an inline asm block", target->toChars());
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
182 fatal();
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
183 }
304
3ebc136702dd [svn r325] Removed dead code.
ChristianK
parents: 302
diff changeset
184
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
185 // 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
186 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
187 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
188 if (targetBB == NULL)
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 339
diff changeset
189 targetBB = llvm::BasicBlock::Create("label", gIR->topfunc());
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
190
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
191 // find finallys between goto and label
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
192 EnclosingHandler* endfinally = enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
193 while(endfinally != NULL && endfinally != lblstmt->enclosinghandler) {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
194 endfinally = endfinally->getEnclosing();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
195 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
196
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
197 // error if didn't find tf statement of label
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
198 if(endfinally != lblstmt->enclosinghandler)
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
199 error(*loc, "cannot goto into try block");
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
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
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
202 // though it should not be problematic to implement
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
203 if(lblstmt->tf != sourcetf) {
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
204 error(*loc, "spec disallows goto into finally block");
357
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
205 fatal();
82af71383b8a [svn r378] Make some errors fatal to prevent segfaults. Error instead of assert on missing label.
ChristianK
parents: 356
diff changeset
206 }
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
207
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
208 // emit code for finallys between goto and label
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
209 DtoEnclosingHandlers(enclosinghandler, endfinally);
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
210
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
211 llvm::BranchInst::Create(targetBB, gIR->scopebb());
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
212 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
213
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
214 /****************************************************************************************/
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
215 /*////////////////////////////////////////////////////////////////////////////////////////
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
216 // TRY-FINALLY, VOLATILE AND SYNCHRONIZED HELPER
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
217 ////////////////////////////////////////////////////////////////////////////////////////*/
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
218
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
219 void EnclosingSynchro::emitCode(IRState * p)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
220 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
221 if (s->exp)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
222 DtoLeaveMonitor(s->llsync);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
223 else
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
224 DtoLeaveCritical(s->llsync);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
225 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
226
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
227 EnclosingHandler* EnclosingSynchro::getEnclosing()
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
228 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
229 return s->enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
230 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
231
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
232 ////////////////////////////////////////////////////////////////////////////////////////
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
233
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
234 void EnclosingVolatile::emitCode(IRState * p)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
235 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
236 // store-load barrier
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
237 DtoMemoryBarrier(false, false, true, false);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
238 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
239
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
240 EnclosingHandler* EnclosingVolatile::getEnclosing()
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
241 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
242 return v->enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
243 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
244
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
245 ////////////////////////////////////////////////////////////////////////////////////////
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
246
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
247 void EnclosingTryFinally::emitCode(IRState * p)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
248 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
249 assert(tf->finalbody);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
250 tf->finalbody->toIR(p);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
251 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
252
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
253 EnclosingHandler* EnclosingTryFinally::getEnclosing()
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
254 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
255 return tf->enclosinghandler;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
256 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
257
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
258 ////////////////////////////////////////////////////////////////////////////////////////
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
259
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
260 void DtoEnclosingHandlers(EnclosingHandler* start, EnclosingHandler* end)
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
261 {
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
262 // verify that end encloses start
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
263 EnclosingHandler* endfinally = start;
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
264 while(endfinally != NULL && endfinally != end) {
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
265 endfinally = endfinally->getEnclosing();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
266 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
267 assert(endfinally == end);
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
268
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
269
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 //
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
271 // emit code for finallys between start and end
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
272 //
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
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 // 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
275 // 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
276 gIR->func()->pushUniqueLabelScope("enclosing");
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
277 EnclosingHandler* tf = start;
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
278 while(tf != end) {
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
279 tf->emitCode(gIR);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
280 tf = tf->getEnclosing();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
281 }
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
282 gIR->func()->popLabelScope();
302
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
283 }
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
284
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
285 /****************************************************************************************/
bef811104734 [svn r323] Branching out of inline asm works.
ChristianK
parents: 295
diff changeset
286 /*////////////////////////////////////////////////////////////////////////////////////////
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
287 // SYNCHRONIZED SECTION HELPERS
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
288 ////////////////////////////////////////////////////////////////////////////////////////*/
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
289
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
290 void DtoEnterCritical(LLValue* g)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
291 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
292 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
293 gIR->CreateCallOrInvoke(fn, g);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
294 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
295
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
296 void DtoLeaveCritical(LLValue* g)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
297 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
298 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
299 gIR->CreateCallOrInvoke(fn, g);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
300 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
301
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
302 void DtoEnterMonitor(LLValue* v)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
303 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
304 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorenter");
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
305 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
306 gIR->CreateCallOrInvoke(fn, v);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
307 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
308
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
309 void DtoLeaveMonitor(LLValue* v)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
310 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
311 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorexit");
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
312 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
313 gIR->CreateCallOrInvoke(fn, v);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
314 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
315
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
316 /****************************************************************************************/
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 305
diff changeset
317 /*////////////////////////////////////////////////////////////////////////////////////////
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
318 // NESTED VARIABLE HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
319 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
320
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
321 DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd)
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
322 {
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
323 Dsymbol* vdparent = vd->toParent2();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
324 assert(vdparent);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
325
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
326 IrFunction* irfunc = gIR->func();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
327
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 // is the nested variable in this scope?
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
329 if (vdparent == irfunc->decl)
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
330 {
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
331 LLValue* val = vd->ir.getIrValue();
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
332 return new DVarValue(astype, vd, val);
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
333 }
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
334
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 // get it from the nested context
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
336 LLValue* ctx = 0;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
337 if (irfunc->decl->isMember2())
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
338 {
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
339 ClassDeclaration* cd = irfunc->decl->isMember2()->isClassDeclaration();
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
340 LLValue* val = DtoLoad(irfunc->thisArg);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
341 ctx = DtoLoad(DtoGEPi(val, 0,2+cd->vthis->ir.irField->index, ".vthis"));
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
342 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
343 else
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
344 ctx = irfunc->nestArg;
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
345 assert(ctx);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
346
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
347 assert(vd->ir.irLocal);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
348 LLValue* val = DtoBitCast(ctx, getPtrToType(getVoidPtrType()));
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
349 val = DtoGEPi1(val, vd->ir.irLocal->nestedIndex);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
350 val = DtoLoad(val);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
351 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
352 val = DtoBitCast(val, vd->ir.irLocal->value->getType(), vd->toChars());
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
353 return new DVarValue(astype, vd, val);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
354 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
355
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
356 LLValue* DtoNestedContext(Loc loc, Dsymbol* sym)
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
357 {
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
358 Logger::println("DtoNestedContext for %s", sym->toPrettyChars());
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
359 LOG_SCOPE;
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
360
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
361 IrFunction* irfunc = gIR->func();
639
8aebdf56c455 Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents: 632
diff changeset
362
8aebdf56c455 Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents: 632
diff changeset
363 // if this func has its own vars that are accessed by nested funcs
8aebdf56c455 Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents: 632
diff changeset
364 // use its own context
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
365 if (irfunc->nestedVar)
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
366 return irfunc->nestedVar;
639
8aebdf56c455 Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents: 632
diff changeset
367 // otherwise, it may have gotten a context from the caller
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
368 else if (irfunc->nestArg)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
369 return irfunc->nestArg;
639
8aebdf56c455 Move check for access of context for nested class from backend into frontend.
Christian Kamm <kamm incasoftware de>
parents: 632
diff changeset
370 // or just have a this argument
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
371 else if (irfunc->thisArg)
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
372 {
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
373 ClassDeclaration* cd = irfunc->decl->isMember2()->isClassDeclaration();
505
841589c97f20 Do not assert if there's a struct-this nested context.
Christian Kamm <kamm incasoftware de>
parents: 503
diff changeset
374 if (!cd || !cd->vthis)
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
375 return getNullPtr(getVoidPtrType());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
376 LLValue* val = DtoLoad(irfunc->thisArg);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
377 return DtoLoad(DtoGEPi(val, 0,2+cd->vthis->ir.irField->index, ".vthis"));
468
45a67b6f1310 Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 453
diff changeset
378 }
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
379 else
453
60332cd85308 Fixed regressions
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 452
diff changeset
380 {
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
381 return getNullPtr(getVoidPtrType());
453
60332cd85308 Fixed regressions
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 452
diff changeset
382 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
383 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
384
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 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
387 // 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
388 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
389
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
390 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
391 {
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
392 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
393 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
394
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
395 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
396 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
397
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
398 if (t->ty == Tstruct) {
295
895e1b50cf2a [svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents: 294
diff changeset
399 if (!t->equals(t2)) {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
400 // TODO: fix this, use 'rhs' for something
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
401 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
402 }
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
403 else {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
404 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
405 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
406 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
407 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
408 // 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
409 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
410 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
411 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
412 }
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
413 else if (t->nextOf()->toBasetype()->equals(t2)) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
414 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
415 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
416 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
417 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
418 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
419 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
420 // 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
421 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
422 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
423 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
424 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
425 // null
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
426 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
427 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
428 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
429 // reference assignment
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
430 else if (t2->ty == Tarray) {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
431 DtoStore(rhs->getRVal(), lhs->getLVal());
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
432 }
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
433 // 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
434 else {
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
435 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
436 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
437 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
438 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
439 // 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
440 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
441 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
442 }
709
b972fb129d37 Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents: 704
diff changeset
443 // 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
444 else if (t->nextOf()->toBasetype()->equals(t2)) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
445 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
446 }
709
b972fb129d37 Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents: 704
diff changeset
447 // 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
448 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
449 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
450 } else {
b972fb129d37 Add missing case to DtoAssign for T[n] = T[]. Fixes downs' initializer bug.
Christian Kamm <kamm incasoftware de>
parents: 704
diff changeset
451 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
452 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
453 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
454 else if (t->ty == Tdelegate) {
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
455 LLValue* l = lhs->getLVal();
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
456 LLValue* r = rhs->getRVal();
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
457 if (Logger::enabled())
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
458 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
459 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
460 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
461 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
462 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
463 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
464 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
465 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
466 {
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
467 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
468 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
469 }
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
470 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
471 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
472 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
473 else if (t->iscomplex()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
474 LLValue* dst;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
475 if (DLRValue* lr = lhs->isLRValue()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
476 dst = lr->getLVal();
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
477 rhs = DtoCastComplex(loc, rhs, lr->getLType());
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
478 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
479 else {
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
480 dst = lhs->getLVal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
481 }
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
482 DtoStore(rhs->getRVal(), dst);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
483 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
484 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
485 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
486 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
487 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
488 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
489 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
490 if (r->getType() != lit) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
491 // handle lvalue cast assignments
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
492 if (DLRValue* lr = lhs->isLRValue()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
493 Logger::println("lvalue cast!");
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
494 r = DtoCast(loc, rhs, lr->getLType())->getRVal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
495 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
496 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
497 r = DtoCast(loc, rhs, lhs->getType())->getRVal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
498 }
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
499 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
500 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
501 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
502 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
503 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
504 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
505 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
506
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 /*////////////////////////////////////////////////////////////////////////////////////////
372
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
509 // NULL VALUE HELPER
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
510 ////////////////////////////////////////////////////////////////////////////////////////*/
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
511
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
512 DValue* DtoNullValue(Type* type)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
513 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
514 Type* basetype = type->toBasetype();
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
515 TY basety = basetype->ty;
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
516 const LLType* lltype = DtoType(basetype);
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
517
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
518 // complex, needs to be first since complex are also floating
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
519 if (basetype->iscomplex())
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
520 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
521 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
522 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
523 return new DImValue(type, res);
372
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
524 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
525 // integer, floating, pointer and class have no special representation
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
526 else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
527 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
528 return new DConstValue(type, LLConstant::getNullValue(lltype));
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
529 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
530 // dynamic array
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
531 else if (basety == Tarray)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
532 {
373
d1574e142e93 [svn r394] Fixed the new DtoNullValue function
lindquist
parents: 372
diff changeset
533 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
534 LLValue* ptr = getNullPtr(getPtrToType(DtoType(basetype->nextOf())));
373
d1574e142e93 [svn r394] Fixed the new DtoNullValue function
lindquist
parents: 372
diff changeset
535 return new DSliceValue(type, len, ptr);
372
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
536 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
537 // delegate
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
538 else if (basety == Tdelegate)
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
539 {
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
540 return new DNullValue(type, LLConstant::getNullValue(lltype));
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
541 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
542
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
543 // unknown
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
544 std::cout << "unsupported: null value for " << type->toChars() << '\n';
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
545 assert(0);
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
546 return 0;
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
547
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
548 }
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
549
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
550
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
551 /****************************************************************************************/
83ade4f4025a [svn r393] Started implementation for DtoNullValue.
ChristianK
parents: 370
diff changeset
552 /*////////////////////////////////////////////////////////////////////////////////////////
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
553 // CASTING HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
554 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
555
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
556 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
557 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
558 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
559
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
560 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
561 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
562 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
563
611
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
564 size_t fromsz = from->size();
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
565 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
566
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
567 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
568 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
569 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
570 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
571
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
572 if (to->isintegral()) {
757
2c730d530c98 Special case DtoCastInt for bool.
Christian Kamm <kamm incasoftware de>
parents: 747
diff changeset
573 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
574 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
575 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
576 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
577 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
578 } else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
579 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
580 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
581 }
757
2c730d530c98 Special case DtoCastInt for bool.
Christian Kamm <kamm incasoftware de>
parents: 747
diff changeset
582 else if (fromsz > tosz || to->ty == Tbool) {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
583 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
584 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
585 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
586 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
587 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
588 }
359
926f65e39246 [svn r380] Improve complex number support.
ChristianK
parents: 358
diff changeset
589 else if (to->iscomplex()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
590 return DtoComplex(loc, to, val);
359
926f65e39246 [svn r380] Improve complex number support.
ChristianK
parents: 358
diff changeset
591 }
244
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 (to->isfloating()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
593 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
594 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
595 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
596 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
597 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
598 }
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 (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
601 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
602 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
603 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
604 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
605 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
606 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
607 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
608 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
609
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
610 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
611 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
612
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
613 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
614 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
615 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
616
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
617 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
618 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
619 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
620
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
621 LLValue* 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 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
624 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
625 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
626 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
627 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
628 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
629 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
630 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
631 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
632 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
633 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
634 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
635 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
636
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
637 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
638 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
639
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
640 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
641 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
642 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
643 return val;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
644
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
645 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
646
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
647 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
648 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
649 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
650
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
651 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
652 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
653
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
654 LLValue* rval;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
655
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
656 if (totype->iscomplex()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
657 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
658 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
659 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
660 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
661 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
662 assert(rval->getType() == tolltype);
359
926f65e39246 [svn r380] Improve complex number support.
ChristianK
parents: 358
diff changeset
663 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
664 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
665 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
666 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
667 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
668 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
669 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
670 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
671 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
672 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
673 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
674 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
675 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
676 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
677 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
678 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
679 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
680 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
681 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
682 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
683 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
684 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
685 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
686 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
687
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
688 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
689 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
690
419
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
691 DValue* DtoCastDelegate(Loc& loc, DValue* val, Type* to)
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
692 {
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
693 if (to->toBasetype()->ty == Tdelegate)
419
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
694 {
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
695 return DtoPaintType(loc, val, to);
419
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
696 }
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
697 else
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
698 {
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
699 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
700 fatal();
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
701 }
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
702 }
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
703
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
704 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
705 {
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
706 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
707 Logger::println("Casting from '%s' to '%s'", fromtype->toChars(), to->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
708 if (fromtype->isintegral()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
709 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
710 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
711 else if (fromtype->iscomplex()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
712 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
713 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
714 else if (fromtype->isfloating()) {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
715 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
716 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
717 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
718 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
719 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
720 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
721 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
722 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
723 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
724 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
725 }
419
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
726 else if (fromtype->ty == Tdelegate) {
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
727 return DtoCastDelegate(loc, val, to);
023fa78c1203 Fixed delegate casts.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 399
diff changeset
728 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
729 else {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
730 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
731 fatal();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
732 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
733 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
734
715
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
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
737 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
738 {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
739 Type* from = val->getType()->toBasetype();
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
740 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
741
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
742 if (from->ty == Tarray)
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
743 {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
744 Type* at = to->toBasetype();
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
745 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
746 Type* elem = at->nextOf()->pointerTo();
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
747 if (DSliceValue* slice = val->isSlice())
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
748 {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
749 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
750 }
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
751 else if (val->isLVal())
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
752 {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
753 LLValue* ptr = val->getLVal();
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
754 ptr = DtoBitCast(ptr, DtoType(at->pointerTo()));
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
755 return new DVarValue(to, ptr);
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
756 }
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
757 else
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
758 {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
759 LLValue *len, *ptr;
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
760 len = DtoArrayLen(val);
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
761 ptr = DtoArrayPtr(val);
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
762 ptr = DtoBitCast(ptr, DtoType(elem));
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
763 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
764 }
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
765 }
719
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
766 else if (from->ty == Tdelegate)
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
767 {
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
768 Type* dgty = to->toBasetype();
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
769 assert(dgty->ty == Tdelegate);
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
770 if (val->isLVal())
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
771 {
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
772 LLValue* ptr = val->getLVal();
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
773 assert(isaPointer(ptr));
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
774 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
775 if (Logger::enabled())
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
776 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
777 return new DVarValue(to, ptr);
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
778 }
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
779 else
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
780 {
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
781 LLValue* dg = val->getRVal();
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
782 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
783 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
784 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
785 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
786 if (Logger::enabled())
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
787 Logger::cout() << "dg: " << *aggr << '\n';
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
788 return new DImValue(to, aggr);
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
789 }
7261ff0f95ff Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 715
diff changeset
790 }
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
791 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
792 {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
793 Type* b = to->toBasetype();
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
794 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
795 LLValue* ptr = DtoBitCast(val->getRVal(), DtoType(b));
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
796 return new DImValue(to, ptr);
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
797 }
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
798 else
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
799 {
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
800 assert(!val->isLVal());
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
801 assert(DtoType(to) == DtoType(to));
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
802 return new DImValue(to, val->getRVal());
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
803 }
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
804 }
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
805
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
806 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
807 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
808 // TEMPLATE HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
809 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
810
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
811 bool DtoIsTemplateInstance(Dsymbol* s)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
812 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
813 if (!s) return false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
814 if (s->isTemplateInstance() && !s->isTemplateMixin())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
815 return true;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
816 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
817 return DtoIsTemplateInstance(s->parent);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
818 return false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
819 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
820
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
821 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
822 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
823 // LAZY STATIC INIT HELPER
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
824 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
825
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
826 void DtoLazyStaticInit(bool istempl, LLValue* gvar, Initializer* init, Type* t)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
827 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
828 // create a flag to make sure initialization only happens once
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
829 llvm::GlobalValue::LinkageTypes gflaglink = istempl ? llvm::GlobalValue::WeakLinkage : llvm::GlobalValue::InternalLinkage;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
830 std::string gflagname(gvar->getName());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
831 gflagname.append("__initflag");
611
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
832 llvm::GlobalVariable* gflag = new llvm::GlobalVariable(LLType::Int1Ty,false,gflaglink,DtoConstBool(false),gflagname,gIR->module);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
833
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
834 // check flag and do init if not already done
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
835 llvm::BasicBlock* oldend = gIR->scopeend();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
836 llvm::BasicBlock* initbb = llvm::BasicBlock::Create("ifnotinit",gIR->topfunc(),oldend);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
837 llvm::BasicBlock* endinitbb = llvm::BasicBlock::Create("ifnotinitend",gIR->topfunc(),oldend);
611
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
838 LLValue* cond = gIR->ir->CreateICmpEQ(gIR->ir->CreateLoad(gflag,"tmp"),DtoConstBool(false));
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
839 gIR->ir->CreateCondBr(cond, initbb, endinitbb);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
840 gIR->scope() = IRScope(initbb,endinitbb);
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
841 DValue* ie = DtoInitializer(gvar, init);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
842
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
843 DVarValue dst(t, gvar);
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
844 DtoAssign(init->loc, &dst, ie);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
845
611
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
846 gIR->ir->CreateStore(DtoConstBool(true), gflag);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
847 gIR->ir->CreateBr(endinitbb);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
848 gIR->scope() = IRScope(endinitbb,oldend);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
849 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
850
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
851 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
852 /*////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
853 // 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
854 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
855
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
856 void 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
857 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
858 if (StructDeclaration* sd = dsym->isStructDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
859 DtoResolveStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
860 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
861 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
862 DtoResolveClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
863 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
864 else if (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
865 DtoResolveFunction(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
866 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
867 else if (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
868 DtoResolveTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
869 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
870 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
871 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
872 assert(0 && "unsupported dsymbol for DtoResolveDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
873 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
874 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
875
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
876 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
877
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
878 void DtoDeclareDsymbol(Dsymbol* dsym)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
879 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
880 if (StructDeclaration* sd = dsym->isStructDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
881 DtoDeclareStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
882 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
883 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
884 DtoDeclareClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
885 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
886 else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
887 DtoDeclareFunction(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
888 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
889 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
890 DtoDeclareTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
891 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
892 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
893 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
894 assert(0 && "unsupported dsymbol for DtoDeclareDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
895 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
896 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
897
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
898 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
899
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
900 void DtoConstInitDsymbol(Dsymbol* dsym)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
901 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
902 if (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
903 DtoConstInitStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
904 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
905 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
906 DtoConstInitClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
907 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
908 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
909 DtoConstInitTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
910 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
911 else if (VarDeclaration* vd = dsym->isVarDeclaration()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
912 DtoConstInitGlobal(vd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
913 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
914 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
915 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
916 assert(0 && "unsupported dsymbol for DtoConstInitDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
917 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
918 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
919
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
920 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
921
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
922 void DtoDefineDsymbol(Dsymbol* dsym)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
923 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
924 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
925 DtoDefineStruct(sd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
926 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
927 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
928 DtoDefineClass(cd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
929 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
930 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
931 DtoDefineFunc(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
932 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
933 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
934 DtoDefineTypeInfo(fd);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
935 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
936 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
937 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
938 assert(0 && "unsupported dsymbol for DtoDefineDsymbol");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
939 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
940 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
941
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
942 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
943
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
944 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
945 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
946 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
947 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
948
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
949 Logger::println("* DtoConstInitGlobal(%s)", vd->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
950 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
951
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
952 bool emitRTstaticInit = false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
953
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
954 LLConstant* _init = 0;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
955 if (vd->parent && vd->parent->isFuncDeclaration() && vd->init && vd->init->isExpInitializer()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
956 _init = DtoConstInitializer(vd->type, NULL);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
957 emitRTstaticInit = true;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
958 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
959 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
960 _init = DtoConstInitializer(vd->type, vd->init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
961 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
962
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
963 const LLType* _type = DtoType(vd->type);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
964 Type* t = vd->type->toBasetype();
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
965
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
966 //Logger::cout() << "initializer: " << *_init << '\n';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
967 if (_type != _init->getType()) {
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
968 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
969 Logger::cout() << "got type '" << *_init->getType() << "' expected '" << *_type << "'\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
970
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
971 // zero initalizer
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
972 if (_init->isNullValue())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
973 _init = llvm::Constant::getNullValue(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
974 // pointer to global constant (struct.init)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
975 else if (llvm::isa<llvm::GlobalVariable>(_init))
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
976 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
977 assert(_init->getType()->getContainedType(0) == _type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
978 llvm::GlobalVariable* gv = llvm::cast<llvm::GlobalVariable>(_init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
979 assert(t->ty == Tstruct);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
980 TypeStruct* ts = (TypeStruct*)t;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
981 assert(ts->sym->ir.irStruct->constInit);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
982 _init = ts->sym->ir.irStruct->constInit;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
983 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
984 // array single value init
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
985 else if (isaArray(_type))
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
986 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
987 _init = DtoConstStaticArray(_type, _init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
988 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
989 else {
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
990 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
991 Logger::cout() << "Unexpected initializer type: " << *_type << '\n';
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
992 //assert(0);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
993 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
994 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
995
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
996 bool istempl = false;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
997 if ((vd->storage_class & STCcomdat) || (vd->parent && DtoIsTemplateInstance(vd->parent))) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
998 istempl = true;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
999 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1000
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1001 if (_init && _init->getType() != _type)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1002 _type = _init->getType();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1003 llvm::cast<LLOpaqueType>(vd->ir.irGlobal->type.get())->refineAbstractTypeTo(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1004 _type = vd->ir.irGlobal->type.get();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1005
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1006 llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(vd->ir.irGlobal->value);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1007 if (!(vd->storage_class & STCextern) && (vd->getModule() == gIR->dmodule || istempl))
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1008 {
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
1009 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
1010 {
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
1011 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
1012 Logger::cout() << "global: " << *gvar << '\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
1013 Logger::cout() << "init: " << *_init << '\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
1014 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1015 gvar->setInitializer(_init);
250
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
1016 // do debug info
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
1017 if (global.params.symdebug)
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
1018 {
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
1019 LLGlobalVariable* gv = DtoDwarfGlobalVariable(gvar, vd);
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
1020 // keep a reference so GDCE doesn't delete it !
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
1021 gIR->usedArray.push_back(llvm::ConstantExpr::getBitCast(gv, getVoidPtrType()));
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 244
diff changeset
1022 }
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1023 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1024
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1025 if (emitRTstaticInit)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1026 DtoLazyStaticInit(istempl, gvar, vd->init, t);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1027 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1028
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1029 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1030
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1031 void DtoEmptyResolveList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1032 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1033 //Logger::println("DtoEmptyResolveList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1034 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1035 while (!gIR->resolveList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1036 dsym = gIR->resolveList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1037 gIR->resolveList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1038 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1039 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1040 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1041
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1042 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1043
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1044 void DtoEmptyDeclareList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1045 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1046 //Logger::println("DtoEmptyDeclareList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1047 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1048 while (!gIR->declareList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1049 dsym = gIR->declareList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1050 gIR->declareList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1051 DtoDeclareDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1052 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1053 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1054
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1055 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1056
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1057 void DtoEmptyConstInitList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1058 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1059 //Logger::println("DtoEmptyConstInitList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1060 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1061 while (!gIR->constInitList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1062 dsym = gIR->constInitList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1063 gIR->constInitList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1064 DtoConstInitDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1065 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1066 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1067
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1068 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1069
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1070 void DtoEmptyDefineList()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1071 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1072 //Logger::println("DtoEmptyDefineList()");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1073 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1074 while (!gIR->defineList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1075 dsym = gIR->defineList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1076 gIR->defineList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1077 DtoDefineDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1078 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1079 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1080
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1081 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1082 void DtoEmptyAllLists()
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1083 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1084 for(;;)
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 Dsymbol* dsym;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1087 if (!gIR->resolveList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1088 dsym = gIR->resolveList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1089 gIR->resolveList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1090 DtoResolveDsymbol(dsym);
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 else if (!gIR->declareList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1093 dsym = gIR->declareList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1094 gIR->declareList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1095 DtoDeclareDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1096 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1097 else if (!gIR->constInitList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1098 dsym = gIR->constInitList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1099 gIR->constInitList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1100 DtoConstInitDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1101 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1102 else if (!gIR->defineList.empty()) {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1103 dsym = gIR->defineList.front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1104 gIR->defineList.pop_front();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1105 DtoDefineDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1106 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1107 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1108 break;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1109 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1110 }
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
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
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1115 void DtoForceDeclareDsymbol(Dsymbol* dsym)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1116 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1117 if (dsym->ir.declared) return;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1118 Logger::println("DtoForceDeclareDsymbol(%s)", dsym->toPrettyChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1119 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1120 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1121
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1122 DtoEmptyResolveList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1123
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1124 DtoDeclareDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1125 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1126
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1127 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1128
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1129 void DtoForceConstInitDsymbol(Dsymbol* dsym)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1130 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1131 if (dsym->ir.initialized) return;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1132 Logger::println("DtoForceConstInitDsymbol(%s)", dsym->toPrettyChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1133 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1134 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1135
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1136 DtoEmptyResolveList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1137 DtoEmptyDeclareList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1138
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1139 DtoConstInitDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1140 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1141
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1142 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1143
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1144 void DtoForceDefineDsymbol(Dsymbol* dsym)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1145 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1146 if (dsym->ir.defined) return;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1147 Logger::println("DtoForceDefineDsymbol(%s)", dsym->toPrettyChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1148 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1149 DtoResolveDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1150
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1151 DtoEmptyResolveList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1152 DtoEmptyDeclareList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1153 DtoEmptyConstInitList();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1154
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1155 DtoDefineDsymbol(dsym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1156 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1157
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1158 /****************************************************************************************/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1159 /*////////////////////////////////////////////////////////////////////////////////////////
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
1160 // 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
1161 ////////////////////////////////////////////////////////////////////////////////////////*/
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1162 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
1163 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1164 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
1165 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
1166
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1167 // 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
1168 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
1169 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1170 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
1171
648
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1172 // 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
1173 // 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
1174 // 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
1175 if (vd->aliassym)
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1176 return DtoDeclarationExp(vd->aliassym);
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1177
433
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1178 // 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
1179 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
1180 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1181 vd->toObjFile(0); // TODO: multiobj
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1182 }
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
1183 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
1184 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1185 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
1186 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
1187
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1188 Logger::println("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
1189
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1190 // 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
1191 #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
1192 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
1193 #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
1194 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
1195 #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
1196 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
1197 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
1198
704
43165a082535 Fixed issue with accessing a WithStatement context from inside a nested function. see mini/with2.d
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 683
diff changeset
1199 // alloca as usual if no value already
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
1200 if (!vd->ir.irLocal->value)
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1201 {
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
1202 vd->ir.irLocal->value = DtoAlloca(DtoType(vd->type), vd->toChars());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1203 }
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
1204
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
1205 // store the address into the nested vars array
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1206
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
1207 assert(vd->ir.irLocal->nestedIndex >= 0);
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1208 LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, vd->ir.irLocal->nestedIndex);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1209
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
1210 assert(isaPointer(vd->ir.irLocal->value));
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1211 LLValue* val = DtoBitCast(vd->ir.irLocal->value, getVoidPtrType());
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1212
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
1213 DtoStore(val, gep);
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 483
diff changeset
1214
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
1215 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1216 // 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
1217 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
1218 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
1219
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1220 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
1221 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
1222 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
1223 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
1224 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
1225
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1226 //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
1227 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
1228 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
1229
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1230 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
1231 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1232 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
1233 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1234 }
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
1235 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
1236 {
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
1237 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
1238 }
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
1239
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
1240 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
1241 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
1242 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
1243 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1244
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
1245 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
1246 }
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1247 // 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
1248 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
1249 {
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1250 Logger::println("StructDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1251 DtoForceConstInitDsymbol(s);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1252 }
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
1253 // 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
1254 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
1255 {
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
1256 Logger::println("FuncDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1257 DtoForceDeclareDsymbol(f);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1258 }
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
1259 // 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
1260 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
1261 {
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
1262 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
1263 // 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
1264 }
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
1265 // 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
1266 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
1267 {
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
1268 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
1269 // 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
1270 }
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
1271 // 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
1272 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
1273 {
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
1274 Logger::println("ClassDeclaration");
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1275 DtoForceConstInitDsymbol(e);
b5f55f471e0b Move DeclarationExp code into a helper function so it can call itself for template mixin members.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
1276 }
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
1277 // 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
1278 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
1279 {
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
1280 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
1281 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
1282 }
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
1283 // 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
1284 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
1285 {
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
1286 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
1287 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
1288 {
590
1ecb43102d12 Allow VarDecl inside AttributeDecl inside DeclExp.
Christian Kamm <kamm incasoftware de>
parents: 585
diff changeset
1289 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
1290 }
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
1291 }
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
1292 // 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
1293 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
1294 {
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
1295 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
1296 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
1297 {
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
1298 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
1299 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
1300 }
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
1301 }
648
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1302 // tuple declaration
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1303 else if (TupleDeclaration* tupled = declaration->isTupleDeclaration())
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1304 {
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1305 Logger::println("TupleDeclaration");
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1306 if(!tupled->isexp) {
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1307 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
1308 assert(0);
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1309 }
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1310
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1311 assert(tupled->objects);
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1312 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
1313 {
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1314 DsymbolExp* exp = (DsymbolExp*)tupled->objects->data[i];
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1315 DtoDeclarationExp(exp->s);
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1316 }
8d850fa25713 Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents: 639
diff changeset
1317 }
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
1318 // 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
1319 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
1320 {
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
1321 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
1322 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
1323 }
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
1324 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
1325 }
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
1326
747
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1327 // does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1328 LLValue* DtoRawVarDeclaration(VarDeclaration* var)
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1329 {
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1330 // 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
1331 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
1332
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1333 // 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
1334 assert(!var->aliassym);
773
5696a7167b21 Fix RawVarDecl double codegen bug. Thanks to downs for the testcase.
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
1335
5696a7167b21 Fix RawVarDecl double codegen bug. Thanks to downs for the testcase.
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
1336 // if this already has storage, it must've been handled already
5696a7167b21 Fix RawVarDecl double codegen bug. Thanks to downs for the testcase.
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
1337 if (var->ir.irLocal && var->ir.irLocal->value)
5696a7167b21 Fix RawVarDecl double codegen bug. Thanks to downs for the testcase.
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
1338 return 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
1339
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1340 // 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
1341 #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
1342 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
1343 #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
1344 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
1345 #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
1346 {
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1347 assert(var->ir.irLocal);
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1348 assert(!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
1349
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1350 // alloca
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1351 var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars());
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1352
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1353 // store the address into the nested vars array
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1354 assert(var->ir.irLocal->nestedIndex >= 0);
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1355 LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, var->ir.irLocal->nestedIndex);
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1356 assert(isaPointer(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
1357 LLValue* val = DtoBitCast(var->ir.irLocal->value, getVoidPtrType());
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1358 DtoStore(val, gep);
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1359 }
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1360 // 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
1361 else
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1362 {
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1363 assert(!var->ir.isSet());
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1364 var->ir.irLocal = new IrLocal(var);
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1365 var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars());
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1366 }
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1367
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1368 // add debug info
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1369 if (global.params.symdebug)
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1370 DtoDwarfLocalVariable(var->ir.irLocal->value, var);
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1371
46d0755451a4 Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 719
diff changeset
1372 // 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
1373 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
1374 }
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
1375
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
1376 /****************************************************************************************/
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
1377 /*////////////////////////////////////////////////////////////////////////////////////////
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1378 // INITIALIZER HELPERS
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1379 ////////////////////////////////////////////////////////////////////////////////////////*/
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1380
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1381 LLConstant* DtoConstInitializer(Type* type, Initializer* init)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1382 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1383 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
1384 if (!init)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1385 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1386 Logger::println("const default initializer for %s", type->toChars());
502
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1387 _init = DtoDefaultInit(type);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1388 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1389 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
1390 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1391 Logger::println("const expression initializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1392 _init = ex->exp->toConstElem(gIR);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1393 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1394 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
1395 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1396 Logger::println("const struct initializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1397 _init = DtoConstStructInitializer(si);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1398 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1399 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
1400 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1401 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
1402 _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
1403 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1404 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
1405 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1406 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
1407 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
1408 _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
1409 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1410 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1411 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
1412 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1413 return _init;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1414 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1415
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1416 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1417
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1418 LLConstant* DtoConstFieldInitializer(Type* t, Initializer* init)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1419 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1420 Logger::println("DtoConstFieldInitializer");
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1421 LOG_SCOPE;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1422
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1423 const LLType* _type = DtoType(t);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1424
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1425 LLConstant* _init = DtoConstInitializer(t, init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1426 assert(_init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1427 if (_type != _init->getType())
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1428 {
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
1429 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
1430 Logger::cout() << "field init is: " << *_init << " type should be " << *_type << '\n';
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1431 if (t->ty == Tsarray)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1432 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1433 const LLArrayType* arrty = isaArray(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1434 uint64_t n = arrty->getNumElements();
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1435 std::vector<LLConstant*> vals(n,_init);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1436 _init = llvm::ConstantArray::get(arrty, vals);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1437 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1438 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
1439 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1440 assert(isaStruct(_type));
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1441 _init = llvm::ConstantAggregateZero::get(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1442 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1443 else if (t->ty == Tstruct)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1444 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1445 const LLStructType* structty = isaStruct(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1446 TypeStruct* ts = (TypeStruct*)t;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1447 assert(ts);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1448 assert(ts->sym);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1449 assert(ts->sym->ir.irStruct->constInit);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1450 _init = ts->sym->ir.irStruct->constInit;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1451 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1452 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
1453 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1454 _init = llvm::Constant::getNullValue(_type);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1455 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1456 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1457 Logger::println("failed for type %s", t->toChars());
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1458 assert(0);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1459 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1460 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1461
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1462 return _init;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1463 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1464
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1465 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1466
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1467 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
1468 {
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
1469 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
1470 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
1471 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
1472 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1473 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
1474 assert(ex->exp);
482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1475 DValue* res = ex->exp->toElem(gIR);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1476
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1477 assert(llvm::isa<llvm::PointerType>(target->getType()) && "init target must be ptr");
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1478 const LLType* targetty = target->getType()->getContainedType(0);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1479 if(targetty == LLType::X86_FP80Ty)
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1480 {
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1481 Logger::println("setting fp80 padding to zero");
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1482
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1483 LLValue* castv = DtoBitCast(target, getPtrToType(LLType::Int16Ty));
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1484 LLValue* padding = DtoGEPi1(castv, 5);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1485 DtoStore(llvm::Constant::getNullValue(LLType::Int16Ty), padding);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1486 }
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1487 else if(targetty == DtoComplexType(Type::tcomplex80))
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1488 {
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1489 Logger::println("setting complex fp80 padding to zero");
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1490
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1491 LLValue* castv = DtoBitCast(target, getPtrToType(LLType::Int16Ty));
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1492 LLValue* padding = DtoGEPi1(castv, 5);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1493 DtoStore(llvm::Constant::getNullValue(LLType::Int16Ty), padding);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1494 padding = DtoGEPi1(castv, 11);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1495 DtoStore(llvm::Constant::getNullValue(LLType::Int16Ty), padding);
aa8c050dfd19 Move zero init of padding to DtoInitializer in order to respect void initializers.
Christian Kamm <kamm incasoftware de>
parents: 481
diff changeset
1496 }
483
d86af825e8d9 Forgot return in DtoInitializer
Christian Kamm <kamm incasoftware de>
parents: 482
diff changeset
1497
d86af825e8d9 Forgot return in DtoInitializer
Christian Kamm <kamm incasoftware de>
parents: 482
diff changeset
1498 return res;
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1499 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1500 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
1501 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1502 // do nothing
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1503 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1504 else {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1505 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
1506 assert(0);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1507 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1508 return 0;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1509 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1510
502
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1511 //////////////////////////////////////////////////////////////////////////////////////////
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1512
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1513 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
1514 {
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
1515 Logger::println("building type %s to 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
1516 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
1517 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
1518 Logger::cout() << "final llvm type requested: " << *dstTy << '\n';
502
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1519
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1520 LLConstant* val = exp->toConstElem(gIR);
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1521
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1522 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
1523 Type* t = base;
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1524
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1525 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
1526
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1527 while(1)
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1528 {
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1529 if (t->equals(expbase))
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1530 break;
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1531 assert(t->ty == Tsarray);
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1532 TypeSArray* tsa = (TypeSArray*)t;
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1533 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
1534 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
1535 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
1536 }
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1537
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1538 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
1539 assert(i);
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1540
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1541 std::vector<LLConstant*> inits;
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1542 while (i--)
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1543 {
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1544 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
1545 inits.clear();
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1546 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
1547 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
1548 }
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1549
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1550 return val;
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1551 }
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1552
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1553 LLConstant* DtoDefaultInit(Type* type)
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1554 {
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1555 Expression* exp = type->defaultInit();
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1556
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1557 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
1558 Type* base = type->toBasetype();
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1559
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1560 // 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
1561 if (!expbase->equals(base))
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1562 {
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1563 if (base->ty == Tsarray)
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1564 {
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
1565 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
1566 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
1567 }
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1568 else
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1569 {
715
30b42a283c8e Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 709
diff changeset
1570 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
1571 fatal();
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1572 }
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1573 assert(0);
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1574
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1575 }
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1576
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1577 return exp->toConstElem(gIR);
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1578 }
837af2a63564 Fixed problems constant multidimensional static array initializers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
1579
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1580
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1581 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1582
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1583 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
1584 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1585 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
1586 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
1587 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
1588 while (*p)
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1589 {
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1590 if (*p == '"')
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1591 *p = '\'';
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1592 ++p;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1593 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1594 // create a noop with the code as the result name!
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1595 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
1596 }
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1597
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1598 //////////////////////////////////////////////////////////////////////////////////////////
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1599
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1600 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
1601 {
290
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1602 type = type->merge(); // needed.. getTypeInfo does the same
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1603 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
1604 TypeInfoDeclaration* tidecl = type->vtinfo;
290
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1605 assert(tidecl);
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1606 DtoForceDeclareDsymbol(tidecl);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1607 assert(tidecl->ir.irGlobal != NULL);
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1608 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
1609 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
1610 if (base)
290
ebaf65fc4726 [svn r311] Fixed: structs no longer output two static typeinfos.
lindquist
parents: 289
diff changeset
1611 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
1612 return c;
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
diff changeset
1613 }
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
1614
289
17d3b3236334 [svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents: 284
diff changeset
1615 //////////////////////////////////////////////////////////////////////////////////////////
17d3b3236334 [svn r310] Fixed a problem with incomplete types and templates in typeinfo code.
lindquist
parents: 284
diff changeset
1616
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
1617 LLValue* DtoBoolean(Loc& loc, DValue* dval)
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1618 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1619 Type* dtype = dval->getType()->toBasetype();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1620 TY ty = dtype->ty;
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1621
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1622 // integer
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1623 if (dtype->isintegral())
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1624 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1625 LLValue* val = dval->getRVal();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1626 if (val->getType() == LLType::Int1Ty)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1627 return val;
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1628 else {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1629 LLValue* zero = LLConstantInt::get(val->getType(), 0, false);
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1630 return gIR->ir->CreateICmpNE(val, zero, "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1631 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1632 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1633 // complex
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1634 else if (dtype->iscomplex())
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1635 {
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 373
diff changeset
1636 return DtoComplexEquals(loc, TOKnotequal, dval, DtoNullValue(dtype));
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1637 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1638 // floating point
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1639 else if (dtype->isfloating())
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1640 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1641 LLValue* val = dval->getRVal();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1642 LLValue* zero = LLConstant::getNullValue(val->getType());
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1643 return gIR->ir->CreateFCmpONE(val, zero, "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1644 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1645 // pointer/class
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1646 else if (ty == Tpointer || ty == Tclass) {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1647 LLValue* val = dval->getRVal();
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1648 LLValue* zero = LLConstant::getNullValue(val->getType());
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
1649 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
1650 {
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
1651 Logger::cout() << "val: " << *val << '\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
1652 Logger::cout() << "zero: " << *zero << '\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
1653 }
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1654 return gIR->ir->CreateICmpNE(val, zero, "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1655 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1656 // dynamic array
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1657 else if (ty == Tarray)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1658 {
670
4f004553de33 Fixed dynamic array -> boolean. does (arr.ptr !is null) now instead of (arr.length != 0)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 657
diff changeset
1659 // return (arr.ptr !is null)
4f004553de33 Fixed dynamic array -> boolean. does (arr.ptr !is null) now instead of (arr.length != 0)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 657
diff changeset
1660 LLValue* ptr = DtoArrayPtr(dval);
4f004553de33 Fixed dynamic array -> boolean. does (arr.ptr !is null) now instead of (arr.length != 0)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 657
diff changeset
1661 LLConstant* nul = getNullPtr(ptr->getType());
4f004553de33 Fixed dynamic array -> boolean. does (arr.ptr !is null) now instead of (arr.length != 0)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 657
diff changeset
1662 return gIR->ir->CreateICmpNE(ptr, nul, "tmp");
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1663 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1664 // delegate
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1665 else if (ty == Tdelegate)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1666 {
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1667 // return (dg !is null)
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1668 return DtoDelegateEquals(TOKnotequal, dval->getRVal(), NULL);
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1669 }
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1670 // unknown
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1671 std::cout << "unsupported -> bool : " << dtype->toChars() << '\n';
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1672 assert(0);
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1673 return 0;
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 363
diff changeset
1674 }
527
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1675
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1676 //////////////////////////////////////////////////////////////////////////////////////////
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1677
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1678 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
1679 {
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1680 Logger::println("DtoOverloadedIntrinsicName");
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1681 LOG_SCOPE;
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1682
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1683 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
1684 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
1685 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
1686
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1687 // 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
1688 assert(ti->tdtypes.dim == 1);
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1689 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
1690
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1691 char tmp[10];
611
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
1692 if (T->toBasetype()->ty == Tbool) // otherwise we'd get a mismatch
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
1693 sprintf(tmp, "1");
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
1694 else
83ca663ecc20 Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents: 610
diff changeset
1695 sprintf(tmp, "%d", T->size()*8);
527
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1696
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1697 // replace # in name with bitsize
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1698 name = td->intrinsicName;
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1699
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1700 std::string needle("#");
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1701 size_t pos;
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1702 while(std::string::npos != (pos = name.find(needle)))
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1703 name.replace(pos, 1, tmp);
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1704
cecfee2d01a8 Added support for overloaded intrinsics.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 505
diff changeset
1705 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
1706 }