Mercurial > projects > ldc
comparison gen/statements.cpp @ 1545:7fcb72d518f6
More factory methods moved to LLVMContext
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Wed, 15 Jul 2009 18:09:41 +0200 |
parents | 61f12f4651b5 |
children | 327eef051d50 |
comparison
equal
deleted
inserted
replaced
1544:8863cf7236e6 | 1545:7fcb72d518f6 |
---|---|
1030 LLValue* keyvar; | 1030 LLValue* keyvar; |
1031 if (key) | 1031 if (key) |
1032 keyvar = DtoRawVarDeclaration(key); | 1032 keyvar = DtoRawVarDeclaration(key); |
1033 else | 1033 else |
1034 keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align? | 1034 keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align? |
1035 LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false); | 1035 LLValue* zerokey = gIR->context().getConstantInt(keytype,0,false); |
1036 | 1036 |
1037 // value | 1037 // value |
1038 Logger::println("value = %s", value->toPrettyChars()); | 1038 Logger::println("value = %s", value->toPrettyChars()); |
1039 LLValue* valvar = NULL; | 1039 LLValue* valvar = NULL; |
1040 if (!value->isRef() && !value->isOut()) { | 1040 if (!value->isRef() && !value->isOut()) { |
1087 if (op == TOKforeach) { | 1087 if (op == TOKforeach) { |
1088 done = p->ir->CreateICmpULT(load, niters, "tmp"); | 1088 done = p->ir->CreateICmpULT(load, niters, "tmp"); |
1089 } | 1089 } |
1090 else if (op == TOKforeach_reverse) { | 1090 else if (op == TOKforeach_reverse) { |
1091 done = p->ir->CreateICmpUGT(load, zerokey, "tmp"); | 1091 done = p->ir->CreateICmpUGT(load, zerokey, "tmp"); |
1092 load = p->ir->CreateSub(load, llvm::ConstantInt::get(keytype, 1, false), "tmp"); | 1092 load = p->ir->CreateSub(load, gIR->context().getConstantInt(keytype, 1, false), "tmp"); |
1093 DtoStore(load, keyvar); | 1093 DtoStore(load, keyvar); |
1094 } | 1094 } |
1095 llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb()); | 1095 llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb()); |
1096 | 1096 |
1097 // init body | 1097 // init body |
1098 p->scope() = IRScope(bodybb,nextbb); | 1098 p->scope() = IRScope(bodybb,nextbb); |
1099 | 1099 |
1100 // get value for this iteration | 1100 // get value for this iteration |
1101 LLConstant* zero = llvm::ConstantInt::get(keytype,0,false); | 1101 LLConstant* zero = gIR->context().getConstantInt(keytype,0,false); |
1102 LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); | 1102 LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); |
1103 LLValue* gep = DtoGEP1(val,loadedKey); | 1103 LLValue* gep = DtoGEP1(val,loadedKey); |
1104 | 1104 |
1105 if (!value->isRef() && !value->isOut()) { | 1105 if (!value->isRef() && !value->isOut()) { |
1106 // Copy value to local variable, and use it as the value variable. | 1106 // Copy value to local variable, and use it as the value variable. |
1124 | 1124 |
1125 // next | 1125 // next |
1126 p->scope() = IRScope(nextbb,endbb); | 1126 p->scope() = IRScope(nextbb,endbb); |
1127 if (op == TOKforeach) { | 1127 if (op == TOKforeach) { |
1128 LLValue* load = DtoLoad(keyvar); | 1128 LLValue* load = DtoLoad(keyvar); |
1129 load = p->ir->CreateAdd(load, llvm::ConstantInt::get(keytype, 1, false), "tmp"); | 1129 load = p->ir->CreateAdd(load, gIR->context().getConstantInt(keytype, 1, false), "tmp"); |
1130 DtoStore(load, keyvar); | 1130 DtoStore(load, keyvar); |
1131 } | 1131 } |
1132 llvm::BranchInst::Create(condbb, p->scopebb()); | 1132 llvm::BranchInst::Create(condbb, p->scopebb()); |
1133 | 1133 |
1134 // end | 1134 // end |