comparison gen/statements.cpp @ 173:db9890b3fb64 trunk

[svn r189] moving IR data back into DMD frontend nodes
author ChristianK
date Tue, 06 May 2008 07:56:03 +0200
parents a8cd9bc1021a
children c44e6a711885
comparison
equal deleted inserted replaced
172:68a7dd38c03c 173:db9890b3fb64
75 if (exp) 75 if (exp)
76 { 76 {
77 if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) { 77 if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) {
78 IrFunction* f = p->func(); 78 IrFunction* f = p->func();
79 assert(f->type->llvmRetInPtr); 79 assert(f->type->llvmRetInPtr);
80 assert(gIR->irDsymbol[f->decl].irFunc->retArg); 80 assert(f->decl->ir.irFunc->retArg);
81 81
82 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); 82 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
83 83
84 DValue* rvar = new DVarValue(f->type->next, gIR->irDsymbol[f->decl].irFunc->retArg, true); 84 DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg, true);
85 85
86 p->exps.push_back(IRExp(NULL,exp,rvar)); 86 p->exps.push_back(IRExp(NULL,exp,rvar));
87 DValue* e = exp->toElem(p); 87 DValue* e = exp->toElem(p);
88 p->exps.pop_back(); 88 p->exps.pop_back();
89 89
154 LOG_SCOPE; 154 LOG_SCOPE;
155 155
156 if (match) 156 if (match)
157 { 157 {
158 llvm::Value* allocainst = new llvm::AllocaInst(DtoType(match->type), "._tmp_if_var", p->topallocapoint()); 158 llvm::Value* allocainst = new llvm::AllocaInst(DtoType(match->type), "._tmp_if_var", p->topallocapoint());
159 gIR->irDsymbol[match].irLocal = new IrLocal(match); 159 match->ir.irLocal = new IrLocal(match);
160 gIR->irDsymbol[match].irLocal->value = allocainst; 160 match->ir.irLocal->value = allocainst;
161 } 161 }
162 162
163 DValue* cond_e = condition->toElem(p); 163 DValue* cond_e = condition->toElem(p);
164 llvm::Value* cond_val = cond_e->getRVal(); 164 llvm::Value* cond_val = cond_e->getRVal();
165 delete cond_e; 165 delete cond_e;
806 const llvm::Type* keytype = key ? DtoType(key->type) : DtoSize_t(); 806 const llvm::Type* keytype = key ? DtoType(key->type) : DtoSize_t();
807 llvm::Value* keyvar = new llvm::AllocaInst(keytype, "foreachkey", p->topallocapoint()); 807 llvm::Value* keyvar = new llvm::AllocaInst(keytype, "foreachkey", p->topallocapoint());
808 if (key) 808 if (key)
809 { 809 {
810 //key->llvmValue = keyvar; 810 //key->llvmValue = keyvar;
811 assert(!gIR->irDsymbol[key].irLocal); 811 assert(!key->ir.irLocal);
812 gIR->irDsymbol[key].irLocal = new IrLocal(key); 812 key->ir.irLocal = new IrLocal(key);
813 gIR->irDsymbol[key].irLocal->value = keyvar; 813 key->ir.irLocal->value = keyvar;
814 } 814 }
815 llvm::Value* zerokey = llvm::ConstantInt::get(keytype,0,false); 815 llvm::Value* zerokey = llvm::ConstantInt::get(keytype,0,false);
816 816
817 // value 817 // value
818 const llvm::Type* valtype = DtoType(value->type); 818 const llvm::Type* valtype = DtoType(value->type);
819 llvm::Value* valvar = NULL; 819 llvm::Value* valvar = NULL;
820 if (!value->isRef() && !value->isOut()) 820 if (!value->isRef() && !value->isOut())
821 valvar = new llvm::AllocaInst(valtype, "foreachval", p->topallocapoint()); 821 valvar = new llvm::AllocaInst(valtype, "foreachval", p->topallocapoint());
822 assert(!gIR->irDsymbol[value].irLocal); 822 assert(!value->ir.irLocal);
823 gIR->irDsymbol[value].irLocal = new IrLocal(value); 823 value->ir.irLocal = new IrLocal(value);
824 824
825 // what to iterate 825 // what to iterate
826 DValue* aggrval = aggr->toElem(p); 826 DValue* aggrval = aggr->toElem(p);
827 Type* aggrtype = DtoDType(aggr->type); 827 Type* aggrtype = DtoDType(aggr->type);
828 828
914 914
915 // get value for this iteration 915 // get value for this iteration
916 llvm::Constant* zero = llvm::ConstantInt::get(keytype,0,false); 916 llvm::Constant* zero = llvm::ConstantInt::get(keytype,0,false);
917 llvm::Value* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); 917 llvm::Value* loadedKey = p->ir->CreateLoad(keyvar,"tmp");
918 if (aggrtype->ty == Tsarray) 918 if (aggrtype->ty == Tsarray)
919 gIR->irDsymbol[value].irLocal->value = DtoGEP(val,zero,loadedKey,"tmp"); 919 value->ir.irLocal->value = DtoGEP(val,zero,loadedKey,"tmp");
920 else if (aggrtype->ty == Tarray) 920 else if (aggrtype->ty == Tarray)
921 gIR->irDsymbol[value].irLocal->value = new llvm::GetElementPtrInst(val,loadedKey,"tmp",p->scopebb()); 921 value->ir.irLocal->value = new llvm::GetElementPtrInst(val,loadedKey,"tmp",p->scopebb());
922 922
923 if (!value->isRef() && !value->isOut()) { 923 if (!value->isRef() && !value->isOut()) {
924 DValue* dst = new DVarValue(value->type, valvar, true); 924 DValue* dst = new DVarValue(value->type, valvar, true);
925 DValue* src = new DVarValue(value->type, gIR->irDsymbol[value].irLocal->value, true); 925 DValue* src = new DVarValue(value->type, value->ir.irLocal->value, true);
926 DtoAssign(dst, src); 926 DtoAssign(dst, src);
927 gIR->irDsymbol[value].irLocal->value = valvar; 927 value->ir.irLocal->value = valvar;
928 } 928 }
929 929
930 // emit body 930 // emit body
931 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,nextbb,endbb)); 931 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,nextbb,endbb));
932 body->toIR(p); 932 body->toIR(p);
1051 1051
1052 assert(exp); 1052 assert(exp);
1053 assert(body); 1053 assert(body);
1054 1054
1055 DValue* e = exp->toElem(p); 1055 DValue* e = exp->toElem(p);
1056 gIR->irDsymbol[wthis].irLocal->value = e->getRVal(); 1056 wthis->ir.irLocal->value = e->getRVal();
1057 delete e; 1057 delete e;
1058 1058
1059 body->toIR(p); 1059 body->toIR(p);
1060 } 1060 }
1061 1061