Mercurial > projects > ldc
comparison dmd/mtype.c @ 1147:dbe4af57b240
Changed use of toObjFile to a new codegen method.
More versioning of DMD specific codegen code.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Fri, 27 Mar 2009 17:54:27 +0100 |
parents | 1860414bf3b7 |
children | 442ab244c455 |
comparison
equal
deleted
inserted
replaced
1146:1860414bf3b7 | 1147:dbe4af57b240 |
---|---|
13 | 13 |
14 #if (defined (__SVR4) && defined (__sun)) | 14 #if (defined (__SVR4) && defined (__sun)) |
15 #include <alloca.h> | 15 #include <alloca.h> |
16 #endif | 16 #endif |
17 | 17 |
18 #ifdef __DMC__ | |
18 #include <math.h> | 19 #include <math.h> |
20 #else | |
21 #include <cmath> | |
22 #endif | |
19 | 23 |
20 #include <stdio.h> | 24 #include <stdio.h> |
21 #include <assert.h> | 25 #include <assert.h> |
22 #include <float.h> | 26 #include <float.h> |
23 | 27 |
63 #include "enum.h" | 67 #include "enum.h" |
64 #include "import.h" | 68 #include "import.h" |
65 #include "aggregate.h" | 69 #include "aggregate.h" |
66 #include "hdrgen.h" | 70 #include "hdrgen.h" |
67 | 71 |
68 #include "gen/tollvm.h" | 72 #if IN_LLVM |
73 //#include "gen/tollvm.h" | |
74 Ir* Type::sir = NULL; | |
75 unsigned GetTypeAlignment(Ir* ir, Type* t); | |
76 #endif | |
69 | 77 |
70 FuncDeclaration *hasThis(Scope *sc); | 78 FuncDeclaration *hasThis(Scope *sc); |
71 | 79 |
72 | 80 |
73 #define LOGDOTEXP 0 // log ::dotExp() | 81 #define LOGDOTEXP 0 // log ::dotExp() |
162 char Type::needThisPrefix() | 170 char Type::needThisPrefix() |
163 { | 171 { |
164 return 'M'; // name mangling prefix for functions needing 'this' | 172 return 'M'; // name mangling prefix for functions needing 'this' |
165 } | 173 } |
166 | 174 |
175 #if IN_LLVM | |
176 void Type::init(Ir* _sir) | |
177 #else | |
167 void Type::init() | 178 void Type::init() |
179 #endif | |
168 { int i; | 180 { int i; |
169 int j; | 181 int j; |
170 | 182 |
171 Lexer::initKeywords(); | 183 Lexer::initKeywords(); |
172 | 184 |
235 for (i = 0; i < sizeof(basetab) / sizeof(basetab[0]); i++) | 247 for (i = 0; i < sizeof(basetab) / sizeof(basetab[0]); i++) |
236 basic[basetab[i]] = new TypeBasic(basetab[i]); | 248 basic[basetab[i]] = new TypeBasic(basetab[i]); |
237 basic[Terror] = basic[Tint32]; | 249 basic[Terror] = basic[Tint32]; |
238 | 250 |
239 tvoidptr = tvoid->pointerTo(); | 251 tvoidptr = tvoid->pointerTo(); |
252 | |
253 // LDC | |
254 sir = _sir; | |
240 | 255 |
241 // set size_t / ptrdiff_t types and pointer size | 256 // set size_t / ptrdiff_t types and pointer size |
242 if (global.params.is64bit) | 257 if (global.params.is64bit) |
243 { | 258 { |
244 Tsize_t = Tuns64; | 259 Tsize_t = Tuns64; |
1015 | 1030 |
1016 unsigned TypeBasic::alignsize() | 1031 unsigned TypeBasic::alignsize() |
1017 { | 1032 { |
1018 if (ty == Tvoid) | 1033 if (ty == Tvoid) |
1019 return 1; | 1034 return 1; |
1020 return getABITypeAlign(DtoType(this)); | 1035 return GetTypeAlignment(sir, this); |
1021 } | 1036 } |
1022 | 1037 |
1023 | 1038 |
1024 Expression *TypeBasic::getProperty(Loc loc, Identifier *ident) | 1039 Expression *TypeBasic::getProperty(Loc loc, Identifier *ident) |
1025 { | 1040 { |