Mercurial > projects > ldc
comparison gen/arrays.cpp @ 1571:8d086d552909
IntegerType is now contextifed.
Requires llvm >= 78969. resistor says this will be the last context API change :)
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Fri, 14 Aug 2009 00:39:18 +0200 |
parents | 755abafbf25d |
children | 5c0cebff9be8 |
comparison
equal
deleted
inserted
replaced
1570:ab03cfb3a212 | 1571:8d086d552909 |
---|---|
22 | 22 |
23 const LLStructType* DtoArrayType(Type* arrayTy) | 23 const LLStructType* DtoArrayType(Type* arrayTy) |
24 { | 24 { |
25 assert(arrayTy->nextOf()); | 25 assert(arrayTy->nextOf()); |
26 const LLType* elemty = DtoType(arrayTy->nextOf()); | 26 const LLType* elemty = DtoType(arrayTy->nextOf()); |
27 if (elemty == LLType::VoidTy) | 27 if (elemty == LLType::getVoidTy(gIR->context())) |
28 elemty = LLType::Int8Ty; | 28 elemty = LLType::getInt8Ty(gIR->context()); |
29 return LLStructType::get(gIR->context(), DtoSize_t(), getPtrToType(elemty), NULL); | 29 return LLStructType::get(gIR->context(), DtoSize_t(), getPtrToType(elemty), NULL); |
30 } | 30 } |
31 | 31 |
32 const LLStructType* DtoArrayType(const LLType* t) | 32 const LLStructType* DtoArrayType(const LLType* t) |
33 { | 33 { |
42 assert(t->ty == Tsarray); | 42 assert(t->ty == Tsarray); |
43 TypeSArray* tsa = (TypeSArray*)t; | 43 TypeSArray* tsa = (TypeSArray*)t; |
44 Type* tnext = tsa->nextOf(); | 44 Type* tnext = tsa->nextOf(); |
45 | 45 |
46 const LLType* elemty = DtoType(tnext); | 46 const LLType* elemty = DtoType(tnext); |
47 if (elemty == LLType::VoidTy) | 47 if (elemty == LLType::getVoidTy(gIR->context())) |
48 elemty = LLType::Int8Ty; | 48 elemty = LLType::getInt8Ty(gIR->context()); |
49 | 49 |
50 return LLArrayType::get(elemty, tsa->dim->toUInteger()); | 50 return LLArrayType::get(elemty, tsa->dim->toUInteger()); |
51 } | 51 } |
52 | 52 |
53 ////////////////////////////////////////////////////////////////////////////////////////// | 53 ////////////////////////////////////////////////////////////////////////////////////////// |
110 | 110 |
111 // if not a zero initializer, call the appropriate runtime function! | 111 // if not a zero initializer, call the appropriate runtime function! |
112 switch (arrayelemty->ty) | 112 switch (arrayelemty->ty) |
113 { | 113 { |
114 case Tbool: | 114 case Tbool: |
115 val = gIR->ir->CreateZExt(val, LLType::Int8Ty, ".bool"); | 115 val = gIR->ir->CreateZExt(val, LLType::getInt8Ty(gIR->context()), ".bool"); |
116 // fall through | 116 // fall through |
117 | 117 |
118 case Tvoid: | 118 case Tvoid: |
119 case Tchar: | 119 case Tchar: |
120 case Tint8: | 120 case Tint8: |
711 LLValue* lmem; | 711 LLValue* lmem; |
712 LLValue* rmem; | 712 LLValue* rmem; |
713 LLSmallVector<LLValue*, 3> args; | 713 LLSmallVector<LLValue*, 3> args; |
714 | 714 |
715 // get values, reinterpret cast to void[] | 715 // get values, reinterpret cast to void[] |
716 lmem = DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::Int8Ty)); | 716 lmem = DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context()))); |
717 args.push_back(lmem); | 717 args.push_back(lmem); |
718 | 718 |
719 rmem = DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::Int8Ty)); | 719 rmem = DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context()))); |
720 args.push_back(rmem); | 720 args.push_back(rmem); |
721 | 721 |
722 // pass array typeinfo ? | 722 // pass array typeinfo ? |
723 if (useti) { | 723 if (useti) { |
724 Type* t = l->getType(); | 724 Type* t = l->getType(); |
1038 // but shouldn't since it might be generic code that's never executed | 1038 // but shouldn't since it might be generic code that's never executed |
1039 | 1039 |
1040 // runtime check | 1040 // runtime check |
1041 | 1041 |
1042 llvm::BasicBlock* oldend = gIR->scopeend(); | 1042 llvm::BasicBlock* oldend = gIR->scopeend(); |
1043 llvm::BasicBlock* failbb = llvm::BasicBlock::Create("arrayboundscheckfail", gIR->topfunc(), oldend); | 1043 llvm::BasicBlock* failbb = llvm::BasicBlock::Create(gIR->context(), "arrayboundscheckfail", gIR->topfunc(), oldend); |
1044 llvm::BasicBlock* okbb = llvm::BasicBlock::Create("arrayboundsok", gIR->topfunc(), oldend); | 1044 llvm::BasicBlock* okbb = llvm::BasicBlock::Create(gIR->context(), "arrayboundsok", gIR->topfunc(), oldend); |
1045 | 1045 |
1046 llvm::ICmpInst::Predicate cmpop = isslice ? llvm::ICmpInst::ICMP_ULE : llvm::ICmpInst::ICMP_ULT; | 1046 llvm::ICmpInst::Predicate cmpop = isslice ? llvm::ICmpInst::ICMP_ULE : llvm::ICmpInst::ICMP_ULT; |
1047 LLValue* cond = gIR->ir->CreateICmp(cmpop, index->getRVal(), DtoArrayLen(arr), "boundscheck"); | 1047 LLValue* cond = gIR->ir->CreateICmp(cmpop, index->getRVal(), DtoArrayLen(arr), "boundscheck"); |
1048 gIR->ir->CreateCondBr(cond, okbb, failbb); | 1048 gIR->ir->CreateCondBr(cond, okbb, failbb); |
1049 | 1049 |