Mercurial > projects > ldc
annotate gen/arrays.c @ 6:35d93ce68cf4 trunk
[svn r10] Updated for LLVM rev. 20070913
Applied fixes from wilsonk on the forum
Some tweaks to work with gc 7.0
Fixed aggregate members of aggregates
Fixed cyclic/recursive class declarations
Other minor tweaks
author | lindquist |
---|---|
date | Wed, 26 Sep 2007 19:05:18 +0200 |
parents | e116aa1488e6 |
children | d3ee9efe20e2 |
rev | line source |
---|---|
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
1 #include "llvm/Constants.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
2 #include "llvm/Type.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
3 #include "llvm/DerivedTypes.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
4 #include "llvm/Instructions.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
5 #include "llvm/CallingConv.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
6 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
7 #include "mtype.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
8 #include "dsymbol.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
9 #include "aggregate.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
10 #include "declaration.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
11 #include "init.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
12 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
13 #include "gen/irstate.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
14 #include "gen/tollvm.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
15 #include "gen/arrays.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
16 #include "gen/runtime.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
17 #include "gen/logger.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
18 #include "gen/elem.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
19 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
20 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
21 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
22 llvm::StructType* LLVM_DtoArrayType(Type* t) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
23 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
24 assert(t->next); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
25 const llvm::Type* at = LLVM_DtoType(t->next); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
26 const llvm::Type* arrty; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
27 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
28 /*if (t->ty == Tsarray) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
29 TypeSArray* tsa = (TypeSArray*)t; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
30 assert(tsa->dim->type->isintegral()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
31 arrty = llvm::ArrayType::get(at,tsa->dim->toUInteger()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
32 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
33 else { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
34 arrty = llvm::ArrayType::get(at,0); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
35 }*/ |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
36 if (at == llvm::Type::VoidTy) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
37 at = llvm::Type::Int8Ty; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
38 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
39 arrty = llvm::PointerType::get(at); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
40 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
41 std::vector<const llvm::Type*> members; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
42 if (global.params.is64bit) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
43 members.push_back(llvm::Type::Int64Ty); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
44 else |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
45 members.push_back(llvm::Type::Int32Ty); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
46 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
47 members.push_back(arrty); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
48 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
49 return llvm::StructType::get(members); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
50 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
51 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
52 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
53 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
54 llvm::ArrayType* LLVM_DtoStaticArrayType(Type* t) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
55 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
56 if (t->llvmType) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
57 return llvm::cast<llvm::ArrayType>(t->llvmType); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
58 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
59 assert(t->ty == Tsarray); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
60 assert(t->next); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
61 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
62 const llvm::Type* at = LLVM_DtoType(t->next); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
63 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
64 TypeSArray* tsa = (TypeSArray*)t; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
65 assert(tsa->dim->type->isintegral()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
66 llvm::ArrayType* arrty = llvm::ArrayType::get(at,tsa->dim->toUInteger()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
67 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
68 tsa->llvmType = arrty; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
69 return arrty; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
70 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
71 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
72 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
73 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
74 llvm::Value* LLVM_DtoNullArray(llvm::Value* v) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
75 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
76 assert(gIR); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
77 d_uns64 n = (global.params.is64bit) ? 16 : 8; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
78 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
79 llvm::Type* i8p_ty = llvm::PointerType::get(llvm::Type::Int8Ty); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
80 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
81 llvm::Value* arr = new llvm::BitCastInst(v,i8p_ty,"tmp",gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
82 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
83 llvm::Function* fn = LLVM_DeclareMemSet32(); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
84 std::vector<llvm::Value*> llargs; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
85 llargs.resize(4); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
86 llargs[0] = arr; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
87 llargs[1] = llvm::ConstantInt::get(llvm::Type::Int8Ty, 0, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
88 llargs[2] = llvm::ConstantInt::get(llvm::Type::Int32Ty, n, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
89 llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
90 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
91 //Logger::cout() << *fn << '|' << *fn->getType() << '\n'; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
92 //Logger::cout() << "to null array call: " << *llargs[0] << '|' << *llargs[1] << '|' << *llargs[2] << '|' << *llargs[3] << '\n'; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
93 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
94 llvm::Value* ret = new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
95 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
96 return ret; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
97 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
98 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
99 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
100 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
101 llvm::Value* LLVM_DtoArrayAssign(llvm::Value* dst, llvm::Value* src) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
102 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
103 assert(gIR); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
104 if (dst->getType() == src->getType()) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
105 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
106 d_uns64 n = (global.params.is64bit) ? 16 : 8; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
107 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
108 llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
109 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
110 llvm::Value* dstarr = new llvm::BitCastInst(dst,arrty,"tmp",gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
111 llvm::Value* srcarr = new llvm::BitCastInst(src,arrty,"tmp",gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
112 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
113 llvm::Function* fn = LLVM_DeclareMemCpy32(); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
114 std::vector<llvm::Value*> llargs; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
115 llargs.resize(4); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
116 llargs[0] = dstarr; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
117 llargs[1] = srcarr; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
118 llargs[2] = llvm::ConstantInt::get(llvm::Type::Int32Ty, n, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
119 llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
120 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
121 return new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
122 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
123 else |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
124 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
125 if (!llvm::isa<llvm::ArrayType>(src->getType()->getContainedType(0))) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
126 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
127 Logger::cout() << "invalid: " << *src << '\n'; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
128 assert(0); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
129 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
130 const llvm::ArrayType* arrty = llvm::cast<llvm::ArrayType>(src->getType()->getContainedType(0)); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
131 llvm::Type* dstty = llvm::PointerType::get(arrty->getElementType()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
132 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
133 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
134 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
135 |
6 | 136 llvm::Value* dstlen = LLVM_DtoGEP(dst,zero,zero,"tmp",gIR->scopebb()); |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
137 llvm::Value* srclen = llvm::ConstantInt::get(LLVM_DtoSize_t(), arrty->getNumElements(), false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
138 new llvm::StoreInst(srclen, dstlen, gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
139 |
6 | 140 llvm::Value* dstptr = LLVM_DtoGEP(dst,zero,one,"tmp",gIR->scopebb()); |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
141 llvm::Value* srcptr = new llvm::BitCastInst(src,dstty,"tmp",gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
142 new llvm::StoreInst(srcptr, dstptr, gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
143 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
144 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
145 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
146 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
147 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
148 void LLVM_DtoArrayInit(llvm::Value* l, llvm::Value* r) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
149 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
150 const llvm::PointerType* ptrty = llvm::cast<llvm::PointerType>(l->getType()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
151 if (llvm::isa<llvm::ArrayType>(ptrty->getContainedType(0))) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
152 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
153 const llvm::ArrayType* arrty = llvm::cast<llvm::ArrayType>(ptrty->getContainedType(0)); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
154 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
155 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
156 std::vector<llvm::Value*> args; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
157 args.resize(3); |
6 | 158 args[0] = LLVM_DtoGEP(l,zero,zero,"tmp",gIR->scopebb()); |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
159 args[1] = llvm::ConstantInt::get(LLVM_DtoSize_t(), arrty->getNumElements(), false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
160 args[2] = r; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
161 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
162 const char* funcname = NULL; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
163 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
164 if (llvm::isa<llvm::PointerType>(arrty->getElementType())) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
165 funcname = "_d_array_init_pointer"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
166 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
167 const llvm::Type* dstty = llvm::PointerType::get(llvm::PointerType::get(llvm::Type::Int8Ty)); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
168 if (args[0]->getType() != dstty) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
169 args[0] = new llvm::BitCastInst(args[0],dstty,"tmp",gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
170 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
171 const llvm::Type* valty = llvm::PointerType::get(llvm::Type::Int8Ty); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
172 if (args[2]->getType() != valty) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
173 args[2] = new llvm::BitCastInst(args[2],valty,"tmp",gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
174 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
175 else if (r->getType() == llvm::Type::Int1Ty) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
176 funcname = "_d_array_init_i1"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
177 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
178 else if (r->getType() == llvm::Type::Int8Ty) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
179 funcname = "_d_array_init_i8"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
180 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
181 else if (r->getType() == llvm::Type::Int16Ty) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
182 funcname = "_d_array_init_i16"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
183 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
184 else if (r->getType() == llvm::Type::Int32Ty) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
185 funcname = "_d_array_init_i32"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
186 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
187 else if (r->getType() == llvm::Type::Int64Ty) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
188 funcname = "_d_array_init_i64"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
189 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
190 else if (r->getType() == llvm::Type::FloatTy) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
191 funcname = "_d_array_init_float"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
192 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
193 else if (r->getType() == llvm::Type::DoubleTy) { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
194 funcname = "_d_array_init_double"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
195 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
196 else { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
197 assert(0); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
198 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
199 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
200 Logger::cout() << *args[0] << '|' << *args[2] << '\n'; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
201 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
202 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, funcname); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
203 assert(fn); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
204 llvm::CallInst* call = new llvm::CallInst(fn, args.begin(), args.end(), "", gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
205 call->setCallingConv(llvm::CallingConv::C); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
206 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
207 Logger::println("array init call ok"); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
208 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
209 else if (llvm::isa<llvm::StructType>(ptrty->getContainedType(0))) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
210 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
211 assert(0 && "Only static arrays support initialisers atm"); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
212 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
213 else |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
214 assert(0); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
215 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
216 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
217 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
218 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
219 void LLVM_DtoSetArray(llvm::Value* arr, llvm::Value* dim, llvm::Value* ptr) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
220 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
221 Logger::cout() << "LLVM_DtoSetArray(" << *arr << ", " << *dim << ", " << *ptr << ")\n"; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
222 const llvm::StructType* st = llvm::cast<llvm::StructType>(arr->getType()->getContainedType(0)); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
223 //const llvm::PointerType* pt = llvm::cast<llvm::PointerType>(r->getType()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
224 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
225 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
226 llvm::Value* one = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1, false); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
227 |
6 | 228 llvm::Value* arrdim = LLVM_DtoGEP(arr,zero,zero,"tmp",gIR->scopebb()); |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
229 new llvm::StoreInst(dim, arrdim, gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
230 |
6 | 231 llvm::Value* arrptr = LLVM_DtoGEP(arr,zero,one,"tmp",gIR->scopebb()); |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
232 new llvm::StoreInst(ptr, arrptr, gIR->scopebb()); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
233 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
234 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
235 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
236 llvm::Constant* LLVM_DtoArrayInitializer(ArrayInitializer* arrinit) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
237 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
238 Logger::println("arr init begin"); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
239 assert(arrinit->type->ty == Tsarray); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
240 TypeSArray* t = (TypeSArray*)arrinit->type; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
241 integer_t tdim = t->dim->toInteger(); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
242 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
243 std::vector<llvm::Constant*> inits(tdim, 0); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
244 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
245 const llvm::Type* elemty = LLVM_DtoType(arrinit->type->next); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
246 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
247 assert(arrinit->index.dim == arrinit->value.dim); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
248 for (int i=0,j=0; i < tdim; ++i) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
249 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
250 Initializer* init = 0; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
251 Expression* idx = (Expression*)arrinit->index.data[j]; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
252 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
253 if (idx) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
254 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
255 integer_t k = idx->toInteger(); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
256 if (i == k) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
257 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
258 init = (Initializer*)arrinit->value.data[j]; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
259 assert(init); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
260 ++j; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
261 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
262 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
263 else |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
264 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
265 init = (Initializer*)arrinit->value.data[j]; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
266 ++j; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
267 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
268 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
269 llvm::Constant* v = 0; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
270 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
271 if (!init) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
272 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
273 elem* e = t->next->defaultInit()->toElem(gIR); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
274 v = llvm::cast<llvm::Constant>(e->val); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
275 delete e; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
276 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
277 else if (ExpInitializer* ex = init->isExpInitializer()) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
278 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
279 elem* e = ex->exp->toElem(gIR); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
280 v = llvm::cast<llvm::Constant>(e->val); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
281 delete e; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
282 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
283 else if (StructInitializer* si = init->isStructInitializer()) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
284 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
285 v = LLVM_DtoStructInitializer(si); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
286 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
287 else if (ArrayInitializer* ai = init->isArrayInitializer()) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
288 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
289 v = LLVM_DtoArrayInitializer(ai); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
290 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
291 else if (init->isVoidInitializer()) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
292 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
293 v = llvm::UndefValue::get(elemty); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
294 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
295 else |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
296 assert(v); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
297 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
298 inits[i] = v; |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
299 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
300 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
301 llvm::ArrayType* arrty = LLVM_DtoStaticArrayType(t); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
302 return llvm::ConstantArray::get(arrty, inits); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
303 } |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
304 |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
305 ////////////////////////////////////////////////////////////////////////////////////////// |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
306 void LLVM_DtoArrayCopy(elem* dst, elem* src) |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
307 { |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
308 assert(0); |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff
changeset
|
309 } |