Mercurial > projects > ldc
comparison gen/toir.cpp @ 1350:15e9762bb620
Adds explicit alignment information for alloca instructions in general, there's a few cases that still needs to be looked at but this should catch the majority. Fixes ticket #293 .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Thu, 14 May 2009 13:26:40 +0200 |
parents | a41a40deff73 |
children | 8d501abecd24 |
comparison
equal
deleted
inserted
replaced
1349:a376776e2301 | 1350:15e9762bb620 |
---|---|
907 lval = v->getLVal(); | 907 lval = v->getLVal(); |
908 else | 908 else |
909 { | 909 { |
910 assert(v->isSlice()); | 910 assert(v->isSlice()); |
911 LLValue* rval = v->getRVal(); | 911 LLValue* rval = v->getRVal(); |
912 lval = DtoAlloca(rval->getType(), ".tmp_slice_storage"); | 912 lval = DtoRawAlloca(rval->getType(), 0, ".tmp_slice_storage"); |
913 DtoStore(rval, lval); | 913 DtoStore(rval, lval); |
914 } | 914 } |
915 | 915 |
916 if (Logger::enabled()) | 916 if (Logger::enabled()) |
917 Logger::cout() << "lval: " << *lval << '\n'; | 917 Logger::cout() << "lval: " << *lval << '\n'; |
2122 { | 2122 { |
2123 Logger::print("CondExp::toElem: %s @ %s\n", toChars(), type->toChars()); | 2123 Logger::print("CondExp::toElem: %s @ %s\n", toChars(), type->toChars()); |
2124 LOG_SCOPE; | 2124 LOG_SCOPE; |
2125 | 2125 |
2126 Type* dtype = type->toBasetype(); | 2126 Type* dtype = type->toBasetype(); |
2127 const LLType* resty = DtoType(dtype); | |
2128 | 2127 |
2129 DValue* dvv; | 2128 DValue* dvv; |
2130 // voids returns will need no storage | 2129 // voids returns will need no storage |
2131 if (dtype->ty != Tvoid) { | 2130 if (dtype->ty != Tvoid) { |
2132 // allocate a temporary for the final result. failed to come up with a better way :/ | 2131 // allocate a temporary for the final result. failed to come up with a better way :/ |
2133 LLValue* resval = DtoAlloca(resty,"condtmp"); | 2132 LLValue* resval = DtoAlloca(dtype,"condtmp"); |
2134 dvv = new DVarValue(type, resval); | 2133 dvv = new DVarValue(type, resval); |
2135 } else { | 2134 } else { |
2136 dvv = new DConstValue(type, getNullValue(DtoTypeNotVoid(dtype))); | 2135 dvv = new DConstValue(type, getNullValue(DtoTypeNotVoid(dtype))); |
2137 } | 2136 } |
2138 | 2137 |
2343 { | 2342 { |
2344 dynSlice = DtoNewDynArray(loc, arrayType, new DConstValue(Type::tsize_t, DtoConstSize_t(len)), false); | 2343 dynSlice = DtoNewDynArray(loc, arrayType, new DConstValue(Type::tsize_t, DtoConstSize_t(len)), false); |
2345 dstMem = dynSlice->ptr; | 2344 dstMem = dynSlice->ptr; |
2346 } | 2345 } |
2347 else | 2346 else |
2348 dstMem = DtoAlloca(llStoType, "arrayliteral"); | 2347 dstMem = DtoRawAlloca(llStoType, 0, "arrayliteral"); |
2349 | 2348 |
2350 // store elements | 2349 // store elements |
2351 for (size_t i=0; i<len; ++i) | 2350 for (size_t i=0; i<len; ++i) |
2352 { | 2351 { |
2353 Expression* expr = (Expression*)elements->data[i]; | 2352 Expression* expr = (Expression*)elements->data[i]; |
2507 } | 2506 } |
2508 | 2507 |
2509 const LLType* st = llvm::StructType::get(valuetypes, packed); | 2508 const LLType* st = llvm::StructType::get(valuetypes, packed); |
2510 | 2509 |
2511 // alloca a stack slot | 2510 // alloca a stack slot |
2512 LLValue* mem = DtoAlloca(st, ".structliteral"); | 2511 LLValue* mem = DtoRawAlloca(st, 0, ".structliteral"); |
2513 | 2512 |
2514 // fill in values | 2513 // fill in values |
2515 for (size_t i = 0; i < n; i++) | 2514 for (size_t i = 0; i < n; i++) |
2516 { | 2515 { |
2517 LLValue* addr = DtoGEPi(mem, 0, i); | 2516 LLValue* addr = DtoGEPi(mem, 0, i); |
2594 assert(values); | 2593 assert(values); |
2595 assert(keys->dim == values->dim); | 2594 assert(keys->dim == values->dim); |
2596 | 2595 |
2597 Type* aatype = type->toBasetype(); | 2596 Type* aatype = type->toBasetype(); |
2598 Type* vtype = aatype->nextOf(); | 2597 Type* vtype = aatype->nextOf(); |
2599 const LLType* aalltype = DtoType(type); | |
2600 | 2598 |
2601 // it should be possible to avoid the temporary in some cases | 2599 // it should be possible to avoid the temporary in some cases |
2602 LLValue* tmp = DtoAlloca(aalltype,"aaliteral"); | 2600 LLValue* tmp = DtoAlloca(type,"aaliteral"); |
2603 DValue* aa = new DVarValue(type, tmp); | 2601 DValue* aa = new DVarValue(type, tmp); |
2604 DtoStore(LLConstant::getNullValue(aalltype), tmp); | 2602 DtoStore(LLConstant::getNullValue(DtoType(type)), tmp); |
2605 | 2603 |
2606 const size_t n = keys->dim; | 2604 const size_t n = keys->dim; |
2607 for (size_t i=0; i<n; ++i) | 2605 for (size_t i=0; i<n; ++i) |
2608 { | 2606 { |
2609 Expression* ekey = (Expression*)keys->data[i]; | 2607 Expression* ekey = (Expression*)keys->data[i]; |