comparison gen/toir.c @ 26:99737f94abfb trunk

[svn r30] * Fixed static function-local variables. * Fixed CondExp - bool ? true : false
author lindquist
date Thu, 04 Oct 2007 10:57:26 +0200
parents 12fd8ce55d9c
children 92408a3a2bac
comparison
equal deleted inserted replaced
25:12fd8ce55d9c 26:99737f94abfb
44 // variable declaration 44 // variable declaration
45 if (VarDeclaration* vd = declaration->isVarDeclaration()) 45 if (VarDeclaration* vd = declaration->isVarDeclaration())
46 { 46 {
47 Logger::println("VarDeclaration"); 47 Logger::println("VarDeclaration");
48 48
49 // handle const 49 if (vd->isDataseg())
50 // TODO probably not correct 50 {
51 bool isconst = (vd->storage_class & STCconst) != 0; 51 vd->toObjFile();
52 52 }
53 // allocate storage on the stack 53 else
54 Logger::println("vdtype = %s", vd->type->toChars()); 54 {
55 const llvm::Type* lltype = LLVM_DtoType(vd->type); 55 // allocate storage on the stack
56 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); 56 Logger::println("vdtype = %s", vd->type->toChars());
57 //allocainst->setAlignment(vd->type->alignsize()); // TODO 57 const llvm::Type* lltype = LLVM_DtoType(vd->type);
58 vd->llvmValue = allocainst; 58 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint());
59 // e->val = really needed?? 59 //allocainst->setAlignment(vd->type->alignsize()); // TODO
60 60 vd->llvmValue = allocainst;
61 LLVM_DtoInitializer(vd->type, vd->init); 61 // e->val = really needed??
62
63 LLVM_DtoInitializer(vd->type, vd->init);
64 }
62 } 65 }
63 // struct declaration 66 // struct declaration
64 else if (StructDeclaration* s = declaration->isStructDeclaration()) 67 else if (StructDeclaration* s = declaration->isStructDeclaration())
65 { 68 {
66 Logger::println("StructDeclaration"); 69 Logger::println("StructDeclaration");
2207 delete c; 2210 delete c;
2208 new llvm::BranchInst(condtrue,condfalse,cond_val,p->scopebb()); 2211 new llvm::BranchInst(condtrue,condfalse,cond_val,p->scopebb());
2209 2212
2210 p->scope() = IRScope(condtrue, condfalse); 2213 p->scope() = IRScope(condtrue, condfalse);
2211 elem* u = e1->toElem(p); 2214 elem* u = e1->toElem(p);
2212 Logger::cout() << *u->val << '|' << *resval << '\n'; \
2213 new llvm::StoreInst(u->getValue(),resval,p->scopebb()); 2215 new llvm::StoreInst(u->getValue(),resval,p->scopebb());
2214 new llvm::BranchInst(condend,p->scopebb()); 2216 new llvm::BranchInst(condend,p->scopebb());
2215 delete u; 2217 delete u;
2216 2218
2217 p->scope() = IRScope(condfalse, condend); 2219 p->scope() = IRScope(condfalse, condend);