Mercurial > projects > ldc
annotate gen/runtime.cpp @ 240:0db62b770a49 trunk
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
Fixed: most runtime calls did not get correct param attrs.
author | lindquist |
---|---|
date | Mon, 09 Jun 2008 00:01:10 +0200 |
parents | 7816aafeea3c |
children | a95056b3c996 |
rev | line source |
---|---|
1 | 1 #include <cassert> |
2 | |
52 | 3 #include "gen/llvm.h" |
1 | 4 #include "llvm/Module.h" |
5 #include "llvm/Bitcode/ReaderWriter.h" | |
6 #include "llvm/Support/MemoryBuffer.h" | |
7 | |
8 #include "root.h" | |
9 #include "mars.h" | |
132 | 10 #include "lexer.h" |
11 #include "dsymbol.h" | |
12 #include "mtype.h" | |
13 #include "aggregate.h" | |
1 | 14 |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
15 #include "gen/runtime.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
16 #include "gen/logger.h" |
132 | 17 #include "gen/tollvm.h" |
157
5c17f81fc1c1
[svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7
ChristianK
parents:
133
diff
changeset
|
18 #include "gen/irstate.h" |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
19 |
1 | 20 static llvm::Module* M = NULL; |
21 static bool runtime_failed = false; | |
22 | |
132 | 23 static void LLVM_D_BuildRuntimeModule(); |
24 | |
52 | 25 ////////////////////////////////////////////////////////////////////////////////////////////////// |
26 | |
1 | 27 bool LLVM_D_InitRuntime() |
28 { | |
132 | 29 Logger::println("*** Initializing D runtime declarations ***"); |
1 | 30 LOG_SCOPE; |
31 | |
132 | 32 LLVM_D_BuildRuntimeModule(); |
33 return true; | |
34 | |
35 /* | |
35
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
36 if (!global.params.runtimeImppath) { |
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
37 error("You must set the runtime import path with -E"); |
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
38 fatal(); |
3cfcb944304e
[svn r39] * Updated to DMD 1.022 with the exception of:
lindquist
parents:
4
diff
changeset
|
39 } |
1 | 40 std::string filename(global.params.runtimeImppath); |
41 filename.append("/llvmdcore.bc"); | |
42 llvm::MemoryBuffer* buffer = llvm::MemoryBuffer::getFile(filename.c_str(), filename.length()); | |
43 if (!buffer) { | |
44 Logger::println("Failed to load runtime library from disk"); | |
45 runtime_failed = true; | |
46 return false; | |
47 } | |
48 | |
49 std::string errstr; | |
50 bool retval = false; | |
51 M = llvm::ParseBitcodeFile(buffer, &errstr); | |
52 if (M) { | |
53 retval = true; | |
54 } | |
55 else { | |
56 Logger::println("Failed to load runtime: %s", errstr.c_str()); | |
57 runtime_failed = true; | |
58 } | |
52 | 59 |
1 | 60 delete buffer; |
61 return retval; | |
132 | 62 */ |
1 | 63 } |
64 | |
65 void LLVM_D_FreeRuntime() | |
66 { | |
67 if (M) { | |
132 | 68 Logger::println("*** Freeing D runtime declarations ***"); |
1 | 69 delete M; |
132 | 70 M = NULL; |
1 | 71 } |
72 } | |
73 | |
52 | 74 ////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | |
1 | 76 llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name) |
77 { | |
78 if (global.params.noruntime) { | |
79 error("No implicit runtime calls allowed with -noruntime option enabled"); | |
80 fatal(); | |
81 } | |
52 | 82 |
1 | 83 if (!M) { |
84 assert(!runtime_failed); | |
85 LLVM_D_InitRuntime(); | |
86 } | |
52 | 87 |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
88 llvm::Function* fn = target->getFunction(name); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
89 if (fn) |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
90 return fn; |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
91 |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
92 fn = M->getFunction(name); |
40 | 93 if (!fn) { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
94 printf("Runtime function '%s' was not found\n", name); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
86
diff
changeset
|
95 assert(0); |
40 | 96 //return NULL; |
97 } | |
52 | 98 |
1 | 99 const llvm::FunctionType* fnty = fn->getFunctionType(); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
100 llvm::Function* resfn = llvm::cast<llvm::Function>(target->getOrInsertFunction(name, fnty)); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
101 resfn->setParamAttrs(fn->getParamAttrs()); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
102 return resfn; |
1 | 103 } |
40 | 104 |
52 | 105 ////////////////////////////////////////////////////////////////////////////////////////////////// |
106 | |
107 llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name) | |
108 { | |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
109 llvm::GlobalVariable* gv = target->getNamedGlobal(name); |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
110 if (gv) { |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
111 return gv; |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
112 } |
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
52
diff
changeset
|
113 |
52 | 114 if (global.params.noruntime) { |
115 error("No implicit runtime calls allowed with -noruntime option enabled"); | |
116 fatal(); | |
117 } | |
118 | |
119 if (!M) { | |
120 assert(!runtime_failed); | |
121 LLVM_D_InitRuntime(); | |
122 } | |
123 | |
124 llvm::GlobalVariable* g = M->getNamedGlobal(name); | |
125 if (!g) { | |
126 error("Runtime global '%s' was not found", name); | |
127 fatal(); | |
128 //return NULL; | |
129 } | |
130 | |
131 const llvm::PointerType* t = g->getType(); | |
132 return new llvm::GlobalVariable(t->getElementType(),g->isConstant(),g->getLinkage(),NULL,g->getName(),target); | |
133 } | |
132 | 134 |
135 ////////////////////////////////////////////////////////////////////////////////////////////////// | |
136 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
137 static const LLType* rt_ptr(const LLType* t) |
132 | 138 { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
139 return getPtrToType(t); |
132 | 140 } |
141 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
142 static const LLType* rt_array(const LLType* elemty) |
132 | 143 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
144 std::vector<const LLType*> t; |
132 | 145 t.push_back(DtoSize_t()); |
146 t.push_back(rt_ptr(elemty)); | |
147 return rt_ptr(llvm::StructType::get(t)); | |
148 } | |
149 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
150 static const LLType* rt_array2(const LLType* elemty) |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
151 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
152 std::vector<const LLType*> t; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
153 t.push_back(DtoSize_t()); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
154 t.push_back(rt_ptr(elemty)); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
155 return llvm::StructType::get(t); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
156 } |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
157 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
158 static const LLType* rt_dg1() |
132 | 159 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
160 std::vector<const LLType*> types; |
132 | 161 types.push_back(rt_ptr(llvm::Type::Int8Ty)); |
162 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
163 const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::Int32Ty, types, false); | |
164 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
165 std::vector<const LLType*> t; |
132 | 166 t.push_back(rt_ptr(llvm::Type::Int8Ty)); |
167 t.push_back(rt_ptr(fty)); | |
168 return rt_ptr(llvm::StructType::get(t)); | |
169 } | |
170 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
171 static const LLType* rt_dg2() |
132 | 172 { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
173 std::vector<const LLType*> types; |
132 | 174 types.push_back(rt_ptr(llvm::Type::Int8Ty)); |
175 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
176 types.push_back(rt_ptr(llvm::Type::Int8Ty)); | |
177 const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::Int32Ty, types, false); | |
178 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
179 std::vector<const LLType*> t; |
132 | 180 t.push_back(rt_ptr(llvm::Type::Int8Ty)); |
181 t.push_back(rt_ptr(fty)); | |
182 return rt_ptr(llvm::StructType::get(t)); | |
183 } | |
184 | |
185 static void LLVM_D_BuildRuntimeModule() | |
186 { | |
187 M = new llvm::Module("llvmdc internal runtime"); | |
188 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
189 const LLType* voidTy = llvm::Type::VoidTy; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
190 const LLType* boolTy = llvm::Type::Int1Ty; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
191 const LLType* byteTy = llvm::Type::Int8Ty; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
192 const LLType* shortTy = llvm::Type::Int16Ty; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
193 const LLType* intTy = llvm::Type::Int32Ty; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
194 const LLType* longTy = llvm::Type::Int64Ty; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
195 const LLType* floatTy = llvm::Type::FloatTy; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
196 const LLType* doubleTy = llvm::Type::DoubleTy; |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
197 const LLType* sizeTy = DtoSize_t(); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
198 const LLType* voidPtrTy = rt_ptr(byteTy); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
199 const LLType* stringTy = rt_array(byteTy); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
200 const LLType* wstringTy = rt_array(shortTy); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
201 const LLType* dstringTy = rt_array(intTy); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
202 const LLType* objectTy = rt_ptr(ClassDeclaration::object->type->ir.type->get()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
203 const LLType* classInfoTy = rt_ptr(ClassDeclaration::classinfo->type->ir.type->get()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
204 const LLType* typeInfoTy = rt_ptr(Type::typeinfo->type->ir.type->get()); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
205 const LLType* aaTy = rt_ptr(llvm::OpaqueType::get()); |
132 | 206 |
207 ///////////////////////////////////////////////////////////////////////////////////// | |
208 ///////////////////////////////////////////////////////////////////////////////////// | |
209 ///////////////////////////////////////////////////////////////////////////////////// | |
210 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
211 // void _d_assert( char[] file, uint line ) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
212 // void _d_array_bounds( char[] file, uint line ) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
213 // void _d_switch_error( char[] file, uint line ) |
132 | 214 { |
215 std::string fname("_d_assert"); | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
216 std::string fname2("_d_array_bounds"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
217 std::string fname3("_d_switch_error"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
218 std::vector<const LLType*> types; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
219 types.push_back(stringTy); |
132 | 220 types.push_back(intTy); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
221 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
222 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
223 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
224 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
225 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
226 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M)->setParamAttrs(palist); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
227 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
228 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
229 // void _d_assert_msg( char[] msg, char[] file, uint line ) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
230 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
231 std::string fname("_d_assert_msg"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
232 std::vector<const LLType*> types; |
132 | 233 types.push_back(stringTy); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
234 types.push_back(stringTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
235 types.push_back(intTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
236 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
237 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
238 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
239 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
240 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
132 | 241 } |
242 | |
243 ///////////////////////////////////////////////////////////////////////////////////// | |
244 ///////////////////////////////////////////////////////////////////////////////////// | |
245 ///////////////////////////////////////////////////////////////////////////////////// | |
246 | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
247 // void* _d_allocmemoryT(TypeInfo ti) |
132 | 248 { |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
249 std::string fname("_d_allocmemoryT"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
250 std::vector<const LLType*> types; |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
251 types.push_back(typeInfoTy); |
132 | 252 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
253 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 254 } |
255 | |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
256 // void* _d_newarrayT(TypeInfo ti, size_t length) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
257 // void* _d_newarrayiT(TypeInfo ti, size_t length) |
132 | 258 { |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
259 std::string fname("_d_newarrayT"); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
260 std::string fname2("_d_newarrayiT"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
261 std::vector<const LLType*> types; |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
262 types.push_back(typeInfoTy); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
263 types.push_back(sizeTy); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
264 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
265 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
266 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
267 } |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
268 |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
269 // void* _d_arraysetlengthT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
270 // void* _d_arraysetlengthiT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
271 { |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
272 std::string fname("_d_arraysetlengthT"); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
273 std::string fname2("_d_arraysetlengthiT"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
274 std::vector<const LLType*> types; |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
275 types.push_back(typeInfoTy); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
276 types.push_back(sizeTy); |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
277 types.push_back(sizeTy); |
132 | 278 types.push_back(voidPtrTy); |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
197
diff
changeset
|
279 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
280 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
281 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); |
132 | 282 } |
283 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
284 // Object _d_newclass(ClassInfo ci) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
285 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
286 std::string fname("_d_newclass"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
287 std::vector<const LLType*> types; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
288 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
289 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
290 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
291 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
292 |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
293 // void _d_delarray(size_t plength, void* pdata) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
294 { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
295 std::string fname("_d_delarray"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
296 std::vector<const LLType*> types; |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
297 types.push_back(sizeTy); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
298 types.push_back(voidPtrTy); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
299 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
300 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
301 } |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
302 |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
303 // void _d_delmemory(void* p) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
304 // void _d_delinterface(void* p) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
305 // void _d_callfinalizer(void* p) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
306 { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
307 std::string fname("_d_delmemory"); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
308 std::string fname2("_d_delinterface"); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
309 std::string fname3("_d_callfinalizer"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
310 std::vector<const LLType*> types; |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
311 types.push_back(voidPtrTy); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
312 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
313 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
314 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
315 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
316 } |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
317 |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
318 // void _d_delclass(Object p) |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
319 { |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
320 std::string fname("_d_delclass"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
321 std::vector<const LLType*> types; |
209
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
322 types.push_back(objectTy); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
323 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
324 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
325 } |
c4c9b4ac021b
[svn r225] Fixed: delete expressions no longer use llvm's free instruction, which crashes on a GC provided pointer.
lindquist
parents:
205
diff
changeset
|
326 |
132 | 327 ///////////////////////////////////////////////////////////////////////////////////// |
328 ///////////////////////////////////////////////////////////////////////////////////// | |
329 ///////////////////////////////////////////////////////////////////////////////////// | |
330 | |
331 #define ARRAY_INIT(TY,suffix) \ | |
332 { \ | |
333 std::string fname("_d_array_init_"); \ | |
334 fname.append(suffix); \ | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
335 std::vector<const LLType*> types; \ |
132 | 336 types.push_back(rt_ptr(TY)); \ |
337 types.push_back(sizeTy); \ | |
338 types.push_back(TY); \ | |
339 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); \ | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
340 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ |
132 | 341 } |
342 | |
343 ARRAY_INIT(boolTy,"i1") | |
344 ARRAY_INIT(byteTy,"i8") | |
345 ARRAY_INIT(shortTy,"i16") | |
346 ARRAY_INIT(intTy,"i32") | |
347 ARRAY_INIT(longTy,"i64") | |
348 ARRAY_INIT(floatTy,"float") | |
349 ARRAY_INIT(doubleTy,"double") | |
350 ARRAY_INIT(voidPtrTy,"pointer") | |
351 | |
352 #undef ARRAY_INIT | |
353 | |
354 // array init mem | |
355 // void _d_array_init_mem(void* a, size_t na, void* v, size_t nv) | |
356 { | |
357 std::string fname("_d_array_init_mem"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
358 std::vector<const LLType*> types; |
132 | 359 types.push_back(voidPtrTy); |
360 types.push_back(sizeTy); | |
361 types.push_back(voidPtrTy); | |
362 types.push_back(sizeTy); | |
363 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
364 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 365 } |
366 | |
367 ///////////////////////////////////////////////////////////////////////////////////// | |
368 ///////////////////////////////////////////////////////////////////////////////////// | |
369 ///////////////////////////////////////////////////////////////////////////////////// | |
370 | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
371 // int _aApplycd1(char[] aa, dg_t dg) |
132 | 372 #define STR_APPLY1(TY,a,b) \ |
373 { \ | |
374 std::string fname(a); \ | |
375 std::string fname2(b); \ | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
376 std::vector<const LLType*> types; \ |
132 | 377 types.push_back(TY); \ |
378 types.push_back(rt_dg1()); \ | |
379 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
380 llvm::PAListPtr palist; \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
381 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
382 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
383 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
384 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); \ |
132 | 385 } |
386 STR_APPLY1(stringTy, "_aApplycw1", "_aApplycd1") | |
387 STR_APPLY1(wstringTy, "_aApplywc1", "_aApplywd1") | |
388 STR_APPLY1(dstringTy, "_aApplydc1", "_aApplydw1") | |
389 #undef STR_APPLY | |
390 | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
391 // int _aApplycd2(char[] aa, dg2_t dg) |
132 | 392 #define STR_APPLY2(TY,a,b) \ |
393 { \ | |
394 std::string fname(a); \ | |
395 std::string fname2(b); \ | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
396 std::vector<const LLType*> types; \ |
132 | 397 types.push_back(TY); \ |
398 types.push_back(rt_dg2()); \ | |
399 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
400 llvm::PAListPtr palist; \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
401 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
402 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
403 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
404 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); \ |
132 | 405 } |
406 STR_APPLY2(stringTy, "_aApplycw2", "_aApplycd2") | |
407 STR_APPLY2(wstringTy, "_aApplywc2", "_aApplywd2") | |
408 STR_APPLY2(dstringTy, "_aApplydc2", "_aApplydw2") | |
409 #undef STR_APPLY2 | |
410 | |
411 #define STR_APPLY_R1(TY,a,b) \ | |
412 { \ | |
413 std::string fname(a); \ | |
414 std::string fname2(b); \ | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
415 std::vector<const LLType*> types; \ |
132 | 416 types.push_back(TY); \ |
417 types.push_back(rt_dg1()); \ | |
418 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
419 llvm::PAListPtr palist; \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
420 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
421 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
422 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
423 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); \ |
132 | 424 } |
425 STR_APPLY_R1(stringTy, "_aApplyRcw1", "_aApplyRcd1") | |
426 STR_APPLY_R1(wstringTy, "_aApplyRwc1", "_aApplyRwd1") | |
427 STR_APPLY_R1(dstringTy, "_aApplyRdc1", "_aApplyRdw1") | |
428 #undef STR_APPLY | |
429 | |
430 #define STR_APPLY_R2(TY,a,b) \ | |
431 { \ | |
432 std::string fname(a); \ | |
433 std::string fname2(b); \ | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
434 std::vector<const LLType*> types; \ |
132 | 435 types.push_back(TY); \ |
436 types.push_back(rt_dg2()); \ | |
437 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); \ | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
438 llvm::PAListPtr palist; \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
439 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
440 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
441 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); \ |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
442 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); \ |
132 | 443 } |
444 STR_APPLY_R2(stringTy, "_aApplyRcw2", "_aApplyRcd2") | |
445 STR_APPLY_R2(wstringTy, "_aApplyRwc2", "_aApplyRwd2") | |
446 STR_APPLY_R2(dstringTy, "_aApplyRdc2", "_aApplyRdw2") | |
447 #undef STR_APPLY2 | |
448 | |
449 ///////////////////////////////////////////////////////////////////////////////////// | |
450 ///////////////////////////////////////////////////////////////////////////////////// | |
451 ///////////////////////////////////////////////////////////////////////////////////// | |
452 | |
453 // fixes the length for dynamic array casts | |
454 // size_t _d_array_cast_len(size_t len, size_t elemsz, size_t newelemsz) | |
455 { | |
456 std::string fname("_d_array_cast_len"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
457 std::vector<const LLType*> types; |
132 | 458 types.push_back(sizeTy); |
459 types.push_back(sizeTy); | |
460 types.push_back(sizeTy); | |
461 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
462 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 463 } |
464 | |
465 ///////////////////////////////////////////////////////////////////////////////////// | |
466 ///////////////////////////////////////////////////////////////////////////////////// | |
467 ///////////////////////////////////////////////////////////////////////////////////// | |
468 | |
469 // builds the d string[] for the D main args from the C main args | |
470 // void _d_main_args(uint n, char** args, ref char[][] res) | |
471 { | |
472 std::string fname("_d_main_args"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
473 std::vector<const LLType*> types; |
132 | 474 types.push_back(intTy); |
475 types.push_back(rt_ptr(rt_ptr(byteTy))); | |
476 types.push_back(rt_array(stringTy->getContainedType(0))); | |
477 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
478 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 479 } |
480 | |
481 ///////////////////////////////////////////////////////////////////////////////////// | |
482 ///////////////////////////////////////////////////////////////////////////////////// | |
483 ///////////////////////////////////////////////////////////////////////////////////// | |
484 | |
485 // cast to object | |
486 // Object _d_toObject(void* p) | |
487 { | |
488 std::string fname("_d_toObject"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
489 std::vector<const LLType*> types; |
132 | 490 types.push_back(voidPtrTy); |
491 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
492 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 493 } |
494 | |
495 // cast interface | |
496 // Object _d_interface_cast(void* p, ClassInfo c) | |
497 { | |
498 std::string fname("_d_interface_cast"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
499 std::vector<const LLType*> types; |
132 | 500 types.push_back(voidPtrTy); |
501 types.push_back(classInfoTy); | |
502 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
503 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 504 } |
505 | |
506 // dynamic cast | |
507 // Object _d_dynamic_cast(Object o, ClassInfo c) | |
508 { | |
509 std::string fname("_d_dynamic_cast"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
510 std::vector<const LLType*> types; |
132 | 511 types.push_back(objectTy); |
512 types.push_back(classInfoTy); | |
513 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
514 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 515 } |
516 | |
517 ///////////////////////////////////////////////////////////////////////////////////// | |
518 ///////////////////////////////////////////////////////////////////////////////////// | |
519 ///////////////////////////////////////////////////////////////////////////////////// | |
520 | |
521 // char[] _adReverseChar(char[] a) | |
522 // char[] _adSortChar(char[] a) | |
523 { | |
524 std::string fname("_adReverseChar"); | |
525 std::string fname2("_adSortChar"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
526 std::vector<const LLType*> types; |
132 | 527 types.push_back(stringTy); |
528 types.push_back(stringTy); | |
529 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
530 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
531 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
532 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
533 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); |
132 | 534 } |
535 | |
536 // wchar[] _adReverseWchar(wchar[] a) | |
537 // wchar[] _adSortWchar(wchar[] a) | |
538 { | |
539 std::string fname("_adReverseWchar"); | |
540 std::string fname2("_adSortWchar"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
541 std::vector<const LLType*> types; |
132 | 542 types.push_back(wstringTy); |
543 types.push_back(wstringTy); | |
544 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
545 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
546 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
547 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
548 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); |
132 | 549 } |
550 | |
551 // Array _adReverse(Array a, size_t szelem) | |
552 { | |
553 std::string fname("_adReverse"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
554 std::vector<const LLType*> types; |
132 | 555 types.push_back(rt_array(byteTy)); |
556 types.push_back(rt_array(byteTy)); | |
557 types.push_back(sizeTy); | |
558 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
559 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
560 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
561 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
132 | 562 } |
563 | |
564 // Array _adDupT(TypeInfo ti, Array a) | |
565 { | |
566 std::string fname("_adDupT"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
567 std::vector<const LLType*> types; |
132 | 568 types.push_back(rt_array(byteTy)); |
569 types.push_back(typeInfoTy); | |
570 types.push_back(rt_array(byteTy)); | |
571 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
572 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
573 palist = palist.addAttr(3, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
574 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
132 | 575 } |
576 | |
577 // int _adEq(Array a1, Array a2, TypeInfo ti) | |
578 // int _adCmp(Array a1, Array a2, TypeInfo ti) | |
579 { | |
580 std::string fname("_adEq"); | |
581 std::string fname2("_adCmp"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
582 std::vector<const LLType*> types; |
132 | 583 types.push_back(rt_array(byteTy)); |
584 types.push_back(rt_array(byteTy)); | |
585 types.push_back(typeInfoTy); | |
586 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
587 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
588 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
589 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
590 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
591 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M)->setParamAttrs(palist); |
132 | 592 } |
593 | |
594 // int _adCmpChar(Array a1, Array a2) | |
595 { | |
596 std::string fname("_adCmpChar"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
597 std::vector<const LLType*> types; |
132 | 598 types.push_back(rt_array(byteTy)); |
599 types.push_back(rt_array(byteTy)); | |
600 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
601 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
602 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
603 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
604 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
132 | 605 } |
606 | |
607 // Array _adSort(Array a, TypeInfo ti) | |
608 { | |
609 std::string fname("_adSort"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
610 std::vector<const LLType*> types; |
132 | 611 types.push_back(rt_array(byteTy)); |
612 types.push_back(rt_array(byteTy)); | |
613 types.push_back(typeInfoTy); | |
614 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
615 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
616 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
617 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
132 | 618 } |
619 | |
620 ///////////////////////////////////////////////////////////////////////////////////// | |
621 ///////////////////////////////////////////////////////////////////////////////////// | |
622 ///////////////////////////////////////////////////////////////////////////////////// | |
623 | |
624 // size_t _aaLen(AA aa) | |
625 { | |
626 std::string fname("_aaLen"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
627 std::vector<const LLType*> types; |
132 | 628 types.push_back(aaTy); |
629 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
630 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 631 } |
632 | |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
157
diff
changeset
|
633 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) |
132 | 634 { |
635 std::string fname("_aaGet"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
636 std::vector<const LLType*> types; |
132 | 637 types.push_back(aaTy); |
638 types.push_back(typeInfoTy); | |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
157
diff
changeset
|
639 types.push_back(sizeTy); |
132 | 640 types.push_back(voidPtrTy); |
641 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
642 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 643 } |
644 | |
645 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) | |
646 { | |
647 std::string fname("_aaGetRvalue"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
648 std::vector<const LLType*> types; |
132 | 649 types.push_back(aaTy); |
650 types.push_back(typeInfoTy); | |
651 types.push_back(sizeTy); | |
652 types.push_back(voidPtrTy); | |
653 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
654 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 655 } |
656 | |
657 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) | |
658 { | |
659 std::string fname("_aaIn"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
660 std::vector<const LLType*> types; |
132 | 661 types.push_back(aaTy); |
662 types.push_back(typeInfoTy); | |
663 types.push_back(voidPtrTy); | |
664 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
665 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 666 } |
667 | |
668 // void _aaDel(AA aa, TypeInfo keyti, void* pkey) | |
669 { | |
670 std::string fname("_aaDel"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
671 std::vector<const LLType*> types; |
132 | 672 types.push_back(aaTy); |
673 types.push_back(typeInfoTy); | |
674 types.push_back(voidPtrTy); | |
675 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
676 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 677 } |
678 | |
679 // ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize) | |
680 { | |
681 std::string fname("_aaValues"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
682 std::vector<const LLType*> types; |
132 | 683 types.push_back(rt_array(byteTy)); |
684 types.push_back(aaTy); | |
685 types.push_back(sizeTy); | |
686 types.push_back(sizeTy); | |
687 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
688 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 689 } |
690 | |
691 // void* _aaRehash(AA* paa, TypeInfo keyti) | |
692 { | |
693 std::string fname("_aaRehash"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
694 std::vector<const LLType*> types; |
132 | 695 types.push_back(aaTy); |
696 types.push_back(typeInfoTy); | |
697 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
698 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 699 } |
700 | |
701 // ArrayRet_t _aaKeys(AA aa, size_t keysize) | |
702 { | |
703 std::string fname("_aaKeys"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
704 std::vector<const LLType*> types; |
132 | 705 types.push_back(rt_array(byteTy)); |
706 types.push_back(aaTy); | |
707 types.push_back(sizeTy); | |
708 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
709 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
132 | 710 } |
711 | |
712 // int _aaApply(AA aa, size_t keysize, dg_t dg) | |
713 { | |
714 std::string fname("_aaApply"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
715 std::vector<const LLType*> types; |
132 | 716 types.push_back(aaTy); |
717 types.push_back(sizeTy); | |
718 types.push_back(rt_dg1()); | |
719 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
720 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
721 palist = palist.addAttr(3, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
722 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
132 | 723 } |
724 | |
725 // int _aaApply2(AA aa, size_t keysize, dg2_t dg) | |
726 { | |
727 std::string fname("_aaApply2"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
728 std::vector<const LLType*> types; |
132 | 729 types.push_back(aaTy); |
730 types.push_back(sizeTy); | |
731 types.push_back(rt_dg1()); | |
732 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
733 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
734 palist = palist.addAttr(3, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
735 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
132 | 736 } |
737 | |
738 ///////////////////////////////////////////////////////////////////////////////////// | |
739 ///////////////////////////////////////////////////////////////////////////////////// | |
740 ///////////////////////////////////////////////////////////////////////////////////// | |
741 | |
742 // void _moduleCtor() | |
743 // void _moduleDtor() | |
744 { | |
745 std::string fname("_moduleCtor"); | |
746 std::string fname2("_moduleDtor"); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
747 std::vector<const LLType*> types; |
132 | 748 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
749 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
750 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); |
132 | 751 } |
752 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
753 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
754 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
755 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
756 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
757 // Object _d_toObject(void* p) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
758 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
759 std::string fname("_d_toObject"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
760 std::vector<const LLType*> types; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
761 types.push_back(voidPtrTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
762 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
763 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
764 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
765 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
766 // Object _d_dynamic_cast(Object o, ClassInfo c) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
767 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
768 std::string fname("_d_dynamic_cast"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
769 std::vector<const LLType*> types; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
770 types.push_back(objectTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
771 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
772 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
773 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
774 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
775 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
776 // Object _d_interface_cast(void* p, ClassInfo c) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
777 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
778 std::string fname("_d_interface_cast"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
779 std::vector<const LLType*> types; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
780 types.push_back(voidPtrTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
781 types.push_back(classInfoTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
782 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
783 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
784 } |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
785 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
786 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
787 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
788 ///////////////////////////////////////////////////////////////////////////////////// |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
789 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
790 // void _d_throw_exception(Object e) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
791 { |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
792 std::string fname("_d_throw_exception"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
793 std::vector<const LLType*> types; |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
794 types.push_back(objectTy); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
795 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
203
diff
changeset
|
796 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
797 } |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
798 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
799 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
800 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
801 ///////////////////////////////////////////////////////////////////////////////////// |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
802 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
803 // int _d_switch_string(char[][] table, char[] ca) |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
804 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
805 std::string fname("_d_switch_string"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
806 std::vector<const LLType*> types; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
807 types.push_back(rt_array(rt_array2(byteTy))); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
808 types.push_back(stringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
809 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
810 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
811 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
812 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
813 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
814 } |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
815 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
816 // int _d_switch_ustring(wchar[][] table, wchar[] ca) |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
817 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
818 std::string fname("_d_switch_ustring"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
819 std::vector<const LLType*> types; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
820 types.push_back(rt_array(rt_array2(shortTy))); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
821 types.push_back(wstringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
822 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
823 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
824 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
825 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
826 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
827 } |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
828 |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
829 // int _d_switch_dstring(dchar[][] table, dchar[] ca) |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
830 { |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
831 std::string fname("_d_switch_dstring"); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
209
diff
changeset
|
832 std::vector<const LLType*> types; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
191
diff
changeset
|
833 types.push_back(rt_array(rt_array2(intTy))); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
834 types.push_back(dstringTy); |
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
835 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
240
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
836 llvm::PAListPtr palist; |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
837 palist = palist.addAttr(1, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
838 palist = palist.addAttr(2, llvm::ParamAttr::ByVal); |
0db62b770a49
[svn r257] Fixed: array .sort and .reverse runtime code was incorrect.
lindquist
parents:
213
diff
changeset
|
839 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)->setParamAttrs(palist); |
191
2900754a6989
[svn r207] Fixed: the runtime support didn't handle string switch.
lindquist
parents:
173
diff
changeset
|
840 } |
132 | 841 } |
842 | |
843 | |
844 | |
845 | |
846 | |
847 |