mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
remove prepareCall and some various array handling logic now handled by SILGen.
Swift SVN r4793
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user