Mercurial > projects > ldc
comparison gen/complex.cpp @ 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.
Reimplemented support for nested functions/class using a new approach.
Added error on taking address of intrinsic.
Fixed problems with the ->syntaxCopy of TypeFunction delegate exp.
Removed DtoDType and replaced all uses with ->toBasetype() instead.
Removed unused inplace stuff.
Fixed a bunch of issues in the runtime unittests, not complete yet.
Added mini tests.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 08:37:38 +0200 |
parents | 672eb4893b55 |
children | fbb1a366cfbc |
comparison
equal
deleted
inserted
replaced
485:50f6e2337a6b | 486:a34078905d01 |
---|---|
11 | 11 |
12 ////////////////////////////////////////////////////////////////////////////////////////// | 12 ////////////////////////////////////////////////////////////////////////////////////////// |
13 | 13 |
14 const llvm::StructType* DtoComplexType(Type* type) | 14 const llvm::StructType* DtoComplexType(Type* type) |
15 { | 15 { |
16 Type* t = DtoDType(type); | 16 Type* t = type->toBasetype(); |
17 | 17 |
18 const LLType* base = DtoComplexBaseType(t); | 18 const LLType* base = DtoComplexBaseType(t); |
19 | 19 |
20 std::vector<const LLType*> types; | 20 std::vector<const LLType*> types; |
21 types.push_back(base); | 21 types.push_back(base); |
24 return llvm::StructType::get(types); | 24 return llvm::StructType::get(types); |
25 } | 25 } |
26 | 26 |
27 const LLType* DtoComplexBaseType(Type* t) | 27 const LLType* DtoComplexBaseType(Type* t) |
28 { | 28 { |
29 TY ty = DtoDType(t)->ty; | 29 TY ty = t->toBasetype()->ty; |
30 const LLType* base; | 30 const LLType* base; |
31 if (ty == Tcomplex32) { | 31 if (ty == Tcomplex32) { |
32 return LLType::FloatTy; | 32 return LLType::FloatTy; |
33 } | 33 } |
34 else if (ty == Tcomplex64) { | 34 else if (ty == Tcomplex64) { |
60 return llvm::ConstantVector::get(vt, inits); | 60 return llvm::ConstantVector::get(vt, inits); |
61 } | 61 } |
62 | 62 |
63 LLConstant* DtoConstComplex(Type* _ty, long double re, long double im) | 63 LLConstant* DtoConstComplex(Type* _ty, long double re, long double im) |
64 { | 64 { |
65 TY ty = DtoDType(_ty)->ty; | 65 TY ty = _ty->toBasetype()->ty; |
66 | 66 |
67 llvm::ConstantFP* fre; | 67 llvm::ConstantFP* fre; |
68 llvm::ConstantFP* fim; | 68 llvm::ConstantFP* fim; |
69 | 69 |
70 Type* base = 0; | 70 Type* base = 0; |
104 | 104 |
105 ////////////////////////////////////////////////////////////////////////////////////////// | 105 ////////////////////////////////////////////////////////////////////////////////////////// |
106 | 106 |
107 DValue* DtoComplex(Loc& loc, Type* to, DValue* val) | 107 DValue* DtoComplex(Loc& loc, Type* to, DValue* val) |
108 { | 108 { |
109 Type* t = DtoDType(val->getType()); | 109 Type* t = val->getType()->toBasetype(); |
110 | 110 |
111 if (val->isComplex() || t->iscomplex()) { | 111 if (val->isComplex() || t->iscomplex()) { |
112 return DtoCastComplex(loc, val, to); | 112 return DtoCastComplex(loc, val, to); |
113 } | 113 } |
114 | 114 |
446 | 446 |
447 ////////////////////////////////////////////////////////////////////////////////////////// | 447 ////////////////////////////////////////////////////////////////////////////////////////// |
448 | 448 |
449 DValue* DtoCastComplex(Loc& loc, DValue* val, Type* _to) | 449 DValue* DtoCastComplex(Loc& loc, DValue* val, Type* _to) |
450 { | 450 { |
451 Type* to = DtoDType(_to); | 451 Type* to = _to->toBasetype(); |
452 Type* vty = val->getType(); | 452 Type* vty = val->getType(); |
453 if (to->iscomplex()) { | 453 if (to->iscomplex()) { |
454 if (vty->size() == to->size()) | 454 if (vty->size() == to->size()) |
455 return val; | 455 return val; |
456 | 456 |