Mercurial > projects > ldc
comparison ir/irtype.cpp @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | 8d086d552909 |
children |
comparison
equal
deleted
inserted
replaced
1649:36da40ecbbe0 | 1650:40bd4a0d4870 |
---|---|
1 #include "llvm/DerivedTypes.h" | 1 #include "llvm/DerivedTypes.h" |
2 #include "llvm/LLVMContext.h" | |
2 #include "mars.h" | 3 #include "mars.h" |
3 #include "mtype.h" | 4 #include "mtype.h" |
4 #include "gen/irstate.h" | 5 #include "gen/irstate.h" |
5 #include "gen/logger.h" | 6 #include "gen/logger.h" |
6 #include "ir/irtype.h" | 7 #include "ir/irtype.h" |
7 | 8 |
9 // This code uses llvm::getGlobalContext() as these functions are invoked before gIR is set. | |
10 // ... thus it segfaults on gIR==NULL | |
11 | |
8 ////////////////////////////////////////////////////////////////////////////// | 12 ////////////////////////////////////////////////////////////////////////////// |
9 | 13 |
10 extern const llvm::Type* DtoType(Type* dt); | 14 extern const llvm::Type* DtoType(Type* dt); |
11 extern const llvm::Type* DtoSize_t(); | 15 extern const llvm::Type* DtoSize_t(); |
12 | 16 |
41 | 45 |
42 const llvm::Type * IrTypeBasic::basic2llvm(Type* t) | 46 const llvm::Type * IrTypeBasic::basic2llvm(Type* t) |
43 { | 47 { |
44 const llvm::Type* t2; | 48 const llvm::Type* t2; |
45 | 49 |
46 // FIXME: don't use getGlobalContext | 50 llvm::LLVMContext& ctx = llvm::getGlobalContext(); |
51 | |
47 switch(t->ty) | 52 switch(t->ty) |
48 { | 53 { |
49 case Tvoid: | 54 case Tvoid: |
50 return llvm::Type::getVoidTy(llvm::getGlobalContext()); | 55 return llvm::Type::getVoidTy(ctx); |
51 | 56 |
52 case Tint8: | 57 case Tint8: |
53 case Tuns8: | 58 case Tuns8: |
54 case Tchar: | 59 case Tchar: |
55 return llvm::Type::getInt8Ty(llvm::getGlobalContext()); | 60 return llvm::Type::getInt8Ty(ctx); |
56 | 61 |
57 case Tint16: | 62 case Tint16: |
58 case Tuns16: | 63 case Tuns16: |
59 case Twchar: | 64 case Twchar: |
60 return llvm::Type::getInt16Ty(llvm::getGlobalContext()); | 65 return llvm::Type::getInt16Ty(ctx); |
61 | 66 |
62 case Tint32: | 67 case Tint32: |
63 case Tuns32: | 68 case Tuns32: |
64 case Tdchar: | 69 case Tdchar: |
65 return llvm::Type::getInt32Ty(llvm::getGlobalContext()); | 70 return llvm::Type::getInt32Ty(ctx); |
66 | 71 |
67 case Tint64: | 72 case Tint64: |
68 case Tuns64: | 73 case Tuns64: |
69 return llvm::Type::getInt64Ty(llvm::getGlobalContext()); | 74 return llvm::Type::getInt64Ty(ctx); |
70 | 75 |
71 /* | 76 /* |
72 case Tint128: | 77 case Tint128: |
73 case Tuns128: | 78 case Tuns128: |
74 return llvm::IntegerType::get(llvm::getGlobalContext(), 128); | 79 return llvm::IntegerType::get(llvm::getGlobalContext(), 128); |
75 */ | 80 */ |
76 | 81 |
77 case Tfloat32: | 82 case Tfloat32: |
78 case Timaginary32: | 83 case Timaginary32: |
79 return llvm::Type::getFloatTy(llvm::getGlobalContext()); | 84 return llvm::Type::getFloatTy(ctx); |
80 | 85 |
81 case Tfloat64: | 86 case Tfloat64: |
82 case Timaginary64: | 87 case Timaginary64: |
83 return llvm::Type::getDoubleTy(llvm::getGlobalContext()); | 88 return llvm::Type::getDoubleTy(ctx); |
84 | 89 |
85 case Tfloat80: | 90 case Tfloat80: |
86 case Timaginary80: | 91 case Timaginary80: |
87 // only x86 has 80bit float | 92 // only x86 has 80bit float |
88 if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) | 93 if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) |
89 return llvm::Type::getX86_FP80Ty(llvm::getGlobalContext()); | 94 return llvm::Type::getX86_FP80Ty(ctx); |
90 // other platforms use 64bit reals | 95 // other platforms use 64bit reals |
91 else | 96 else |
92 return llvm::Type::getDoubleTy(llvm::getGlobalContext()); | 97 return llvm::Type::getDoubleTy(ctx); |
93 | 98 |
94 case Tcomplex32: | 99 case Tcomplex32: |
95 t2 = llvm::Type::getFloatTy(llvm::getGlobalContext()); | 100 t2 = llvm::Type::getFloatTy(ctx); |
96 return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL); | 101 return llvm::StructType::get(ctx, t2, t2, NULL); |
97 | 102 |
98 case Tcomplex64: | 103 case Tcomplex64: |
99 t2 = llvm::Type::getDoubleTy(llvm::getGlobalContext()); | 104 t2 = llvm::Type::getDoubleTy(ctx); |
100 return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL); | 105 return llvm::StructType::get(ctx, t2, t2, NULL); |
101 | 106 |
102 case Tcomplex80: | 107 case Tcomplex80: |
103 t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) | 108 t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64) |
104 ? llvm::Type::getX86_FP80Ty(llvm::getGlobalContext()) | 109 ? llvm::Type::getX86_FP80Ty(ctx) |
105 : llvm::Type::getDoubleTy(llvm::getGlobalContext()); | 110 : llvm::Type::getDoubleTy(ctx); |
106 return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL); | 111 return llvm::StructType::get(ctx, t2, t2, NULL); |
107 | 112 |
108 case Tbool: | 113 case Tbool: |
109 return llvm::Type::getInt1Ty(llvm::getGlobalContext()); | 114 return llvm::Type::getInt1Ty(ctx); |
110 } | 115 } |
111 | 116 |
112 assert(0 && "not basic type"); | 117 assert(0 && "not basic type"); |
113 return NULL; | 118 return NULL; |
114 } | 119 } |