comparison gen/runtime.cpp @ 1418:f5f8c21ce6ef

Make "`aa[key]`" use the same runtime call as "`key in aa`". The runtime calls these were using were different, but with equivalent definitions. With `ldc -O3`, the following functions now all compile to the exact same code: {{{ int[int] y; void foo(int x) { if (x in y) { auto z = x in y; sink(*z); } } void bar(int x) { if (x in y) { sink(y[x]); } } void baz(int x) { if (auto p = x in y) { sink(*p); } } }}}
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 25 May 2009 12:50:40 +0200
parents 551b01341728
children 9344fecd24f0
comparison
equal deleted inserted replaced
1417:c3c23d2c5407 1418:f5f8c21ce6ef
657 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); 657 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
658 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) 658 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)
659 ->setAttributes(Attr_1_4_NoCapture); 659 ->setAttributes(Attr_1_4_NoCapture);
660 } 660 }
661 661
662 // void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey)
663 {
664 std::string fname("_aaGetRvalue");
665 std::vector<const LLType*> types;
666 types.push_back(aaTy);
667 types.push_back(typeInfoTy);
668 types.push_back(sizeTy);
669 types.push_back(voidPtrTy);
670 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false);
671 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M)
672 ->setAttributes(Attr_ReadOnly_1_4_NoCapture);
673 }
674
675 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) 662 // void* _aaIn(AA aa, TypeInfo keyti, void* pkey)
676 { 663 {
677 std::string fname("_aaIn"); 664 std::string fname("_aaIn");
678 std::vector<const LLType*> types; 665 std::vector<const LLType*> types;
679 types.push_back(aaTy); 666 types.push_back(aaTy);