Mercurial > projects > ldc
annotate ir/irtype.cpp @ 1651:cb960b882ca3 default tip
bindings were moved to dsource.org/projects/bindings/
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Thu, 20 May 2010 20:05:03 +0200 |
parents | 40bd4a0d4870 |
children |
rev | line source |
---|---|
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:
diff
changeset
|
1 #include "llvm/DerivedTypes.h" |
1650 | 2 #include "llvm/LLVMContext.h" |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
3 #include "mars.h" |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
4 #include "mtype.h" |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
5 #include "gen/irstate.h" |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
6 #include "gen/logger.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:
diff
changeset
|
7 #include "ir/irtype.h" |
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:
diff
changeset
|
8 |
1650 | 9 // This code uses llvm::getGlobalContext() as these functions are invoked before gIR is set. |
10 // ... thus it segfaults on gIR==NULL | |
11 | |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
12 ////////////////////////////////////////////////////////////////////////////// |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
13 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
14 extern const llvm::Type* DtoType(Type* dt); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
15 extern const llvm::Type* DtoSize_t(); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
16 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
17 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
18 |
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:
diff
changeset
|
19 IrType::IrType(Type* dt, const llvm::Type* lt) |
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:
diff
changeset
|
20 : dtype(dt), |
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:
diff
changeset
|
21 pa(lt) |
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:
diff
changeset
|
22 { |
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:
diff
changeset
|
23 assert(dt && "null D Type"); |
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:
diff
changeset
|
24 assert(lt && "null LLVM Type"); |
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:
1228
diff
changeset
|
25 assert(dt->irtype == NULL && "already has IrType"); |
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:
diff
changeset
|
26 } |
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:
diff
changeset
|
27 |
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:
diff
changeset
|
28 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
29 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
30 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
31 |
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:
diff
changeset
|
32 IrTypeBasic::IrTypeBasic(Type * dt) |
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:
diff
changeset
|
33 : IrType(dt, basic2llvm(dt)) |
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:
diff
changeset
|
34 { |
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:
diff
changeset
|
35 } |
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:
diff
changeset
|
36 |
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:
diff
changeset
|
37 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
38 |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
39 const llvm::Type * IrTypeBasic::buildType() |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
40 { |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
41 return pa.get(); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
42 } |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
43 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
44 ////////////////////////////////////////////////////////////////////////////// |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
45 |
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:
diff
changeset
|
46 const llvm::Type * IrTypeBasic::basic2llvm(Type* t) |
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:
diff
changeset
|
47 { |
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:
diff
changeset
|
48 const llvm::Type* t2; |
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:
diff
changeset
|
49 |
1650 | 50 llvm::LLVMContext& ctx = llvm::getGlobalContext(); |
51 | |
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:
diff
changeset
|
52 switch(t->ty) |
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:
diff
changeset
|
53 { |
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:
diff
changeset
|
54 case Tvoid: |
1650 | 55 return llvm::Type::getVoidTy(ctx); |
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:
diff
changeset
|
56 |
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:
diff
changeset
|
57 case Tint8: |
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:
diff
changeset
|
58 case Tuns8: |
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:
diff
changeset
|
59 case Tchar: |
1650 | 60 return llvm::Type::getInt8Ty(ctx); |
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:
diff
changeset
|
61 |
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:
diff
changeset
|
62 case Tint16: |
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:
diff
changeset
|
63 case Tuns16: |
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:
diff
changeset
|
64 case Twchar: |
1650 | 65 return llvm::Type::getInt16Ty(ctx); |
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:
diff
changeset
|
66 |
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:
diff
changeset
|
67 case Tint32: |
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:
diff
changeset
|
68 case Tuns32: |
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:
diff
changeset
|
69 case Tdchar: |
1650 | 70 return llvm::Type::getInt32Ty(ctx); |
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:
diff
changeset
|
71 |
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:
diff
changeset
|
72 case Tint64: |
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:
diff
changeset
|
73 case Tuns64: |
1650 | 74 return llvm::Type::getInt64Ty(ctx); |
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:
diff
changeset
|
75 |
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:
diff
changeset
|
76 /* |
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:
diff
changeset
|
77 case Tint128: |
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:
diff
changeset
|
78 case Tuns128: |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
79 return llvm::IntegerType::get(llvm::getGlobalContext(), 128); |
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:
diff
changeset
|
80 */ |
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:
diff
changeset
|
81 |
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:
diff
changeset
|
82 case Tfloat32: |
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:
diff
changeset
|
83 case Timaginary32: |
1650 | 84 return llvm::Type::getFloatTy(ctx); |
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:
diff
changeset
|
85 |
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:
diff
changeset
|
86 case Tfloat64: |
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:
diff
changeset
|
87 case Timaginary64: |
1650 | 88 return llvm::Type::getDoubleTy(ctx); |
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:
diff
changeset
|
89 |
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:
diff
changeset
|
90 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:
diff
changeset
|
91 case Timaginary80: |
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:
diff
changeset
|
92 // only x86 has 80bit float |
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:
diff
changeset
|
93 if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) |
1650 | 94 return llvm::Type::getX86_FP80Ty(ctx); |
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:
diff
changeset
|
95 // other platforms use 64bit reals |
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:
diff
changeset
|
96 else |
1650 | 97 return llvm::Type::getDoubleTy(ctx); |
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:
diff
changeset
|
98 |
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:
diff
changeset
|
99 case Tcomplex32: |
1650 | 100 t2 = llvm::Type::getFloatTy(ctx); |
101 return llvm::StructType::get(ctx, t2, t2, NULL); | |
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:
diff
changeset
|
102 |
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:
diff
changeset
|
103 case Tcomplex64: |
1650 | 104 t2 = llvm::Type::getDoubleTy(ctx); |
105 return llvm::StructType::get(ctx, t2, t2, NULL); | |
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:
diff
changeset
|
106 |
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:
diff
changeset
|
107 case Tcomplex80: |
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:
diff
changeset
|
108 t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) |
1650 | 109 ? llvm::Type::getX86_FP80Ty(ctx) |
110 : llvm::Type::getDoubleTy(ctx); | |
111 return llvm::StructType::get(ctx, t2, t2, NULL); | |
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:
diff
changeset
|
112 |
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:
diff
changeset
|
113 case Tbool: |
1650 | 114 return llvm::Type::getInt1Ty(ctx); |
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:
diff
changeset
|
115 } |
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:
diff
changeset
|
116 |
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:
diff
changeset
|
117 assert(0 && "not basic type"); |
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:
diff
changeset
|
118 return NULL; |
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:
diff
changeset
|
119 } |
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:
diff
changeset
|
120 |
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:
diff
changeset
|
121 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
122 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
123 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
124 |
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:
diff
changeset
|
125 IrTypePointer::IrTypePointer(Type * dt) |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
126 : IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext())) |
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:
diff
changeset
|
127 { |
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:
diff
changeset
|
128 } |
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:
diff
changeset
|
129 |
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:
diff
changeset
|
130 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
131 |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
132 const llvm::Type * IrTypePointer::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:
diff
changeset
|
133 { |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
134 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo( |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
135 pointer2llvm(dtype)); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
136 return pa.get(); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
137 } |
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:
diff
changeset
|
138 |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
139 ////////////////////////////////////////////////////////////////////////////// |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
140 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
141 const llvm::Type * IrTypePointer::pointer2llvm(Type * dt) |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
142 { |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
143 assert(dt->ty == Tpointer && "not pointer type"); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
144 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
145 const llvm::Type* elemType = DtoType(dt->nextOf()); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
146 if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext())) |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
147 elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext()); |
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:
diff
changeset
|
148 return llvm::PointerType::get(elemType, 0); |
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:
diff
changeset
|
149 } |
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:
diff
changeset
|
150 |
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:
diff
changeset
|
151 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
152 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
153 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
154 |
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:
diff
changeset
|
155 IrTypeSArray::IrTypeSArray(Type * dt) |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
156 : IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext())) |
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:
diff
changeset
|
157 { |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
158 assert(dt->ty == Tsarray && "not static array type"); |
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:
diff
changeset
|
159 TypeSArray* tsa = (TypeSArray*)dt; |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
160 dim = (uint64_t)tsa->dim->toUInteger(); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
161 } |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
162 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
163 ////////////////////////////////////////////////////////////////////////////// |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
164 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
165 const llvm::Type * IrTypeSArray::buildType() |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
166 { |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
167 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo( |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
168 sarray2llvm(dtype)); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
169 return pa.get(); |
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:
diff
changeset
|
170 } |
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:
diff
changeset
|
171 |
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:
diff
changeset
|
172 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
173 |
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:
diff
changeset
|
174 const llvm::Type * IrTypeSArray::sarray2llvm(Type * t) |
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:
diff
changeset
|
175 { |
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:
diff
changeset
|
176 const llvm::Type* elemType = DtoType(t->nextOf()); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
177 if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext())) |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
178 elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext()); |
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:
diff
changeset
|
179 return llvm::ArrayType::get(elemType, dim); |
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:
diff
changeset
|
180 } |
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:
diff
changeset
|
181 |
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:
diff
changeset
|
182 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
183 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
184 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
185 |
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:
diff
changeset
|
186 IrTypeArray::IrTypeArray(Type * dt) |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
187 : IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext())) |
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:
diff
changeset
|
188 { |
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:
diff
changeset
|
189 } |
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:
diff
changeset
|
190 |
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:
diff
changeset
|
191 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
192 |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
193 const llvm::Type * IrTypeArray::buildType() |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
194 { |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
195 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo( |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
196 array2llvm(dtype)); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
197 return pa.get(); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
198 } |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
199 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
200 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
201 |
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:
diff
changeset
|
202 const llvm::Type * IrTypeArray::array2llvm(Type * t) |
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:
diff
changeset
|
203 { |
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:
diff
changeset
|
204 assert(t->ty == Tarray && "not dynamic array type"); |
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:
diff
changeset
|
205 |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
206 // get .ptr type |
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:
diff
changeset
|
207 const llvm::Type* elemType = DtoType(t->nextOf()); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
208 if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext())) |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
209 elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext()); |
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:
diff
changeset
|
210 elemType = llvm::PointerType::get(elemType, 0); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
211 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
212 // create struct type |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
213 const llvm::Type* at = llvm::StructType::get(llvm::getGlobalContext(), DtoSize_t(), elemType, NULL); |
1228
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
214 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
215 // name dynamic array types |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
216 Type::sir->getState()->module->addTypeName(t->toChars(), at); |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
217 |
79758fd2f48a
Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1192
diff
changeset
|
218 return at; |
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:
diff
changeset
|
219 } |
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:
diff
changeset
|
220 |
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:
diff
changeset
|
221 ////////////////////////////////////////////////////////////////////////////// |
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:
diff
changeset
|
222 |