annotate ir/irtype.cpp @ 1638:0de4525a9ed6

Apply workaround for #395 by klickverbot.
author Christian Kamm <kamm incasoftware de>
date Mon, 08 Mar 2010 20:06:08 +0100
parents 8d086d552909
children 40bd4a0d4870
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
2 #include "mars.h"
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
3 #include "mtype.h"
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
4 #include "gen/irstate.h"
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
5 #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
6 #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
7
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
8 //////////////////////////////////////////////////////////////////////////////
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
9
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
10 extern const llvm::Type* DtoType(Type* dt);
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
11 extern const llvm::Type* DtoSize_t();
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 //////////////////////////////////////////////////////////////////////////////
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
14
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
15 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
16 : 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
17 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
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 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
20 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
21 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
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
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 //////////////////////////////////////////////////////////////////////////////
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
25 //////////////////////////////////////////////////////////////////////////////
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 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
29 : 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
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
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 //////////////////////////////////////////////////////////////////////////////
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
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
35 const llvm::Type * IrTypeBasic::buildType()
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
36 {
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
37 return pa.get();
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
38 }
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
39
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
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
42 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
43 {
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
44 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
45
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
46 // FIXME: don't use 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
47 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
48 {
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 case Tvoid:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
50 return llvm::Type::getVoidTy(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
51
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 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
53 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
54 case Tchar:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
55 return 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
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 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
58 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
59 case Twchar:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
60 return llvm::Type::getInt16Ty(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
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 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
63 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
64 case Tdchar:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
65 return llvm::Type::getInt32Ty(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
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 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
68 case Tuns64:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
69 return llvm::Type::getInt64Ty(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
70
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 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
73 case Tuns128:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
74 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
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 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
78 case Timaginary32:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
79 return llvm::Type::getFloatTy(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
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 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
82 case Timaginary64:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
83 return llvm::Type::getDoubleTy(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
84
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 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
86 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
87 // 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
88 if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
89 return llvm::Type::getX86_FP80Ty(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
90 // 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
91 else
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
92 return llvm::Type::getDoubleTy(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
93
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
94 case Tcomplex32:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
95 t2 = llvm::Type::getFloatTy(llvm::getGlobalContext());
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
96 return llvm::StructType::get(llvm::getGlobalContext(), 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
97
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 case Tcomplex64:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
99 t2 = llvm::Type::getDoubleTy(llvm::getGlobalContext());
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
100 return llvm::StructType::get(llvm::getGlobalContext(), 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
101
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 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
103 t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
104 ? llvm::Type::getX86_FP80Ty(llvm::getGlobalContext())
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
105 : llvm::Type::getDoubleTy(llvm::getGlobalContext());
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
106 return llvm::StructType::get(llvm::getGlobalContext(), 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
107
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 case Tbool:
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
109 return llvm::Type::getInt1Ty(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
110 }
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
111
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 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
113 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
114 }
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 //////////////////////////////////////////////////////////////////////////////
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 //////////////////////////////////////////////////////////////////////////////
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 IrTypePointer::IrTypePointer(Type * dt)
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
121 : 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
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 //////////////////////////////////////////////////////////////////////////////
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
126
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
127 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
128 {
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
129 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo(
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
130 pointer2llvm(dtype));
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
131 return pa.get();
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
132 }
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 //////////////////////////////////////////////////////////////////////////////
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
135
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
136 const llvm::Type * IrTypePointer::pointer2llvm(Type * dt)
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
137 {
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
138 assert(dt->ty == Tpointer && "not pointer type");
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 const llvm::Type* elemType = DtoType(dt->nextOf());
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
141 if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
142 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
143 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
144 }
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
145
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
146 //////////////////////////////////////////////////////////////////////////////
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
147 //////////////////////////////////////////////////////////////////////////////
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 //////////////////////////////////////////////////////////////////////////////
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 IrTypeSArray::IrTypeSArray(Type * dt)
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
151 : 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
152 {
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
153 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
154 TypeSArray* tsa = (TypeSArray*)dt;
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
155 dim = (uint64_t)tsa->dim->toUInteger();
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
156 }
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
157
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
158 //////////////////////////////////////////////////////////////////////////////
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
159
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
160 const llvm::Type * IrTypeSArray::buildType()
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 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo(
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
163 sarray2llvm(dtype));
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
164 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
165 }
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
166
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
167 //////////////////////////////////////////////////////////////////////////////
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
168
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
169 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
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 const llvm::Type* elemType = DtoType(t->nextOf());
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
172 if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
173 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
174 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
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
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
177 //////////////////////////////////////////////////////////////////////////////
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
178 //////////////////////////////////////////////////////////////////////////////
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 //////////////////////////////////////////////////////////////////////////////
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 IrTypeArray::IrTypeArray(Type * dt)
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
182 : 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
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 //////////////////////////////////////////////////////////////////////////////
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
187
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
188 const llvm::Type * IrTypeArray::buildType()
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
189 {
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
190 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo(
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
191 array2llvm(dtype));
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
192 return pa.get();
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
193 }
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 //////////////////////////////////////////////////////////////////////////////
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
196
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
197 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
198 {
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
199 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
200
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
201 // 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
202 const llvm::Type* elemType = DtoType(t->nextOf());
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
203 if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
204 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
205 elemType = llvm::PointerType::get(elemType, 0);
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
206
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
207 // create struct type
1571
8d086d552909 IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
208 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
209
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
210 // name dynamic array types
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
211 Type::sir->getState()->module->addTypeName(t->toChars(), at);
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
212
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1192
diff changeset
213 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
214 }
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
215
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
216 //////////////////////////////////////////////////////////////////////////////
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
217