Mercurial > projects > ldc
comparison gen/runtime.cpp @ 1277:6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
passes with more information.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Wed, 29 Apr 2009 17:47:24 +0200 |
parents | f528e55fb32f |
children | 00b408a5b7fa |
comparison
equal
deleted
inserted
replaced
1276:fa20726fe074 | 1277:6bd5ce91b136 |
---|---|
1 #include "gen/llvm.h" | 1 #include "gen/llvm.h" |
2 #include "llvm/Module.h" | 2 #include "llvm/Module.h" |
3 #include "llvm/Attributes.h" | |
3 #include "llvm/Bitcode/ReaderWriter.h" | 4 #include "llvm/Bitcode/ReaderWriter.h" |
4 #include "llvm/Support/MemoryBuffer.h" | 5 #include "llvm/Support/MemoryBuffer.h" |
5 #include "llvm/Support/CommandLine.h" | 6 #include "llvm/Support/CommandLine.h" |
6 | 7 |
7 #include "root.h" | 8 #include "root.h" |
13 | 14 |
14 #include "gen/runtime.h" | 15 #include "gen/runtime.h" |
15 #include "gen/logger.h" | 16 #include "gen/logger.h" |
16 #include "gen/tollvm.h" | 17 #include "gen/tollvm.h" |
17 #include "gen/irstate.h" | 18 #include "gen/irstate.h" |
19 | |
20 using namespace llvm::Attribute; | |
18 | 21 |
19 ////////////////////////////////////////////////////////////////////////////////////////////////// | 22 ////////////////////////////////////////////////////////////////////////////////////////////////// |
20 | 23 |
21 static llvm::cl::opt<bool> noruntime("noruntime", | 24 static llvm::cl::opt<bool> noruntime("noruntime", |
22 llvm::cl::desc("Do not allow code that generates implicit runtime calls"), | 25 llvm::cl::desc("Do not allow code that generates implicit runtime calls"), |
188 | 191 |
189 ///////////////////////////////////////////////////////////////////////////////////// | 192 ///////////////////////////////////////////////////////////////////////////////////// |
190 ///////////////////////////////////////////////////////////////////////////////////// | 193 ///////////////////////////////////////////////////////////////////////////////////// |
191 ///////////////////////////////////////////////////////////////////////////////////// | 194 ///////////////////////////////////////////////////////////////////////////////////// |
192 | 195 |
196 // Construct some attribute lists used below (possibly multiple times) | |
197 llvm::AttrListPtr | |
198 NoAttrs, | |
199 Attr_NoAlias | |
200 = NoAttrs.addAttr(0, NoAlias), | |
201 Attr_ReadOnly | |
202 = NoAttrs.addAttr(~0U, ReadOnly), | |
203 Attr_ReadOnly_1_NoCapture | |
204 = Attr_ReadOnly.addAttr(1, NoCapture), | |
205 Attr_ReadOnly_1_3_NoCapture | |
206 = Attr_ReadOnly_1_NoCapture.addAttr(3, NoCapture), | |
207 Attr_ReadOnly_1_4_NoCapture | |
208 = Attr_ReadOnly_1_NoCapture.addAttr(4, NoCapture), | |
209 Attr_ReadNone | |
210 = NoAttrs.addAttr(~0U, ReadNone), | |
211 Attr_1_NoCapture | |
212 = NoAttrs.addAttr(1, NoCapture), | |
213 Attr_NoAlias_1_NoCapture | |
214 = Attr_1_NoCapture.addAttr(0, NoAlias), | |
215 Attr_NoAlias_3_NoCapture | |
216 = Attr_NoAlias.addAttr(3, NoCapture), | |
217 Attr_1_3_NoCapture | |
218 = Attr_1_NoCapture.addAttr(3, NoCapture), | |
219 Attr_1_4_NoCapture | |
220 = Attr_1_NoCapture.addAttr(4, NoCapture); | |
221 | |
222 ///////////////////////////////////////////////////////////////////////////////////// | |
223 ///////////////////////////////////////////////////////////////////////////////////// | |
224 ///////////////////////////////////////////////////////////////////////////////////// | |
225 | |
193 // void _d_assert( char[] file, uint line ) | 226 // void _d_assert( char[] file, uint line ) |
194 // void _d_array_bounds( char[] file, uint line ) | 227 // void _d_array_bounds( char[] file, uint line ) |
195 // void _d_switch_error( char[] file, uint line ) | 228 // void _d_switch_error( char[] file, uint line ) |
196 { | 229 { |
197 std::string fname("_d_assert"); | 230 std::string fname("_d_assert"); |
225 { | 258 { |
226 std::string fname("_d_allocmemoryT"); | 259 std::string fname("_d_allocmemoryT"); |
227 std::vector<const LLType*> types; | 260 std::vector<const LLType*> types; |
228 types.push_back(typeInfoTy); | 261 types.push_back(typeInfoTy); |
229 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | 262 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
230 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 263 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
264 ->setAttributes(Attr_NoAlias); | |
231 } | 265 } |
232 | 266 |
233 // void* _d_newarrayT(TypeInfo ti, size_t length) | 267 // void* _d_newarrayT(TypeInfo ti, size_t length) |
234 // void* _d_newarrayiT(TypeInfo ti, size_t length) | 268 // void* _d_newarrayiT(TypeInfo ti, size_t length) |
235 // void* _d_newarrayvT(TypeInfo ti, size_t length) | 269 // void* _d_newarrayvT(TypeInfo ti, size_t length) |
239 std::string fname3("_d_newarrayvT"); | 273 std::string fname3("_d_newarrayvT"); |
240 std::vector<const LLType*> types; | 274 std::vector<const LLType*> types; |
241 types.push_back(typeInfoTy); | 275 types.push_back(typeInfoTy); |
242 types.push_back(sizeTy); | 276 types.push_back(sizeTy); |
243 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | 277 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
244 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 278 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
245 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | 279 ->setAttributes(Attr_NoAlias); |
246 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); | 280 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M) |
281 ->setAttributes(Attr_NoAlias); | |
282 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M) | |
283 ->setAttributes(Attr_NoAlias); | |
247 } | 284 } |
248 | 285 |
249 // void* _d_newarraymT(TypeInfo ti, size_t length, size_t* dims) | 286 // void* _d_newarraymT(TypeInfo ti, size_t length, size_t* dims) |
250 // void* _d_newarraymiT(TypeInfo ti, size_t length, size_t* dims) | 287 // void* _d_newarraymiT(TypeInfo ti, size_t length, size_t* dims) |
251 // void* _d_newarraymvT(TypeInfo ti, size_t length, size_t* dims) | 288 // void* _d_newarraymvT(TypeInfo ti, size_t length, size_t* dims) |
256 std::vector<const LLType*> types; | 293 std::vector<const LLType*> types; |
257 types.push_back(typeInfoTy); | 294 types.push_back(typeInfoTy); |
258 types.push_back(sizeTy); | 295 types.push_back(sizeTy); |
259 types.push_back(rt_ptr(sizeTy)); | 296 types.push_back(rt_ptr(sizeTy)); |
260 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | 297 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
261 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 298 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
262 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | 299 ->setAttributes(Attr_NoAlias_3_NoCapture); |
263 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); | 300 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M) |
301 ->setAttributes(Attr_NoAlias_3_NoCapture); | |
302 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M) | |
303 ->setAttributes(Attr_NoAlias_3_NoCapture); | |
264 } | 304 } |
265 | 305 |
266 // void* _d_arraysetlengthT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) | 306 // void* _d_arraysetlengthT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) |
267 // void* _d_arraysetlengthiT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) | 307 // void* _d_arraysetlengthiT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) |
268 { | 308 { |
272 types.push_back(typeInfoTy); | 312 types.push_back(typeInfoTy); |
273 types.push_back(sizeTy); | 313 types.push_back(sizeTy); |
274 types.push_back(sizeTy); | 314 types.push_back(sizeTy); |
275 types.push_back(voidPtrTy); | 315 types.push_back(voidPtrTy); |
276 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | 316 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
277 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 317 |
278 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | 318 // ReadOnly is not technically true, but close enough: It only writes |
319 // to memory the caller doesn't know about. | |
320 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) | |
321 ->setAttributes(Attr_NoAlias); | |
322 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M) | |
323 ->setAttributes(Attr_NoAlias); | |
279 } | 324 } |
280 | 325 |
281 // Object _d_allocclass(ClassInfo ci) | 326 // Object _d_allocclass(ClassInfo ci) |
282 { | 327 { |
283 std::string fname("_d_allocclass"); | 328 std::string fname("_d_allocclass"); |
284 std::vector<const LLType*> types; | 329 std::vector<const LLType*> types; |
285 types.push_back(classInfoTy); | 330 types.push_back(classInfoTy); |
286 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 331 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
287 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 332 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
333 ->setAttributes(Attr_NoAlias); | |
288 } | 334 } |
289 | 335 |
290 // void _d_delarray(size_t plength, void* pdata) | 336 // void _d_delarray(size_t plength, void* pdata) |
291 { | 337 { |
292 std::string fname("_d_delarray"); | 338 std::string fname("_d_delarray"); |
332 std::vector<const LLType*> types; \ | 378 std::vector<const LLType*> types; \ |
333 types.push_back(rt_ptr(TY)); \ | 379 types.push_back(rt_ptr(TY)); \ |
334 types.push_back(sizeTy); \ | 380 types.push_back(sizeTy); \ |
335 types.push_back(TY); \ | 381 types.push_back(TY); \ |
336 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); \ | 382 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); \ |
337 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); \ | 383 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) \ |
384 ->setAttributes(Attr_1_NoCapture); \ | |
338 } | 385 } |
339 | 386 |
340 ARRAY_INIT(boolTy,"i1") | 387 ARRAY_INIT(boolTy,"i1") |
341 ARRAY_INIT(byteTy,"i8") | 388 ARRAY_INIT(byteTy,"i8") |
342 ARRAY_INIT(shortTy,"i16") | 389 ARRAY_INIT(shortTy,"i16") |
360 types.push_back(voidPtrTy); | 407 types.push_back(voidPtrTy); |
361 types.push_back(sizeTy); | 408 types.push_back(sizeTy); |
362 types.push_back(voidPtrTy); | 409 types.push_back(voidPtrTy); |
363 types.push_back(sizeTy); | 410 types.push_back(sizeTy); |
364 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | 411 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
365 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 412 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
413 ->setAttributes(Attr_1_3_NoCapture); | |
366 } | 414 } |
367 | 415 |
368 ///////////////////////////////////////////////////////////////////////////////////// | 416 ///////////////////////////////////////////////////////////////////////////////////// |
369 ///////////////////////////////////////////////////////////////////////////////////// | 417 ///////////////////////////////////////////////////////////////////////////////////// |
370 ///////////////////////////////////////////////////////////////////////////////////// | 418 ///////////////////////////////////////////////////////////////////////////////////// |
446 std::vector<const LLType*> types; | 494 std::vector<const LLType*> types; |
447 types.push_back(sizeTy); | 495 types.push_back(sizeTy); |
448 types.push_back(sizeTy); | 496 types.push_back(sizeTy); |
449 types.push_back(sizeTy); | 497 types.push_back(sizeTy); |
450 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | 498 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); |
451 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 499 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
500 ->setAttributes(Attr_ReadNone); | |
452 } | 501 } |
453 | 502 |
454 ///////////////////////////////////////////////////////////////////////////////////// | 503 ///////////////////////////////////////////////////////////////////////////////////// |
455 ///////////////////////////////////////////////////////////////////////////////////// | 504 ///////////////////////////////////////////////////////////////////////////////////// |
456 ///////////////////////////////////////////////////////////////////////////////////// | 505 ///////////////////////////////////////////////////////////////////////////////////// |
460 { | 509 { |
461 std::string fname("_d_toObject"); | 510 std::string fname("_d_toObject"); |
462 std::vector<const LLType*> types; | 511 std::vector<const LLType*> types; |
463 types.push_back(voidPtrTy); | 512 types.push_back(voidPtrTy); |
464 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 513 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
465 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 514 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
515 ->setAttributes(Attr_ReadOnly); | |
466 } | 516 } |
467 | 517 |
468 // cast interface | 518 // cast interface |
469 // Object _d_interface_cast(void* p, ClassInfo c) | 519 // Object _d_interface_cast(void* p, ClassInfo c) |
470 { | 520 { |
471 std::string fname("_d_interface_cast"); | 521 std::string fname("_d_interface_cast"); |
472 std::vector<const LLType*> types; | 522 std::vector<const LLType*> types; |
473 types.push_back(voidPtrTy); | 523 types.push_back(voidPtrTy); |
474 types.push_back(classInfoTy); | 524 types.push_back(classInfoTy); |
475 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 525 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
476 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 526 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
527 ->setAttributes(Attr_ReadOnly); | |
477 } | 528 } |
478 | 529 |
479 // dynamic cast | 530 // dynamic cast |
480 // Object _d_dynamic_cast(Object o, ClassInfo c) | 531 // Object _d_dynamic_cast(Object o, ClassInfo c) |
481 { | 532 { |
482 std::string fname("_d_dynamic_cast"); | 533 std::string fname("_d_dynamic_cast"); |
483 std::vector<const LLType*> types; | 534 std::vector<const LLType*> types; |
484 types.push_back(objectTy); | 535 types.push_back(objectTy); |
485 types.push_back(classInfoTy); | 536 types.push_back(classInfoTy); |
486 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 537 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
487 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 538 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
539 ->setAttributes(Attr_ReadOnly); | |
488 } | 540 } |
489 | 541 |
490 ///////////////////////////////////////////////////////////////////////////////////// | 542 ///////////////////////////////////////////////////////////////////////////////////// |
491 ///////////////////////////////////////////////////////////////////////////////////// | 543 ///////////////////////////////////////////////////////////////////////////////////// |
492 ///////////////////////////////////////////////////////////////////////////////////// | 544 ///////////////////////////////////////////////////////////////////////////////////// |
530 std::string fname("_adDupT"); | 582 std::string fname("_adDupT"); |
531 std::vector<const LLType*> types; | 583 std::vector<const LLType*> types; |
532 types.push_back(typeInfoTy); | 584 types.push_back(typeInfoTy); |
533 types.push_back(rt_array(byteTy)); | 585 types.push_back(rt_array(byteTy)); |
534 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); | 586 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); |
535 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 587 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
588 ->setAttributes(Attr_NoAlias); | |
536 } | 589 } |
537 | 590 |
538 // int _adEq(void[] a1, void[] a2, TypeInfo ti) | 591 // int _adEq(void[] a1, void[] a2, TypeInfo ti) |
539 // int _adCmp(void[] a1, void[] a2, TypeInfo ti) | 592 // int _adCmp(void[] a1, void[] a2, TypeInfo ti) |
540 { | 593 { |
543 std::vector<const LLType*> types; | 596 std::vector<const LLType*> types; |
544 types.push_back(rt_array(byteTy)); | 597 types.push_back(rt_array(byteTy)); |
545 types.push_back(rt_array(byteTy)); | 598 types.push_back(rt_array(byteTy)); |
546 types.push_back(typeInfoTy); | 599 types.push_back(typeInfoTy); |
547 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 600 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
548 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 601 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
549 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | 602 ->setAttributes(Attr_ReadOnly); |
603 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M) | |
604 ->setAttributes(Attr_ReadOnly); | |
550 } | 605 } |
551 | 606 |
552 // int _adCmpChar(void[] a1, void[] a2) | 607 // int _adCmpChar(void[] a1, void[] a2) |
553 { | 608 { |
554 std::string fname("_adCmpChar"); | 609 std::string fname("_adCmpChar"); |
555 std::vector<const LLType*> types; | 610 std::vector<const LLType*> types; |
556 types.push_back(rt_array(byteTy)); | 611 types.push_back(rt_array(byteTy)); |
557 types.push_back(rt_array(byteTy)); | 612 types.push_back(rt_array(byteTy)); |
558 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 613 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
559 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 614 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
615 ->setAttributes(Attr_ReadOnly); | |
560 } | 616 } |
561 | 617 |
562 // void[] _adSort(void[] a, TypeInfo ti) | 618 // void[] _adSort(void[] a, TypeInfo ti) |
563 { | 619 { |
564 std::string fname("_adSort"); | 620 std::string fname("_adSort"); |
577 { | 633 { |
578 std::string fname("_aaLen"); | 634 std::string fname("_aaLen"); |
579 std::vector<const LLType*> types; | 635 std::vector<const LLType*> types; |
580 types.push_back(aaTy); | 636 types.push_back(aaTy); |
581 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); | 637 const llvm::FunctionType* fty = llvm::FunctionType::get(sizeTy, types, false); |
582 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 638 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
639 ->setAttributes(Attr_ReadOnly_1_NoCapture); | |
583 } | 640 } |
584 | 641 |
585 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) | 642 // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) |
586 { | 643 { |
587 std::string fname("_aaGet"); | 644 std::string fname("_aaGet"); |
589 types.push_back(aaTy); | 646 types.push_back(aaTy); |
590 types.push_back(typeInfoTy); | 647 types.push_back(typeInfoTy); |
591 types.push_back(sizeTy); | 648 types.push_back(sizeTy); |
592 types.push_back(voidPtrTy); | 649 types.push_back(voidPtrTy); |
593 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | 650 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
594 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 651 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
652 ->setAttributes(Attr_1_4_NoCapture); | |
595 } | 653 } |
596 | 654 |
597 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) | 655 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) |
598 { | 656 { |
599 std::string fname("_aaGetRvalue"); | 657 std::string fname("_aaGetRvalue"); |
601 types.push_back(aaTy); | 659 types.push_back(aaTy); |
602 types.push_back(typeInfoTy); | 660 types.push_back(typeInfoTy); |
603 types.push_back(sizeTy); | 661 types.push_back(sizeTy); |
604 types.push_back(voidPtrTy); | 662 types.push_back(voidPtrTy); |
605 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | 663 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
606 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 664 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
665 ->setAttributes(Attr_ReadOnly_1_4_NoCapture); | |
607 } | 666 } |
608 | 667 |
609 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) | 668 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) |
610 { | 669 { |
611 std::string fname("_aaIn"); | 670 std::string fname("_aaIn"); |
612 std::vector<const LLType*> types; | 671 std::vector<const LLType*> types; |
613 types.push_back(aaTy); | 672 types.push_back(aaTy); |
614 types.push_back(typeInfoTy); | 673 types.push_back(typeInfoTy); |
615 types.push_back(voidPtrTy); | 674 types.push_back(voidPtrTy); |
616 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | 675 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); |
617 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 676 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
677 ->setAttributes(Attr_ReadOnly_1_3_NoCapture); | |
618 } | 678 } |
619 | 679 |
620 // void _aaDel(AA aa, TypeInfo keyti, void* pkey) | 680 // void _aaDel(AA aa, TypeInfo keyti, void* pkey) |
621 { | 681 { |
622 std::string fname("_aaDel"); | 682 std::string fname("_aaDel"); |
623 std::vector<const LLType*> types; | 683 std::vector<const LLType*> types; |
624 types.push_back(aaTy); | 684 types.push_back(aaTy); |
625 types.push_back(typeInfoTy); | 685 types.push_back(typeInfoTy); |
626 types.push_back(voidPtrTy); | 686 types.push_back(voidPtrTy); |
627 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | 687 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
628 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 688 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
689 ->setAttributes(Attr_1_3_NoCapture); | |
629 } | 690 } |
630 | 691 |
631 // void[] _aaValues(AA aa, size_t keysize, size_t valuesize) | 692 // void[] _aaValues(AA aa, size_t keysize, size_t valuesize) |
632 { | 693 { |
633 std::string fname("_aaValues"); | 694 std::string fname("_aaValues"); |
634 std::vector<const LLType*> types; | 695 std::vector<const LLType*> types; |
635 types.push_back(aaTy); | 696 types.push_back(aaTy); |
636 types.push_back(sizeTy); | 697 types.push_back(sizeTy); |
637 types.push_back(sizeTy); | 698 types.push_back(sizeTy); |
638 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); | 699 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); |
639 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 700 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
701 ->setAttributes(Attr_NoAlias_1_NoCapture); | |
640 } | 702 } |
641 | 703 |
642 // void* _aaRehash(AA* paa, TypeInfo keyti) | 704 // void* _aaRehash(AA* paa, TypeInfo keyti) |
643 { | 705 { |
644 std::string fname("_aaRehash"); | 706 std::string fname("_aaRehash"); |
654 std::string fname("_aaKeys"); | 716 std::string fname("_aaKeys"); |
655 std::vector<const LLType*> types; | 717 std::vector<const LLType*> types; |
656 types.push_back(aaTy); | 718 types.push_back(aaTy); |
657 types.push_back(sizeTy); | 719 types.push_back(sizeTy); |
658 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); | 720 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); |
659 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 721 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
722 ->setAttributes(Attr_NoAlias_1_NoCapture); | |
660 } | 723 } |
661 | 724 |
662 // int _aaApply(AA aa, size_t keysize, dg_t dg) | 725 // int _aaApply(AA aa, size_t keysize, dg_t dg) |
663 { | 726 { |
664 std::string fname("_aaApply"); | 727 std::string fname("_aaApply"); |
665 std::vector<const LLType*> types; | 728 std::vector<const LLType*> types; |
666 types.push_back(aaTy); | 729 types.push_back(aaTy); |
667 types.push_back(sizeTy); | 730 types.push_back(sizeTy); |
668 types.push_back(rt_dg1()); | 731 types.push_back(rt_dg1()); |
669 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 732 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
670 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 733 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
734 ->setAttributes(Attr_1_NoCapture); | |
671 } | 735 } |
672 | 736 |
673 // int _aaApply2(AA aa, size_t keysize, dg2_t dg) | 737 // int _aaApply2(AA aa, size_t keysize, dg2_t dg) |
674 { | 738 { |
675 std::string fname("_aaApply2"); | 739 std::string fname("_aaApply2"); |
676 std::vector<const LLType*> types; | 740 std::vector<const LLType*> types; |
677 types.push_back(aaTy); | 741 types.push_back(aaTy); |
678 types.push_back(sizeTy); | 742 types.push_back(sizeTy); |
679 types.push_back(rt_dg2()); | 743 types.push_back(rt_dg2()); |
680 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 744 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
681 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 745 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
746 ->setAttributes(Attr_1_NoCapture); | |
682 } | 747 } |
683 | 748 |
684 ///////////////////////////////////////////////////////////////////////////////////// | 749 ///////////////////////////////////////////////////////////////////////////////////// |
685 ///////////////////////////////////////////////////////////////////////////////////// | 750 ///////////////////////////////////////////////////////////////////////////////////// |
686 ///////////////////////////////////////////////////////////////////////////////////// | 751 ///////////////////////////////////////////////////////////////////////////////////// |
697 } | 762 } |
698 | 763 |
699 ///////////////////////////////////////////////////////////////////////////////////// | 764 ///////////////////////////////////////////////////////////////////////////////////// |
700 ///////////////////////////////////////////////////////////////////////////////////// | 765 ///////////////////////////////////////////////////////////////////////////////////// |
701 ///////////////////////////////////////////////////////////////////////////////////// | 766 ///////////////////////////////////////////////////////////////////////////////////// |
702 | |
703 // Object _d_toObject(void* p) | |
704 { | |
705 std::string fname("_d_toObject"); | |
706 std::vector<const LLType*> types; | |
707 types.push_back(voidPtrTy); | |
708 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
709 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
710 } | |
711 | 767 |
712 // Object _d_dynamic_cast(Object o, ClassInfo c) | 768 // Object _d_dynamic_cast(Object o, ClassInfo c) |
713 { | 769 { |
714 std::string fname("_d_dynamic_cast"); | 770 std::string fname("_d_dynamic_cast"); |
715 std::vector<const LLType*> types; | 771 std::vector<const LLType*> types; |
716 types.push_back(objectTy); | 772 types.push_back(objectTy); |
717 types.push_back(classInfoTy); | 773 types.push_back(classInfoTy); |
718 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 774 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
719 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 775 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
776 ->setAttributes(Attr_ReadOnly); | |
720 } | 777 } |
721 | 778 |
722 // Object _d_interface_cast(void* p, ClassInfo c) | 779 // Object _d_interface_cast(void* p, ClassInfo c) |
723 { | 780 { |
724 std::string fname("_d_interface_cast"); | 781 std::string fname("_d_interface_cast"); |
725 std::vector<const LLType*> types; | 782 std::vector<const LLType*> types; |
726 types.push_back(voidPtrTy); | 783 types.push_back(voidPtrTy); |
727 types.push_back(classInfoTy); | 784 types.push_back(classInfoTy); |
728 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | 785 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); |
729 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 786 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
787 ->setAttributes(Attr_ReadOnly); | |
730 } | 788 } |
731 | 789 |
732 ///////////////////////////////////////////////////////////////////////////////////// | 790 ///////////////////////////////////////////////////////////////////////////////////// |
733 ///////////////////////////////////////////////////////////////////////////////////// | 791 ///////////////////////////////////////////////////////////////////////////////////// |
734 ///////////////////////////////////////////////////////////////////////////////////// | 792 ///////////////////////////////////////////////////////////////////////////////////// |
751 std::string fname("_d_switch_string"); | 809 std::string fname("_d_switch_string"); |
752 std::vector<const LLType*> types; | 810 std::vector<const LLType*> types; |
753 types.push_back(rt_array(stringTy)); | 811 types.push_back(rt_array(stringTy)); |
754 types.push_back(stringTy); | 812 types.push_back(stringTy); |
755 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 813 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
756 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 814 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
815 ->setAttributes(Attr_ReadOnly); | |
757 } | 816 } |
758 | 817 |
759 // int _d_switch_ustring(wchar[][] table, wchar[] ca) | 818 // int _d_switch_ustring(wchar[][] table, wchar[] ca) |
760 { | 819 { |
761 std::string fname("_d_switch_ustring"); | 820 std::string fname("_d_switch_ustring"); |
762 std::vector<const LLType*> types; | 821 std::vector<const LLType*> types; |
763 types.push_back(rt_array(wstringTy)); | 822 types.push_back(rt_array(wstringTy)); |
764 types.push_back(wstringTy); | 823 types.push_back(wstringTy); |
765 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 824 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
766 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 825 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
826 ->setAttributes(Attr_ReadOnly); | |
767 } | 827 } |
768 | 828 |
769 // int _d_switch_dstring(dchar[][] table, dchar[] ca) | 829 // int _d_switch_dstring(dchar[][] table, dchar[] ca) |
770 { | 830 { |
771 std::string fname("_d_switch_dstring"); | 831 std::string fname("_d_switch_dstring"); |
772 std::vector<const LLType*> types; | 832 std::vector<const LLType*> types; |
773 types.push_back(rt_array(dstringTy)); | 833 types.push_back(rt_array(dstringTy)); |
774 types.push_back(dstringTy); | 834 types.push_back(dstringTy); |
775 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); | 835 const llvm::FunctionType* fty = llvm::FunctionType::get(intTy, types, false); |
776 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 836 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
837 ->setAttributes(Attr_ReadOnly); | |
777 } | 838 } |
778 | 839 |
779 ///////////////////////////////////////////////////////////////////////////////////// | 840 ///////////////////////////////////////////////////////////////////////////////////// |
780 ///////////////////////////////////////////////////////////////////////////////////// | 841 ///////////////////////////////////////////////////////////////////////////////////// |
781 ///////////////////////////////////////////////////////////////////////////////////// | 842 ///////////////////////////////////////////////////////////////////////////////////// |
798 std::string fname("_d_monitorenter"); | 859 std::string fname("_d_monitorenter"); |
799 std::string fname2("_d_monitorexit"); | 860 std::string fname2("_d_monitorexit"); |
800 std::vector<const LLType*> types; | 861 std::vector<const LLType*> types; |
801 types.push_back(objectTy); | 862 types.push_back(objectTy); |
802 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | 863 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
803 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 864 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) |
804 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | 865 ->setAttributes(Attr_1_NoCapture); |
866 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M) | |
867 ->setAttributes(Attr_1_NoCapture); | |
805 } | 868 } |
806 | 869 |
807 ///////////////////////////////////////////////////////////////////////////////////// | 870 ///////////////////////////////////////////////////////////////////////////////////// |
808 ///////////////////////////////////////////////////////////////////////////////////// | 871 ///////////////////////////////////////////////////////////////////////////////////// |
809 ///////////////////////////////////////////////////////////////////////////////////// | 872 ///////////////////////////////////////////////////////////////////////////////////// |