Mercurial > projects > ldc
comparison gen/toir.cpp @ 212:4c2689d57ba4 trunk
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
Fixed: the tango/lib/compiler/llvmdc/llvmdc.mak makefile was a bit incorrect.
Changed: the basic gc is now the default.
Changed: renamed a few temporary names in the LLVM IR output.
author | lindquist |
---|---|
date | Tue, 27 May 2008 22:14:24 +0200 |
parents | 1d6cfdbc97f0 |
children | 7816aafeea3c |
comparison
equal
deleted
inserted
replaced
211:f66219e0d530 | 212:4c2689d57ba4 |
---|---|
442 else | 442 else |
443 assert(0); | 443 assert(0); |
444 | 444 |
445 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; | 445 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; |
446 Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n'; | 446 Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n'; |
447 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,"stringliteral",gIR->module); | 447 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,".stringliteral",gIR->module); |
448 | 448 |
449 llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); | 449 llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
450 llvm::Constant* idxs[2] = { zero, zero }; | 450 llvm::Constant* idxs[2] = { zero, zero }; |
451 llvm::Constant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); | 451 llvm::Constant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
452 | 452 |
532 { | 532 { |
533 return _init; | 533 return _init; |
534 } | 534 } |
535 | 535 |
536 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; | 536 llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; |
537 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_init->getType(),true,_linkage,_init,"stringliteral",gIR->module); | 537 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_init->getType(),true,_linkage,_init,".stringliteral",gIR->module); |
538 | 538 |
539 llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); | 539 llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
540 llvm::Constant* idxs[2] = { zero, zero }; | 540 llvm::Constant* idxs[2] = { zero, zero }; |
541 llvm::Constant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); | 541 llvm::Constant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
542 | 542 |
1977 // new basic type | 1977 // new basic type |
1978 else | 1978 else |
1979 { | 1979 { |
1980 // allocate | 1980 // allocate |
1981 llvm::Value* mem = DtoNew(newtype); | 1981 llvm::Value* mem = DtoNew(newtype); |
1982 // BUG: default initialize | 1982 DVarValue tmpvar(newtype, mem, true); |
1983 // return | 1983 |
1984 // default initialize | |
1985 Expression* exp = newtype->defaultInit(loc); | |
1986 DValue* iv = exp->toElem(gIR); | |
1987 DtoAssign(&tmpvar, iv); | |
1988 | |
1989 // return as pointer-to | |
1984 return new DImValue(type, mem, false); | 1990 return new DImValue(type, mem, false); |
1985 } | 1991 } |
1986 | 1992 |
1987 assert(0); | 1993 assert(0); |
1988 } | 1994 } |
2080 DValue* cond = e1->toElem(p); | 2086 DValue* cond = e1->toElem(p); |
2081 | 2087 |
2082 // create basic blocks | 2088 // create basic blocks |
2083 llvm::BasicBlock* oldend = p->scopeend(); | 2089 llvm::BasicBlock* oldend = p->scopeend(); |
2084 llvm::BasicBlock* assertbb = llvm::BasicBlock::Create("assert", p->topfunc(), oldend); | 2090 llvm::BasicBlock* assertbb = llvm::BasicBlock::Create("assert", p->topfunc(), oldend); |
2085 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endassert", p->topfunc(), oldend); | 2091 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("noassert", p->topfunc(), oldend); |
2086 | 2092 |
2087 // test condition | 2093 // test condition |
2088 llvm::Value* condval = cond->getRVal(); | 2094 llvm::Value* condval = cond->getRVal(); |
2089 condval = DtoBoolean(condval); | 2095 condval = DtoBoolean(condval); |
2090 | 2096 |