comparison dmd2/mtype.c @ 1011:010b8b67de1a

Apply previous changes to dmd2/mtype.c as well.
author Frits van Bommel <fvbommel wxs.nl>
date Sat, 28 Feb 2009 17:44:53 +0100
parents 5fa3e0ea06e9
children 799dbdf9c461
comparison
equal deleted inserted replaced
1010:bad2044a1597 1011:010b8b67de1a
7 // License for redistribution is by either the Artistic License 7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt. 8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details. 9 // See the included readme.txt for details.
10 10
11 #define __USE_ISOC99 1 // so signbit() gets defined 11 #define __USE_ISOC99 1 // so signbit() gets defined
12 #include <math.h> 12 #include <cmath>
13 13
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <assert.h> 15 #include <assert.h>
16 #include <float.h> 16 #include <float.h>
17 17
30 #else 30 #else
31 //#define signbit 56 31 //#define signbit 56
32 #endif 32 #endif
33 33
34 #if __APPLE__ 34 #if __APPLE__
35 #include <math.h> 35 #include <cmath>
36 static double zero = 0; 36 static double zero = 0;
37 #elif __MINGW32__ 37 #elif __MINGW32__
38 #include <math.h> 38 #include <cmath>
39 static double zero = 0; 39 static double zero = 0;
40 #elif __GNUC__ 40 #elif __GNUC__
41 #include <math.h> 41 #include <cmath>
42 #include <bits/nan.h> 42 #include <bits/nan.h>
43 #include <bits/mathdef.h> 43 #include <bits/mathdef.h>
44 static double zero = 0; 44 static double zero = 0;
45 #endif 45 #endif
46 46
57 #include "id.h" 57 #include "id.h"
58 #include "enum.h" 58 #include "enum.h"
59 #include "import.h" 59 #include "import.h"
60 #include "aggregate.h" 60 #include "aggregate.h"
61 #include "hdrgen.h" 61 #include "hdrgen.h"
62
63 #include "gen/tollvm.h"
62 64
63 FuncDeclaration *hasThis(Scope *sc); 65 FuncDeclaration *hasThis(Scope *sc);
64 66
65 67
66 #define LOGDOTEXP 0 // log ::dotExp() 68 #define LOGDOTEXP 0 // log ::dotExp()
1227 //printf("TypeBasic::size() = %d\n", size); 1229 //printf("TypeBasic::size() = %d\n", size);
1228 return size; 1230 return size;
1229 } 1231 }
1230 1232
1231 unsigned TypeBasic::alignsize() 1233 unsigned TypeBasic::alignsize()
1232 { unsigned sz; 1234 {
1233 1235 return getABITypeAlign(DtoType(this));
1234 //LDC: it's bad that we always have to check LLVM's align and
1235 // dmd's align info match. Can't we somehow get at LLVM's align
1236 // here?
1237
1238 switch (ty)
1239 {
1240 case Tfloat80:
1241 case Timaginary80:
1242 case Tcomplex80:
1243 if (global.params.cpu == ARCHx86_64)
1244 sz = 16;
1245 else
1246 sz = 4;
1247 break;
1248
1249 case Tint64:
1250 case Tuns64:
1251 case Tfloat64:
1252 case Timaginary64:
1253 if (global.params.cpu == ARCHx86_64)
1254 sz = 8;
1255 else
1256 sz = 4;
1257 break;
1258
1259 default:
1260 sz = size(0);
1261 break;
1262 }
1263 return sz;
1264 } 1236 }
1265 1237
1266 1238
1267 Expression *TypeBasic::getProperty(Loc loc, Identifier *ident) 1239 Expression *TypeBasic::getProperty(Loc loc, Identifier *ident)
1268 { 1240 {
1352 // gcc nan's have the sign bit set by default, so turn it off 1324 // gcc nan's have the sign bit set by default, so turn it off
1353 // Need the volatile to prevent gcc from doing incorrect 1325 // Need the volatile to prevent gcc from doing incorrect
1354 // constant folding. 1326 // constant folding.
1355 volatile d_float80 foo; 1327 volatile d_float80 foo;
1356 foo = NAN; 1328 foo = NAN;
1357 if (signbit(foo)) // signbit sometimes, not always, set 1329 if (std::signbit(foo)) // signbit sometimes, not always, set
1358 foo = -foo; // turn off sign bit 1330 foo = -foo; // turn off sign bit
1359 fvalue = foo; 1331 fvalue = foo;
1360 #elif _MSC_VER 1332 #elif _MSC_VER
1361 unsigned long nan[2]= { 0xFFFFFFFF, 0x7FFFFFFF }; 1333 unsigned long nan[2]= { 0xFFFFFFFF, 0x7FFFFFFF };
1362 fvalue = *(double*)nan; 1334 fvalue = *(double*)nan;