Mercurial > projects > ldc
annotate gen/tollvm.cpp @ 1509:e07f15c4ab4d
Automated merge with http://hg.dsource.org/projects/ldc
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 20 Jun 2009 19:12:04 +0200 |
parents | 855f188aab7a |
children | ad7f2f1862d6 |
rev | line source |
---|---|
1 | 1 |
40 | 2 #include "gen/llvm.h" |
1 | 3 |
4 #include "dsymbol.h" | |
5 #include "aggregate.h" | |
6 #include "declaration.h" | |
7 #include "init.h" | |
323
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
8 #include "module.h" |
1 | 9 |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
10 #include "gen/tollvm.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
11 #include "gen/irstate.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
12 #include "gen/logger.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
13 #include "gen/runtime.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
14 #include "gen/arrays.h" |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
15 #include "gen/dvalue.h" |
100 | 16 #include "gen/functions.h" |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
17 #include "gen/structs.h" |
100 | 18 #include "gen/classes.h" |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
19 #include "gen/typeinf.h" |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
20 #include "gen/complex.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
21 #include "gen/llvmhelpers.h" |
1064
f0b6549055ab
Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents:
1050
diff
changeset
|
22 #include "gen/linkage.h" |
1138
4c8bb03e4fbc
Update DtoConstFP() to be correct after LLVM r67562, which changed the way the
Frits van Bommel <fvbommel wxs.nl>
parents:
1064
diff
changeset
|
23 #include "gen/llvm-version.h" |
1 | 24 |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
25 #include "ir/irtype.h" |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
26 #include "ir/irtypeclass.h" |
1364
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1353
diff
changeset
|
27 #include "ir/irtypefunction.h" |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
28 |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
29 bool DtoIsPassedByRef(Type* type) |
40 | 30 { |
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:
464
diff
changeset
|
31 Type* typ = type->toBasetype(); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
32 TY t = typ->ty; |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
33 return (t == Tstruct || t == Tsarray); |
40 | 34 } |
35 | |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
36 unsigned DtoShouldExtend(Type* type) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
37 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
38 type = type->toBasetype(); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
39 if (type->isintegral()) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
40 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
41 switch(type->ty) |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
42 { |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
43 case Tint8: |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
44 case Tint16: |
632
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
45 return llvm::Attribute::SExt; |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
46 |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
47 case Tuns8: |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
48 case Tuns16: |
632
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
49 return llvm::Attribute::ZExt; |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
50 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
51 } |
632
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
52 return llvm::Attribute::None; |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
53 } |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
54 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
55 const LLType* DtoType(Type* t) |
1 | 56 { |
1504
855f188aab7a
Added a stripModifiers() function to remove shared|const|immutable storage classes in D2 (should eventually be moved to a dhelpers file rather than llvm helpers).
Robert Clipsham <robert@octarineparrot.com>
parents:
1501
diff
changeset
|
57 t = stripModifiers( t ); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
58 |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
59 if (t->irtype) |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
60 { |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
61 return t->irtype->get(); |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
62 } |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
63 |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
64 IF_LOG Logger::println("Building type: %s", t->toChars()); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
65 |
1 | 66 assert(t); |
67 switch (t->ty) | |
68 { | |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
69 // basic types |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
70 case Tvoid: |
1 | 71 case Tint8: |
72 case Tuns8: | |
73 case Tint16: | |
74 case Tuns16: | |
75 case Tint32: | |
76 case Tuns32: | |
77 case Tint64: | |
78 case Tuns64: | |
79 case Tfloat32: | |
80 case Tfloat64: | |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
81 case Tfloat80: |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
82 case Timaginary32: |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
83 case Timaginary64: |
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
84 case Timaginary80: |
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
85 case Tcomplex32: |
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
86 case Tcomplex64: |
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
87 case Tcomplex80: |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
88 //case Tbit: |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
89 case Tbool: |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
90 case Tchar: |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
91 case Twchar: |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
92 case Tdchar: |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
93 { |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
94 t->irtype = new IrTypeBasic(t); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
95 return t->irtype->buildType(); |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
96 } |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
97 |
1 | 98 // pointers |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
264
diff
changeset
|
99 case Tpointer: |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
100 { |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
101 t->irtype = new IrTypePointer(t); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
102 return t->irtype->buildType(); |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
103 } |
1 | 104 |
105 // arrays | |
106 case Tarray: | |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
107 { |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
108 t->irtype = new IrTypeArray(t); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
109 return t->irtype->buildType(); |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
110 } |
1 | 111 |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
112 case Tsarray: |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
113 { |
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
114 t->irtype = new IrTypeSArray(t); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
115 return t->irtype->buildType(); |
1192
3251ce06c820
Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1179
diff
changeset
|
116 } |
1 | 117 |
118 // aggregates | |
119 case Tstruct: { | |
103
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
120 TypeStruct* ts = (TypeStruct*)t; |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
121 t->irtype = new IrTypeStruct(ts->sym); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
122 return t->irtype->buildType(); |
1 | 123 } |
124 case Tclass: { | |
103
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
125 TypeClass* tc = (TypeClass*)t; |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
126 t->irtype = new IrTypeClass(tc->sym); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
127 return t->irtype->buildType(); |
1 | 128 } |
129 | |
130 // functions | |
131 case Tfunction: | |
132 { | |
1364
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1353
diff
changeset
|
133 t->irtype = new IrTypeFunction(t); |
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1353
diff
changeset
|
134 return t->irtype->buildType(); |
1 | 135 } |
6 | 136 |
1 | 137 // delegates |
138 case Tdelegate: | |
139 { | |
1364
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1353
diff
changeset
|
140 t->irtype = new IrTypeDelegate(t); |
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1353
diff
changeset
|
141 return t->irtype->buildType(); |
1 | 142 } |
143 | |
144 // typedefs | |
52 | 145 // enum |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
146 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1214
diff
changeset
|
147 // FIXME: maybe just call toBasetype first ? |
1 | 148 case Ttypedef: |
52 | 149 case Tenum: |
1 | 150 { |
151 Type* bt = t->toBasetype(); | |
152 assert(bt); | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
153 return DtoType(bt); |
1 | 154 } |
155 | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
156 // associative arrays |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
157 case Taarray: |
723
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
719
diff
changeset
|
158 return getVoidPtrType(); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
159 |
648
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
160 /* |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
161 Not needed atm as VarDecls for tuples are rewritten as a string of |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
162 VarDecls for the fields (u -> _u_field_0, ...) |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
163 |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
164 case Ttuple: |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
165 { |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
166 TypeTuple* ttupl = (TypeTuple*)t; |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
167 return DtoStructTypeFromArguments(ttupl->arguments); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
168 } |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
169 */ |
379
d632801b15f0
Introducing opaque type to dmd frontent to be used with certain runtime array
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
170 |
1 | 171 default: |
650
aa6a0b7968f7
Added test case for bug #100
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
648
diff
changeset
|
172 printf("trying to convert unknown type '%s' with value %d\n", t->toChars(), t->ty); |
1 | 173 assert(0); |
174 } | |
175 return 0; | |
176 } | |
177 | |
178 ////////////////////////////////////////////////////////////////////////////////////////// | |
179 | |
648
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
180 /* |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
181 const LLType* DtoStructTypeFromArguments(Arguments* arguments) |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
182 { |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
183 if (!arguments) |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
184 return LLType::VoidTy; |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
185 |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
186 std::vector<const LLType*> types; |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
187 for (size_t i = 0; i < arguments->dim; i++) |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
188 { |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
189 Argument *arg = (Argument *)arguments->data[i]; |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
190 assert(arg && arg->type); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
191 |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
192 types.push_back(DtoType(arg->type)); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
193 } |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
194 return LLStructType::get(types); |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
195 } |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
196 */ |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
197 |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
198 ////////////////////////////////////////////////////////////////////////////////////////// |
8d850fa25713
Fix VarDecls for tuples. Closes #99.
Christian Kamm <kamm incasoftware de>
parents:
637
diff
changeset
|
199 |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
200 const LLType* DtoTypeNotVoid(Type* t) |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
201 { |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
202 const LLType* lt = DtoType(t); |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
203 if (lt == LLType::VoidTy) |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
204 return LLType::Int8Ty; |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
205 return lt; |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
206 } |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
207 |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
208 ////////////////////////////////////////////////////////////////////////////////////////// |
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
209 |
344
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
210 LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs) |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
211 { |
344
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
212 Logger::println("Doing delegate equality"); |
177
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
173
diff
changeset
|
213 llvm::Value *b1, *b2; |
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
173
diff
changeset
|
214 if (rhs == NULL) |
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
173
diff
changeset
|
215 { |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
216 rhs = LLConstant::getNullValue(lhs->getType()); |
177
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
173
diff
changeset
|
217 } |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
218 |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
219 LLValue* l = gIR->ir->CreateExtractValue(lhs, 0); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
220 LLValue* r = gIR->ir->CreateExtractValue(rhs, 0); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
221 b1 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp"); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
222 |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
223 l = gIR->ir->CreateExtractValue(lhs, 1); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
224 r = gIR->ir->CreateExtractValue(rhs, 1); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
225 b2 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp"); |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
226 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
227 LLValue* b = gIR->ir->CreateAnd(b1,b2,"tmp"); |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
228 |
177
cea8dcfa76df
[svn r193] Fixed: abstract classes implementing interfaces now output proper Interface info arrays. (null vtables).
lindquist
parents:
173
diff
changeset
|
229 if (op == TOKnotequal || op == TOKnotidentity) |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
230 return gIR->ir->CreateNot(b,"tmp"); |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
231 |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
232 return b; |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
233 } |
1 | 234 |
235 ////////////////////////////////////////////////////////////////////////////////////////// | |
236 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
237 LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym) |
1 | 238 { |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
239 // global variable |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
240 if (VarDeclaration* vd = sym->isVarDeclaration()) |
1 | 241 { |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
242 if (mustDefineSymbol(vd)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
243 Logger::println("Variable %savailable externally: %s", (vd->availableExternally ? "" : "not "), vd->toChars()); |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
244 #if LLVM_REV >= 68940 |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
245 // generated by inlining semantics run |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
246 if (vd->availableExternally && mustDefineSymbol(sym)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
247 return llvm::GlobalValue::AvailableExternallyLinkage; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
248 #endif |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
249 // template |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
250 if (needsTemplateLinkage(sym)) |
918
a4fcc13da3cd
Changed templates and typeinfo to use linkonce linkage instead of weak linkage, this should fix inlining problems, fixing bug #197 . If problems show up, it's easy to change it back by changing the define in mars.h . I'm 95% sure this is safe, given how we handle templates.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
896
diff
changeset
|
251 return TEMPLATE_LINKAGE_TYPE; |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
252 } |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
253 // function |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
254 else if (FuncDeclaration* fdecl = sym->isFuncDeclaration()) |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
255 { |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
256 if (mustDefineSymbol(fdecl)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
257 Logger::println("Function %savailable externally: %s", (fdecl->availableExternally ? "" : "not "), fdecl->toChars()); |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
258 assert(fdecl->type->ty == Tfunction); |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
259 TypeFunction* ft = (TypeFunction*)fdecl->type; |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
260 |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
261 // intrinsics are always external |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
262 if (fdecl->llvmInternal == LLVMintrinsic) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
263 return llvm::GlobalValue::ExternalLinkage; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
264 #if LLVM_REV >= 68940 |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
265 // generated by inlining semantics run |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
266 if (fdecl->availableExternally && mustDefineSymbol(sym)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
267 return llvm::GlobalValue::AvailableExternallyLinkage; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
268 #endif |
1279
04c36605feb9
Fixed array operation codegen when used from imported templates. All array operations are now emitted with template linkage. Fixed #270 .
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1242
diff
changeset
|
269 // array operations are always template linkage |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
661
diff
changeset
|
270 if (fdecl->isArrayOp) |
1279
04c36605feb9
Fixed array operation codegen when used from imported templates. All array operations are now emitted with template linkage. Fixed #270 .
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1242
diff
changeset
|
271 return TEMPLATE_LINKAGE_TYPE; |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
272 // template instances should have weak linkage |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
918
diff
changeset
|
273 // but only if there's a body, and it's not naked |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
918
diff
changeset
|
274 // otherwise we make it external |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
275 else if (needsTemplateLinkage(fdecl) && fdecl->fbody && !fdecl->naked) |
918
a4fcc13da3cd
Changed templates and typeinfo to use linkonce linkage instead of weak linkage, this should fix inlining problems, fixing bug #197 . If problems show up, it's easy to change it back by changing the define in mars.h . I'm 95% sure this is safe, given how we handle templates.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
896
diff
changeset
|
276 return TEMPLATE_LINKAGE_TYPE; |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
277 // extern(C) functions are always external |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
278 else if (ft->linkage == LINKc) |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
279 return llvm::GlobalValue::ExternalLinkage; |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
280 } |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
281 // class |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
282 else if (ClassDeclaration* cd = sym->isClassDeclaration()) |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
283 { |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
284 if (mustDefineSymbol(cd)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
285 Logger::println("Class %savailable externally: %s", (cd->availableExternally ? "" : "not "), vd->toChars()); |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
286 #if LLVM_REV >= 68940 |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
287 // generated by inlining semantics run |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
288 if (cd->availableExternally && mustDefineSymbol(sym)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
289 return llvm::GlobalValue::AvailableExternallyLinkage; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
290 #endif |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
291 // template |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
292 if (needsTemplateLinkage(cd)) |
918
a4fcc13da3cd
Changed templates and typeinfo to use linkonce linkage instead of weak linkage, this should fix inlining problems, fixing bug #197 . If problems show up, it's easy to change it back by changing the define in mars.h . I'm 95% sure this is safe, given how we handle templates.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
896
diff
changeset
|
293 return TEMPLATE_LINKAGE_TYPE; |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
294 } |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
295 else |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
296 { |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
297 assert(0 && "not global/function"); |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
298 } |
1214
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
299 |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
300 // The following breaks for nested naked functions and other declarations, so check for that. |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
301 bool skipNestedCheck = !mustDefineSymbol(sym); |
1221
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
302 if (FuncDeclaration* fd = sym->isFuncDeclaration()) |
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
303 skipNestedCheck = (fd->naked != 0); |
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
304 |
1214
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
305 // Any symbol nested in a function can't be referenced directly from |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
306 // outside that function, so we can give such symbols internal linkage. |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
307 // This holds even if nested indirectly, such as member functions of |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
308 // aggregates nested in functions. |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
309 // |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
310 // Note: This must be checked after things like template member-ness or |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
311 // symbols nested in templates would get duplicated for each module, |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
312 // breaking things like |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
313 // --- |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
314 // int counter(T)() { static int i; return i++; }" |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
315 // --- |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
316 // if instances get emitted in multiple object files because they'd use |
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
317 // different instances of 'i'. |
1221
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
318 if (!skipNestedCheck) |
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
319 for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) { |
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
320 if (parent->isFuncDeclaration()) |
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
321 return llvm::GlobalValue::InternalLinkage; |
f41ff8ccc249
Unbreak nested naked functions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1218
diff
changeset
|
322 } |
1214
7e5547d8e59f
Give all symbols nested in functions internal linkage, unless it's one of the
Frits van Bommel <fvbommel wxs.nl>
parents:
1210
diff
changeset
|
323 |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
324 // default to external linkage |
1 | 325 return llvm::GlobalValue::ExternalLinkage; |
326 } | |
327 | |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
328 static bool isAvailableExternally(Dsymbol* sym) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
329 { |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
330 if (VarDeclaration* vd = sym->isVarDeclaration()) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
331 return vd->availableExternally; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
332 if (FuncDeclaration* fd = sym->isFuncDeclaration()) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
333 return fd->availableExternally; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
334 if (AggregateDeclaration* ad = sym->isAggregateDeclaration()) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
335 return ad->availableExternally; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
336 return false; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
337 } |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
338 |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
339 llvm::GlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym) |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
340 { |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
341 if (needsTemplateLinkage(sym)) { |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
342 #if LLVM_REV >= 68940 |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
343 if (isAvailableExternally(sym) && mustDefineSymbol(sym)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
344 return llvm::GlobalValue::AvailableExternallyLinkage; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
345 #endif |
918
a4fcc13da3cd
Changed templates and typeinfo to use linkonce linkage instead of weak linkage, this should fix inlining problems, fixing bug #197 . If problems show up, it's easy to change it back by changing the define in mars.h . I'm 95% sure this is safe, given how we handle templates.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
896
diff
changeset
|
346 return TEMPLATE_LINKAGE_TYPE; |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
347 } |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
348 else |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
349 return llvm::GlobalValue::InternalLinkage; |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
350 } |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
351 |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
352 llvm::GlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym) |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
353 { |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
354 #if LLVM_REV >= 68940 |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
355 if (isAvailableExternally(sym) && mustDefineSymbol(sym)) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
356 return llvm::GlobalValue::AvailableExternallyLinkage; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1480
diff
changeset
|
357 #endif |
940
39519a1ff603
Changed the way LDC determines if a template instantiation needs to get a definition, seems to speed up compile times quite a bit in some cases.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
358 if (needsTemplateLinkage(sym)) |
918
a4fcc13da3cd
Changed templates and typeinfo to use linkonce linkage instead of weak linkage, this should fix inlining problems, fixing bug #197 . If problems show up, it's easy to change it back by changing the define in mars.h . I'm 95% sure this is safe, given how we handle templates.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
896
diff
changeset
|
359 return TEMPLATE_LINKAGE_TYPE; |
149
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
360 else |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
361 return llvm::GlobalValue::ExternalLinkage; |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
362 } |
4c577c2b7229
[svn r155] Fixed a bunch of linkage problems (especially with templates)
lindquist
parents:
144
diff
changeset
|
363 |
1 | 364 ////////////////////////////////////////////////////////////////////////////////////////// |
365 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
366 LLValue* DtoPointedType(LLValue* ptr, LLValue* val) |
1 | 367 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
368 const LLType* ptrTy = ptr->getType()->getContainedType(0); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
369 const LLType* valTy = val->getType(); |
1 | 370 // ptr points to val's type |
371 if (ptrTy == valTy) | |
372 { | |
373 return val; | |
374 } | |
375 // ptr is integer pointer | |
376 else if (ptrTy->isInteger()) | |
377 { | |
378 // val is integer | |
379 assert(valTy->isInteger()); | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
380 const LLIntegerType* pt = llvm::cast<const LLIntegerType>(ptrTy); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
381 const LLIntegerType* vt = llvm::cast<const LLIntegerType>(valTy); |
1 | 382 if (pt->getBitWidth() < vt->getBitWidth()) { |
383 return new llvm::TruncInst(val, pt, "tmp", gIR->scopebb()); | |
384 } | |
385 else | |
386 assert(0); | |
387 } | |
388 // something else unsupported | |
389 else | |
390 { | |
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:
618
diff
changeset
|
391 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:
618
diff
changeset
|
392 Logger::cout() << *ptrTy << '|' << *valTy << '\n'; |
1 | 393 assert(0); |
394 } | |
395 return 0; | |
396 } | |
397 | |
398 ////////////////////////////////////////////////////////////////////////////////////////// | |
399 | |
1501
8b9f236dd051
Build fix for LLVM >= r73431
Benjamin Kramer <benny.kra@gmail.com>
parents:
1482
diff
changeset
|
400 const LLIntegerType* DtoSize_t() |
1 | 401 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
402 // the type of size_t does not change once set |
1501
8b9f236dd051
Build fix for LLVM >= r73431
Benjamin Kramer <benny.kra@gmail.com>
parents:
1482
diff
changeset
|
403 static const LLIntegerType* t = NULL; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
404 if (t == NULL) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
405 t = (global.params.is64bit) ? LLType::Int64Ty : LLType::Int32Ty; |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
406 return t; |
40 | 407 } |
408 | |
409 ////////////////////////////////////////////////////////////////////////////////////////// | |
410 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
411 LLValue* DtoGEP1(LLValue* ptr, LLValue* i0, const char* var, llvm::BasicBlock* bb) |
100 | 412 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
413 return llvm::GetElementPtrInst::Create(ptr, i0, var?var:"tmp", bb?bb:gIR->scopebb()); |
1 | 414 } |
6 | 415 |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
416 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
417 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
418 LLValue* DtoGEP(LLValue* ptr, LLValue* i0, LLValue* i1, const char* var, llvm::BasicBlock* bb) |
6 | 419 { |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
420 LLSmallVector<LLValue*,2> v(2); |
6 | 421 v[0] = i0; |
422 v[1] = i1; | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
423 return llvm::GetElementPtrInst::Create(ptr, v.begin(), v.end(), var?var:"tmp", bb?bb:gIR->scopebb()); |
6 | 424 } |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
425 |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
426 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
427 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
428 LLValue* DtoGEPi1(LLValue* ptr, unsigned i, const char* var, llvm::BasicBlock* bb) |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
429 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
430 return llvm::GetElementPtrInst::Create(ptr, DtoConstUint(i), var?var:"tmp", bb?bb:gIR->scopebb()); |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
431 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
432 |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
433 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
434 |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
435 LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::BasicBlock* bb) |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
436 { |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
437 LLSmallVector<LLValue*,2> v(2); |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
438 v[0] = DtoConstUint(i0); |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
439 v[1] = DtoConstUint(i1); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
440 return llvm::GetElementPtrInst::Create(ptr, v.begin(), v.end(), var?var:"tmp", bb?bb:gIR->scopebb()); |
34 | 441 } |
442 | |
40 | 443 ////////////////////////////////////////////////////////////////////////////////////////// |
34 | 444 |
1450
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
445 LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1) |
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
446 { |
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
447 LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) }; |
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
448 return llvm::ConstantExpr::getGetElementPtr(ptr, v, 2); |
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
449 } |
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
450 |
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
451 ////////////////////////////////////////////////////////////////////////////////////////// |
83bdf7bed9c5
Fix a type mismatch in ModuleInfo generation.
Frits van Bommel <fvbommel wxs.nl>
parents:
1419
diff
changeset
|
452 |
1480
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
453 void DtoMemSet(LLValue* dst, LLValue* val, LLValue* nbytes) |
129
8096ba7082db
[svn r133] Fixed some problems with inlining not happening :P
lindquist
parents:
121
diff
changeset
|
454 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
455 dst = DtoBitCast(dst,getVoidPtrType()); |
131 | 456 |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
457 const LLType* intTy = DtoSize_t(); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
458 llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module, |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
459 llvm::Intrinsic::memset, &intTy, 1); |
131 | 460 |
1480
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
461 gIR->ir->CreateCall4(fn, dst, val, nbytes, DtoConstUint(0), ""); |
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
462 } |
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
463 |
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
464 ////////////////////////////////////////////////////////////////////////////////////////// |
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
465 |
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
466 void DtoMemSetZero(LLValue* dst, LLValue* nbytes) |
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
467 { |
b3ba2c6ff038
Use `llvm.memset` instead of `_d_array_init_i1` and `_d_array_init_i8`.
Frits van Bommel <fvbommel wxs.nl>
parents:
1450
diff
changeset
|
468 DtoMemSet(dst, DtoConstUbyte(0), nbytes); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
469 } |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
470 |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
471 ////////////////////////////////////////////////////////////////////////////////////////// |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
472 |
1210
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
473 void DtoMemCpy(LLValue* dst, LLValue* src, LLValue* nbytes, unsigned align) |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
474 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
475 dst = DtoBitCast(dst,getVoidPtrType()); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
476 src = DtoBitCast(src,getVoidPtrType()); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
477 |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
478 const LLType* intTy = DtoSize_t(); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
479 llvm::Function* fn = llvm::Intrinsic::getDeclaration(gIR->module, |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
480 llvm::Intrinsic::memcpy, &intTy, 1); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
481 |
1210
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
482 gIR->ir->CreateCall4(fn, dst, src, nbytes, DtoConstUint(align), ""); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
483 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
484 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
485 ////////////////////////////////////////////////////////////////////////////////////////// |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
486 |
344
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
487 LLValue* DtoMemCmp(LLValue* lhs, LLValue* rhs, LLValue* nbytes) |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
488 { |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
489 // int memcmp ( const void * ptr1, const void * ptr2, size_t num ); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
490 |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
491 LLFunction* fn = gIR->module->getFunction("memcmp"); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
492 if (!fn) |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
493 { |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
494 std::vector<const LLType*> params(3); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
495 params[0] = getVoidPtrType(); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
496 params[1] = getVoidPtrType(); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
497 params[2] = DtoSize_t(); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
498 const LLFunctionType* fty = LLFunctionType::get(LLType::Int32Ty, params, false); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
499 fn = LLFunction::Create(fty, LLGlobalValue::ExternalLinkage, "memcmp", gIR->module); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
500 } |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
501 |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
502 lhs = DtoBitCast(lhs,getVoidPtrType()); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
503 rhs = DtoBitCast(rhs,getVoidPtrType()); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
504 |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
505 return gIR->ir->CreateCall3(fn, lhs, rhs, nbytes, "tmp"); |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
506 } |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
507 |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
508 ////////////////////////////////////////////////////////////////////////////////////////// |
e20ce6d8d374
[svn r365] Implemented raw struct equality comparison, uses C memcmp.
lindquist
parents:
328
diff
changeset
|
509 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
510 void DtoAggrZeroInit(LLValue* v) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
511 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
512 uint64_t n = getTypeStoreSize(v->getType()->getContainedType(0)); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
513 DtoMemSetZero(v, DtoConstSize_t(n)); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
514 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
515 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
516 ////////////////////////////////////////////////////////////////////////////////////////// |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
517 |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
518 void DtoAggrCopy(LLValue* dst, LLValue* src) |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
519 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
520 uint64_t n = getTypeStoreSize(dst->getType()->getContainedType(0)); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
521 DtoMemCpy(dst, src, DtoConstSize_t(n)); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
522 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
523 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
524 ////////////////////////////////////////////////////////////////////////////////////////// |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
525 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
526 void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device) |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
527 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
528 llvm::Function* fn = GET_INTRINSIC_DECL(memory_barrier); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
529 assert(fn != NULL); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
530 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
531 LLSmallVector<LLValue*, 5> llargs; |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
532 llargs.push_back(DtoConstBool(ll)); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
533 llargs.push_back(DtoConstBool(ls)); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
534 llargs.push_back(DtoConstBool(sl)); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
535 llargs.push_back(DtoConstBool(ss)); |
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
536 llargs.push_back(DtoConstBool(device)); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
537 |
317
1a2777460bd5
[svn r338] Intrinsic calls can never be invokes.
ChristianK
parents:
315
diff
changeset
|
538 llvm::CallInst::Create(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
539 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
540 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
541 ////////////////////////////////////////////////////////////////////////////////////////// |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
542 |
1375
63f4afd01036
Cleaned up TypeInfo_Struct.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1364
diff
changeset
|
543 llvm::ConstantInt* DtoConstSize_t(uint64_t i) |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
544 { |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
545 return llvm::ConstantInt::get(DtoSize_t(), i, false); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
546 } |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
547 llvm::ConstantInt* DtoConstUint(unsigned i) |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
548 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
549 return llvm::ConstantInt::get(LLType::Int32Ty, i, false); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
550 } |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
551 llvm::ConstantInt* DtoConstInt(int i) |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
552 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
553 return llvm::ConstantInt::get(LLType::Int32Ty, i, true); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
554 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
555 LLConstant* DtoConstBool(bool b) |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
556 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
557 return llvm::ConstantInt::get(LLType::Int1Ty, b, false); |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
558 } |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
559 llvm::ConstantInt* DtoConstUbyte(unsigned char i) |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
560 { |
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
561 return llvm::ConstantInt::get(LLType::Int8Ty, i, false); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
562 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
563 |
1501
8b9f236dd051
Build fix for LLVM >= r73431
Benjamin Kramer <benny.kra@gmail.com>
parents:
1482
diff
changeset
|
564 LLConstant* DtoConstFP(Type* t, long double value) |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
565 { |
445
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
566 const LLType* llty = DtoType(t); |
cc40db549aea
Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
414
diff
changeset
|
567 assert(llty->isFloatingPoint()); |
653
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
568 |
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
569 if(llty == LLType::FloatTy || llty == LLType::DoubleTy) |
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
570 return LLConstantFP::get(llty, value); |
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
571 else if(llty == LLType::X86_FP80Ty) { |
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
572 uint64_t bits[] = {0, 0}; |
1138
4c8bb03e4fbc
Update DtoConstFP() to be correct after LLVM r67562, which changed the way the
Frits van Bommel <fvbommel wxs.nl>
parents:
1064
diff
changeset
|
573 bits[0] = *(uint64_t*)&value; |
4c8bb03e4fbc
Update DtoConstFP() to be correct after LLVM r67562, which changed the way the
Frits van Bommel <fvbommel wxs.nl>
parents:
1064
diff
changeset
|
574 bits[1] = *(uint16_t*)((uint64_t*)&value + 1); |
653
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
575 return LLConstantFP::get(APFloat(APInt(80, 2, bits))); |
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
576 } else { |
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
577 assert(0 && "Unknown floating point type encountered"); |
5812d6fac0f0
Fix x86_fp80 constants.
Christian Kamm <kamm incasoftware de>
parents:
650
diff
changeset
|
578 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
579 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
580 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
581 ////////////////////////////////////////////////////////////////////////////////////////// |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
582 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
583 LLConstant* DtoConstString(const char* str) |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
584 { |
328
7086a84ab3d6
[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length.
lindquist
parents:
323
diff
changeset
|
585 std::string s(str?str:""); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
586 LLConstant* init = llvm::ConstantArray::get(s, true); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
587 llvm::GlobalVariable* gvar = new llvm::GlobalVariable( |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
244
diff
changeset
|
588 init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str", gIR->module); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
589 LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
590 return DtoConstSlice( |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
591 DtoConstSize_t(s.length()), |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
592 llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2) |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
593 ); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
594 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
595 LLConstant* DtoConstStringPtr(const char* str, const char* section) |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
596 { |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
597 std::string s(str); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
598 LLConstant* init = llvm::ConstantArray::get(s, true); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
599 llvm::GlobalVariable* gvar = new llvm::GlobalVariable( |
246
b604c56945b0
[svn r263] Changed *** ATTENTION *** to warnings.
lindquist
parents:
244
diff
changeset
|
600 init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str", gIR->module); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
601 if (section) gvar->setSection(section); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
602 LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
603 return llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
604 } |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
605 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
606 ////////////////////////////////////////////////////////////////////////////////////////// |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
607 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
608 LLValue* DtoLoad(LLValue* src, const char* name) |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
609 { |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
610 // if (Logger::enabled()) |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
611 // Logger::cout() << "loading " << *src << '\n'; |
1210
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
612 llvm::LoadInst* ld = gIR->ir->CreateLoad(src, name ? name : "tmp"); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
613 //ld->setVolatile(gIR->func()->inVolatile); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
614 return ld; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
615 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
616 |
1210
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
617 // Like DtoLoad, but the pointer is guaranteed to be aligned appropriately for the type. |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
618 LLValue* DtoAlignedLoad(LLValue* src, const char* name) |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
619 { |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
620 llvm::LoadInst* ld = gIR->ir->CreateLoad(src, name ? name : "tmp"); |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
621 ld->setAlignment(getABITypeAlign(ld->getType())); |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
622 return ld; |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
623 } |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
624 |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
625 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
626 void DtoStore(LLValue* src, LLValue* dst) |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
627 { |
719
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
628 // if (Logger::enabled()) |
7261ff0f95ff
Implemented first class delegates. closes #101
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
715
diff
changeset
|
629 // Logger::cout() << "storing " << *src << " into " << *dst << '\n'; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
630 LLValue* st = gIR->ir->CreateStore(src,dst); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
631 //st->setVolatile(gIR->func()->inVolatile); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
632 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
633 |
1210
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
634 // Like DtoStore, but the pointer is guaranteed to be aligned appropriately for the type. |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
635 void DtoAlignedStore(LLValue* src, LLValue* dst) |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
636 { |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
637 llvm::StoreInst* st = gIR->ir->CreateStore(src,dst); |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
638 st->setAlignment(getABITypeAlign(src->getType())); |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
639 } |
3d4581761b4c
Add some alignment info where LLVM might otherwise be more pessimistic.
Frits van Bommel <fvbommel wxs.nl>
parents:
1192
diff
changeset
|
640 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
641 ////////////////////////////////////////////////////////////////////////////////////////// |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
642 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
643 LLValue* DtoBitCast(LLValue* v, const LLType* t, const char* name) |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
644 { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
645 if (v->getType() == t) |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
646 return v; |
1050
32ead42679d1
Fix a bug in the X86 ABI. The size of a struct is different from the size of a
Frits van Bommel <fvbommel wxs.nl>
parents:
1024
diff
changeset
|
647 assert(!isaStruct(t)); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
648 return gIR->ir->CreateBitCast(v, t, name ? name : "tmp"); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
649 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
650 |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
651 LLConstant* DtoBitCast(LLConstant* v, const LLType* t) |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
652 { |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
653 if (v->getType() == t) |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
654 return v; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
655 return llvm::ConstantExpr::getBitCast(v, t); |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
656 } |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
657 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
658 ////////////////////////////////////////////////////////////////////////////////////////// |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
659 |
1353
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
660 LLValue* DtoInsertValue(LLValue* aggr, LLValue* v, unsigned idx) |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
661 { |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
662 return gIR->ir->CreateInsertValue(aggr, v, idx); |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
663 } |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
664 |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
665 LLValue* DtoExtractValue(LLValue* aggr, unsigned idx) |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
666 { |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
667 return gIR->ir->CreateExtractValue(aggr, idx); |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
668 } |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
669 |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
670 ////////////////////////////////////////////////////////////////////////////////////////// |
45aca7e7cc88
Remove struct padding when passing or returning in registers on x86-64 (extern(D) only)
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
671 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
672 const LLPointerType* isaPointer(LLValue* v) |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
673 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
674 return llvm::dyn_cast<LLPointerType>(v->getType()); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
675 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
676 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
677 const LLPointerType* isaPointer(const LLType* t) |
96 | 678 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
679 return llvm::dyn_cast<LLPointerType>(t); |
96 | 680 } |
681 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
682 const LLArrayType* isaArray(LLValue* v) |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
683 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
684 return llvm::dyn_cast<LLArrayType>(v->getType()); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
685 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
686 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
687 const LLArrayType* isaArray(const LLType* t) |
96 | 688 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
689 return llvm::dyn_cast<LLArrayType>(t); |
96 | 690 } |
691 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
692 const LLStructType* isaStruct(LLValue* v) |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
693 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
694 return llvm::dyn_cast<LLStructType>(v->getType()); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
695 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
696 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
697 const LLStructType* isaStruct(const LLType* t) |
96 | 698 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
699 return llvm::dyn_cast<LLStructType>(t); |
96 | 700 } |
701 | |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
702 const LLFunctionType* isaFunction(LLValue* v) |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
703 { |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
704 return llvm::dyn_cast<LLFunctionType>(v->getType()); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
705 } |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
706 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
707 const LLFunctionType* isaFunction(const LLType* t) |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
708 { |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
709 return llvm::dyn_cast<LLFunctionType>(t); |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
710 } |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
381
diff
changeset
|
711 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
712 LLConstant* isaConstant(LLValue* v) |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
713 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
714 return llvm::dyn_cast<llvm::Constant>(v); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
715 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
716 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
717 llvm::ConstantInt* isaConstantInt(LLValue* v) |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
718 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
719 return llvm::dyn_cast<llvm::ConstantInt>(v); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
720 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
721 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
722 llvm::Argument* isaArgument(LLValue* v) |
96 | 723 { |
724 return llvm::dyn_cast<llvm::Argument>(v); | |
725 } | |
726 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
727 llvm::GlobalVariable* isaGlobalVar(LLValue* v) |
106 | 728 { |
729 return llvm::dyn_cast<llvm::GlobalVariable>(v); | |
730 } | |
731 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
732 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
733 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
734 const LLPointerType* getPtrToType(const LLType* t) |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
735 { |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
264
diff
changeset
|
736 if (t == LLType::VoidTy) |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
264
diff
changeset
|
737 t = LLType::Int8Ty; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
738 return LLPointerType::get(t, 0); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
739 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
740 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
741 const LLPointerType* getVoidPtrType() |
193
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
189
diff
changeset
|
742 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
743 return getPtrToType(LLType::Int8Ty); |
193
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
189
diff
changeset
|
744 } |
aca17e55b7a5
[svn r209] Fixed: exotic array to pointer casts were broken.
lindquist
parents:
189
diff
changeset
|
745 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
746 llvm::ConstantPointerNull* getNullPtr(const LLType* t) |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
747 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
748 const LLPointerType* pt = llvm::cast<LLPointerType>(t); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
749 return llvm::ConstantPointerNull::get(pt); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
750 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
751 |
811
8e6135be6999
Fixed ModuleInfo generation to no longer use the ModuleInfo class' default initializer for types/defaults, it's unsafe as initializers don't necesarily match the "formal" type. There might be explicit padding.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
752 LLConstant* getNullValue(const LLType* t) |
8e6135be6999
Fixed ModuleInfo generation to no longer use the ModuleInfo class' default initializer for types/defaults, it's unsafe as initializers don't necesarily match the "formal" type. There might be explicit padding.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
753 { |
8e6135be6999
Fixed ModuleInfo generation to no longer use the ModuleInfo class' default initializer for types/defaults, it's unsafe as initializers don't necesarily match the "formal" type. There might be explicit padding.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
754 return LLConstant::getNullValue(t); |
8e6135be6999
Fixed ModuleInfo generation to no longer use the ModuleInfo class' default initializer for types/defaults, it's unsafe as initializers don't necesarily match the "formal" type. There might be explicit padding.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
755 } |
8e6135be6999
Fixed ModuleInfo generation to no longer use the ModuleInfo class' default initializer for types/defaults, it's unsafe as initializers don't necesarily match the "formal" type. There might be explicit padding.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
756 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
757 ////////////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
758 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
759 size_t getTypeBitSize(const LLType* t) |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
760 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
761 return gTargetData->getTypeSizeInBits(t); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
762 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
763 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
764 size_t getTypeStoreSize(const LLType* t) |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
765 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
766 return gTargetData->getTypeStoreSize(t); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
767 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
768 |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
769 size_t getTypePaddedSize(const LLType* t) |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
770 { |
1323
c74dfdcc5043
Update for LLVM rev > 71348: getTypePaddedSize -> getTypeAllocSize
Christian Kamm <kamm incasoftware de>
parents:
1279
diff
changeset
|
771 #if LLVM_REV > 71348 |
c74dfdcc5043
Update for LLVM rev > 71348: getTypePaddedSize -> getTypeAllocSize
Christian Kamm <kamm incasoftware de>
parents:
1279
diff
changeset
|
772 size_t sz = gTargetData->getTypeAllocSize(t); |
c74dfdcc5043
Update for LLVM rev > 71348: getTypePaddedSize -> getTypeAllocSize
Christian Kamm <kamm incasoftware de>
parents:
1279
diff
changeset
|
773 #else |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
774 size_t sz = gTargetData->getTypePaddedSize(t); |
1323
c74dfdcc5043
Update for LLVM rev > 71348: getTypePaddedSize -> getTypeAllocSize
Christian Kamm <kamm incasoftware de>
parents:
1279
diff
changeset
|
775 #endif |
618 | 776 //Logger::cout() << "abi type size of: " << *t << " == " << sz << '\n'; |
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:
464
diff
changeset
|
777 return sz; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
778 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
779 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
780 unsigned char getABITypeAlign(const LLType* t) |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
781 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
782 return gTargetData->getABITypeAlignment(t); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
783 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
784 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
785 unsigned char getPrefTypeAlign(const LLType* t) |
100 | 786 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
787 return gTargetData->getPrefTypeAlignment(t); |
100 | 788 } |
789 | |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
790 const LLType* getBiggestType(const LLType** begin, size_t n) |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
791 { |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
792 const LLType* bigTy = 0; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
793 size_t bigSize = 0; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
794 size_t bigAlign = 0; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
795 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
796 const LLType** end = begin+n; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
797 while (begin != end) |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
798 { |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
799 const LLType* T = *begin; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
800 |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
801 size_t sz = getTypePaddedSize(T); |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
802 size_t ali = getABITypeAlign(T); |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
803 if (sz > bigSize || (sz == bigSize && ali > bigAlign)) |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
804 { |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
805 bigTy = T; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
806 bigSize = sz; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
807 bigAlign = ali; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
808 } |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
809 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
810 ++begin; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
811 } |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
812 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
813 // will be null for n==0 |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
814 return bigTy; |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
815 } |
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
794
diff
changeset
|
816 |
100 | 817 ////////////////////////////////////////////////////////////////////////////////////////// |
818 | |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
819 const LLStructType* DtoInterfaceInfoType() |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
820 { |
161
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
160
diff
changeset
|
821 if (gIR->interfaceInfoType) |
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
160
diff
changeset
|
822 return gIR->interfaceInfoType; |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
823 |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
824 // build interface info type |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
825 std::vector<const LLType*> types; |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
826 // ClassInfo classinfo |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
827 ClassDeclaration* cd2 = ClassDeclaration::classinfo; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
828 DtoResolveClass(cd2); |
1364
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1353
diff
changeset
|
829 types.push_back(DtoType(cd2->type)); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
830 // void*[] vtbl |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
210
diff
changeset
|
831 std::vector<const LLType*> vtbltypes; |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
832 vtbltypes.push_back(DtoSize_t()); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
833 const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::Int8Ty)); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
834 vtbltypes.push_back(byteptrptrty); |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
835 types.push_back(LLStructType::get(vtbltypes)); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
836 // int offset |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
837 types.push_back(LLType::Int32Ty); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
838 // create type |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
237
diff
changeset
|
839 gIR->interfaceInfoType = LLStructType::get(types); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
840 |
161
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
160
diff
changeset
|
841 return gIR->interfaceInfoType; |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
135
diff
changeset
|
842 } |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
843 |
309 | 844 ////////////////////////////////////////////////////////////////////////////////////////// |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
845 |
309 | 846 const LLStructType* DtoMutexType() |
847 { | |
848 if (gIR->mutexType) | |
849 return gIR->mutexType; | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
850 |
309 | 851 // win32 |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
516
diff
changeset
|
852 if (global.params.os == OSWindows) |
309 | 853 { |
854 // CRITICAL_SECTION.sizeof == 68 | |
855 std::vector<const LLType*> types(17, LLType::Int32Ty); | |
856 return LLStructType::get(types); | |
857 } | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
858 |
637
29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
632
diff
changeset
|
859 // FreeBSD |
29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
632
diff
changeset
|
860 else if (global.params.os == OSFreeBSD) { |
29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
632
diff
changeset
|
861 // Just a pointer |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
758
diff
changeset
|
862 return LLStructType::get(DtoSize_t(), NULL); |
637
29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
632
diff
changeset
|
863 } |
29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
632
diff
changeset
|
864 |
309 | 865 // pthread_fastlock |
866 std::vector<const LLType*> types2; | |
867 types2.push_back(DtoSize_t()); | |
868 types2.push_back(LLType::Int32Ty); | |
869 const LLStructType* fastlock = LLStructType::get(types2); | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
870 |
309 | 871 // pthread_mutex |
872 std::vector<const LLType*> types1; | |
873 types1.push_back(LLType::Int32Ty); | |
874 types1.push_back(LLType::Int32Ty); | |
875 types1.push_back(getVoidPtrType()); | |
876 types1.push_back(LLType::Int32Ty); | |
877 types1.push_back(fastlock); | |
878 const LLStructType* pmutex = LLStructType::get(types1); | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
879 |
309 | 880 // D_CRITICAL_SECTION |
881 LLOpaqueType* opaque = LLOpaqueType::get(); | |
882 std::vector<const LLType*> types; | |
883 types.push_back(getPtrToType(opaque)); | |
884 types.push_back(pmutex); | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
885 |
309 | 886 // resolve type |
887 pmutex = LLStructType::get(types); | |
888 LLPATypeHolder pa(pmutex); | |
889 opaque->refineAbstractTypeTo(pa.get()); | |
890 pmutex = isaStruct(pa.get()); | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
201
diff
changeset
|
891 |
309 | 892 gIR->mutexType = pmutex; |
893 gIR->module->addTypeName("D_CRITICAL_SECTION", pmutex); | |
894 return pmutex; | |
895 } | |
323
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
896 |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
897 ////////////////////////////////////////////////////////////////////////////////////////// |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
898 |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
899 const LLStructType* DtoModuleReferenceType() |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
900 { |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
901 if (gIR->moduleRefType) |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
902 return gIR->moduleRefType; |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
903 |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
904 // this is a recursive type so start out with the opaque |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
905 LLOpaqueType* opaque = LLOpaqueType::get(); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
906 |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
907 // add members |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
908 std::vector<const LLType*> types; |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
909 types.push_back(getPtrToType(opaque)); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
910 types.push_back(DtoType(Module::moduleinfo->type)); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
911 |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
912 // resolve type |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
913 const LLStructType* st = LLStructType::get(types); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
914 LLPATypeHolder pa(st); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
915 opaque->refineAbstractTypeTo(pa.get()); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
916 st = isaStruct(pa.get()); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
917 |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
918 // done |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
919 gIR->moduleRefType = st; |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
920 gIR->module->addTypeName("ModuleReference", st); |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
921 return st; |
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
317
diff
changeset
|
922 } |
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:
534
diff
changeset
|
923 |
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:
534
diff
changeset
|
924 ////////////////////////////////////////////////////////////////////////////////////////// |
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:
534
diff
changeset
|
925 |
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:
534
diff
changeset
|
926 LLValue* DtoAggrPair(const LLType* type, LLValue* V1, LLValue* V2, const char* name) |
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:
534
diff
changeset
|
927 { |
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:
534
diff
changeset
|
928 LLValue* res = llvm::UndefValue::get(type); |
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:
534
diff
changeset
|
929 res = gIR->ir->CreateInsertValue(res, V1, 0, "tmp"); |
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:
534
diff
changeset
|
930 return gIR->ir->CreateInsertValue(res, V2, 1, name?name:"tmp"); |
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:
534
diff
changeset
|
931 } |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
932 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
933 LLValue* DtoAggrPair(LLValue* V1, LLValue* V2, const char* name) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
934 { |
794
661384d6a936
Fix warnings on x86-64. By fvbommel.
Christian Kamm <kamm incasoftware de>
parents:
758
diff
changeset
|
935 const LLType* t = LLStructType::get(V1->getType(), V2->getType(), NULL); |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
936 return DtoAggrPair(t, V1, V2, name); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
937 } |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
938 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
939 LLValue* DtoAggrPaint(LLValue* aggr, const LLType* as) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
940 { |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
941 if (aggr->getType() == as) |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
942 return aggr; |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
943 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
944 LLValue* res = llvm::UndefValue::get(as); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
945 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
946 LLValue* V = gIR->ir->CreateExtractValue(aggr, 0, "tmp");; |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
947 V = DtoBitCast(V, as->getContainedType(0)); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
948 res = gIR->ir->CreateInsertValue(res, V, 0, "tmp"); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
949 |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
950 V = gIR->ir->CreateExtractValue(aggr, 1, "tmp");; |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
951 V = DtoBitCast(V, as->getContainedType(1)); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
952 return gIR->ir->CreateInsertValue(res, V, 1, "tmp"); |
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
705
diff
changeset
|
953 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
954 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
955 LLValue* DtoAggrPairSwap(LLValue* aggr) |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
956 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
957 Logger::println("swapping aggr pair"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
958 LLValue* r = gIR->ir->CreateExtractValue(aggr, 0); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
959 LLValue* i = gIR->ir->CreateExtractValue(aggr, 1); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
960 return DtoAggrPair(i, r, "swapped"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
940
diff
changeset
|
961 } |