comparison gen/tollvm.cpp @ 1192:3251ce06c820

Started seperating type resolution from the rest of codegen again, the merge had too many regressions.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Fri, 03 Apr 2009 16:34:11 +0200
parents 71479f6e2a01
children 3d4581761b4c
comparison
equal deleted inserted replaced
1191:d68796be59fd 1192:3251ce06c820
20 #include "gen/complex.h" 20 #include "gen/complex.h"
21 #include "gen/llvmhelpers.h" 21 #include "gen/llvmhelpers.h"
22 #include "gen/linkage.h" 22 #include "gen/linkage.h"
23 #include "gen/llvm-version.h" 23 #include "gen/llvm-version.h"
24 24
25 #include "ir/irtype.h"
26
25 bool DtoIsPassedByRef(Type* type) 27 bool DtoIsPassedByRef(Type* type)
26 { 28 {
27 Type* typ = type->toBasetype(); 29 Type* typ = type->toBasetype();
28 TY t = typ->ty; 30 TY t = typ->ty;
29 return (t == Tstruct || t == Tsarray); 31 return (t == Tstruct || t == Tsarray);
48 return llvm::Attribute::None; 50 return llvm::Attribute::None;
49 } 51 }
50 52
51 const LLType* DtoType(Type* t) 53 const LLType* DtoType(Type* t)
52 { 54 {
55 if (t->irtype)
56 {
57 return t->irtype->get();
58 }
59
53 assert(t); 60 assert(t);
54 switch (t->ty) 61 switch (t->ty)
55 { 62 {
56 // integers 63 // basic types
64 case Tvoid:
57 case Tint8: 65 case Tint8:
58 case Tuns8: 66 case Tuns8:
59 case Tchar:
60 return (const LLType*)LLType::Int8Ty;
61 case Tint16: 67 case Tint16:
62 case Tuns16: 68 case Tuns16:
63 case Twchar:
64 return (const LLType*)LLType::Int16Ty;
65 case Tint32: 69 case Tint32:
66 case Tuns32: 70 case Tuns32:
67 case Tdchar:
68 return (const LLType*)LLType::Int32Ty;
69 case Tint64: 71 case Tint64:
70 case Tuns64: 72 case Tuns64:
71 return (const LLType*)LLType::Int64Ty;
72
73 case Tbool:
74 return (const LLType*)llvm::ConstantInt::getTrue()->getType();
75
76 // floats
77 case Tfloat32: 73 case Tfloat32:
74 case Tfloat64:
75 case Tfloat80:
78 case Timaginary32: 76 case Timaginary32:
79 return LLType::FloatTy;
80 case Tfloat64:
81 case Timaginary64: 77 case Timaginary64:
82 return LLType::DoubleTy;
83 case Tfloat80:
84 case Timaginary80: 78 case Timaginary80:
85 if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
86 return LLType::X86_FP80Ty;
87 else
88 return LLType::DoubleTy;
89
90 // complex
91 case Tcomplex32: 79 case Tcomplex32:
92 case Tcomplex64: 80 case Tcomplex64:
93 case Tcomplex80: 81 case Tcomplex80:
94 return DtoComplexType(t); 82 //case Tbit:
83 case Tbool:
84 case Tchar:
85 case Twchar:
86 case Tdchar:
87 {
88 t->irtype = new IrTypeBasic(t);
89 return t->irtype->get();
90 }
95 91
96 // pointers 92 // pointers
97 case Tpointer: 93 case Tpointer:
98 // getPtrToType checks for void itself 94 {
99 return getPtrToType(DtoType(t->nextOf())); 95 t->irtype = new IrTypePointer(t);
96 return t->irtype->get();
97 }
100 98
101 // arrays 99 // arrays
102 case Tarray: 100 case Tarray:
103 return DtoArrayType(t); 101 {
102 t->irtype = new IrTypeArray(t);
103 return t->irtype->get();
104 }
105
104 case Tsarray: 106 case Tsarray:
105 return DtoStaticArrayType(t); 107 {
106 108 t->irtype = new IrTypeSArray(t);
107 // void 109 return t->irtype->get();
108 case Tvoid: 110 }
109 return LLType::VoidTy;
110 111
111 // aggregates 112 // aggregates
112 case Tstruct: { 113 case Tstruct: {
113 #if DMDV2 114 #if DMDV2
114 TypeStruct* ts = (TypeStruct*)t->mutableOf(); 115 TypeStruct* ts = (TypeStruct*)t->mutableOf();