remove prepareCall and some various array handling logic now handled by SILGen.

Swift SVN r4793
This commit is contained in:
Chris Lattner
2013-04-18 04:57:27 +00:00
parent 47e508c24d
commit 03394a29ea
6 changed files with 3 additions and 153 deletions

View File

@@ -107,52 +107,3 @@ const TypeInfo *TypeConverter::convertArrayType(ArrayType *T) {
return new ArrayTypeInfo();
}
/// Emit an array allocation expression.
void swift::irgen::emitNewArrayExpr(IRGenFunction &IGF, NewArrayExpr *E,
Explosion &out) {
// First things first: emit the array bound. Sema ensures that this
// is always a builtin type.
llvm::Value *length;
{
Explosion bounds(ExplosionKind::Maximal);
IGF.emitRValue(E->getBounds()[0].Value, bounds);
length = bounds.claimUnmanagedNext();
}
Expr *init = nullptr;
ArrayHeapLayout layout(IGF, E->getElementType()->getCanonicalType());
Address begin;
ManagedValue alloc =
layout.emitAlloc(IGF, length, begin, init, "new-array");
emitArrayInjectionCall(IGF, alloc, begin, E->getType()->getCanonicalType(),
E->getInjectionFunction(), length, out);
}
void irgen::emitArrayInjectionCall(IRGenFunction &IGF, ManagedValue alloc,
Address begin, CanType sliceTy,
Expr *injectionFn, llvm::Value *length,
Explosion &out) {
// Emit the allocation.
// Eventually the data address will be well-typed, but for now it
// always needs to be an i8*.
llvm::Value *dataAddr = begin.getAddress();
dataAddr = IGF.Builder.CreateBitCast(dataAddr, IGF.IGM.Int8PtrTy);
// Emit the callee.
CallEmission emission = prepareCall(IGF, injectionFn, out.getKind(),
1, sliceTy);
// The injection function takes this tuple:
// (Builtin.RawPointer, Builtin.ObjectPointer, typeof(length))
Explosion injectionArg(emission.getCurExplosionLevel());
injectionArg.addUnmanaged(dataAddr);
injectionArg.add(alloc);
injectionArg.addUnmanaged(length);
emission.addArg(injectionArg);
// Force the call.
emission.emitToExplosion(out);
}