mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "New SIL instructions to support tail-allocated arrays in SIL."
This commit is contained in:
@@ -676,74 +676,44 @@ public:
|
||||
/// AllocRefInst - This represents the primitive allocation of an instance
|
||||
/// of a reference type. Aside from the reference count, the instance is
|
||||
/// returned uninitialized.
|
||||
/// Optionally, the allocated instance contains space for one or more tail-
|
||||
/// allocated arrays.
|
||||
class AllocRefInst final
|
||||
: public AllocationInst,
|
||||
public StackPromotable {
|
||||
public StackPromotable,
|
||||
private llvm::TrailingObjects<AllocRefInst, Operand> {
|
||||
friend TrailingObjects;
|
||||
friend class SILBuilder;
|
||||
unsigned NumOperands : 31;
|
||||
bool ObjC : 1;
|
||||
|
||||
// Number of tail-allocated arrays.
|
||||
unsigned short NumTailTypes;
|
||||
AllocRefInst(SILDebugLocation Loc, SILType type, SILFunction &F, bool objc,
|
||||
bool canBeOnStack, ArrayRef<SILValue> TypeDependentOperands);
|
||||
|
||||
bool ObjC;
|
||||
|
||||
/// The first NumTailTypes operands are counts for the tail allocated
|
||||
/// elements, the remaining operands are opened archetype operands.
|
||||
TailAllocatedOperandList<0> Operands;
|
||||
|
||||
SILType *getTypeStorage() {
|
||||
return reinterpret_cast<SILType*>(Operands.asArray().end());
|
||||
}
|
||||
|
||||
const SILType *getTypeStorage() const {
|
||||
return reinterpret_cast<const SILType*>(Operands.asArray().end());
|
||||
}
|
||||
|
||||
AllocRefInst(SILDebugLocation DebugLoc, SILFunction &F,
|
||||
SILType ObjectType,
|
||||
bool objc, bool canBeOnStack,
|
||||
ArrayRef<SILType> ElementTypes,
|
||||
ArrayRef<SILValue> AllOperands);
|
||||
|
||||
static AllocRefInst *create(SILDebugLocation DebugLoc, SILFunction &F,
|
||||
SILType ObjectType,
|
||||
bool objc, bool canBeOnStack,
|
||||
ArrayRef<SILType> ElementTypes,
|
||||
ArrayRef<SILValue> ElementCountOperands,
|
||||
static AllocRefInst *create(SILDebugLocation Loc, SILType type,
|
||||
SILFunction &F, bool objc, bool canBeOnStack,
|
||||
SILOpenedArchetypesState &OpenedArchetypes);
|
||||
|
||||
public:
|
||||
ArrayRef<SILType> getTailAllocatedTypes() const {
|
||||
return {getTypeStorage(), NumTailTypes};
|
||||
}
|
||||
|
||||
MutableArrayRef<SILType> getTailAllocatedTypes() {
|
||||
return {getTypeStorage(), NumTailTypes};
|
||||
}
|
||||
|
||||
ArrayRef<Operand> getTailAllocatedCounts() const {
|
||||
return getAllOperands().slice(0, NumTailTypes);
|
||||
}
|
||||
|
||||
MutableArrayRef<Operand> getTailAllocatedCounts() {
|
||||
return getAllOperands().slice(0, NumTailTypes);
|
||||
~AllocRefInst() {
|
||||
Operand *Operands = getTrailingObjects<Operand>();
|
||||
for (unsigned i = 0, end = NumOperands; i < end; ++i) {
|
||||
Operands[i].~Operand();
|
||||
}
|
||||
}
|
||||
|
||||
ArrayRef<Operand> getAllOperands() const {
|
||||
return Operands.asArray();
|
||||
return { getTrailingObjects<Operand>(), NumOperands };
|
||||
}
|
||||
|
||||
MutableArrayRef<Operand> getAllOperands() {
|
||||
return Operands.asArray();
|
||||
return { getTrailingObjects<Operand>(), NumOperands };
|
||||
}
|
||||
|
||||
ArrayRef<Operand> getTypeDependentOperands() const {
|
||||
return getAllOperands().slice(NumTailTypes);
|
||||
return getAllOperands();
|
||||
}
|
||||
|
||||
MutableArrayRef<Operand> getTypeDependentOperands() {
|
||||
return getAllOperands().slice(NumTailTypes);
|
||||
return getAllOperands();
|
||||
}
|
||||
|
||||
/// Whether to use Objective-C's allocation mechanism (+allocWithZone:).
|
||||
@@ -3524,26 +3494,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// RefTailAddrInst - Derive the address of the first element of the first
|
||||
/// tail-allocated array in a reference type instance.
|
||||
class RefTailAddrInst
|
||||
: public UnaryInstructionBase<ValueKind::RefTailAddrInst>
|
||||
{
|
||||
friend class SILBuilder;
|
||||
|
||||
RefTailAddrInst(SILDebugLocation DebugLoc, SILValue Operand, SILType ResultTy)
|
||||
: UnaryInstructionBase(DebugLoc, Operand, ResultTy) {}
|
||||
|
||||
public:
|
||||
ClassDecl *getClassDecl() const {
|
||||
auto s = getOperand()->getType().getClassOrBoundGenericClass();
|
||||
assert(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
SILType getTailType() const { return getType().getObjectType(); }
|
||||
};
|
||||
|
||||
/// MethodInst - Abstract base for instructions that implement dynamic
|
||||
/// method lookup.
|
||||
class MethodInst : public SILInstruction {
|
||||
@@ -4329,11 +4279,6 @@ public:
|
||||
: SILInstruction(Kind, DebugLoc, Operand->getType()),
|
||||
Operands{this, Operand, Index} {}
|
||||
|
||||
IndexingInst(ValueKind Kind, SILDebugLocation DebugLoc, SILValue Operand,
|
||||
SILValue Index, SILType ResultTy)
|
||||
: SILInstruction(Kind, DebugLoc, ResultTy),
|
||||
Operands{this, Operand, Index} {}
|
||||
|
||||
SILValue getBase() const { return Operands[Base].get(); }
|
||||
SILValue getIndex() const { return Operands[Index].get(); }
|
||||
|
||||
@@ -4363,24 +4308,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// TailAddrInst - like IndexingInst, but aligns-up the resulting address to a
|
||||
/// tail-allocated element type.
|
||||
class TailAddrInst : public IndexingInst {
|
||||
friend class SILBuilder;
|
||||
|
||||
TailAddrInst(SILDebugLocation DebugLoc, SILValue Operand, SILValue Count,
|
||||
SILType ResultTy)
|
||||
: IndexingInst(ValueKind::TailAddrInst, DebugLoc, Operand, Count,
|
||||
ResultTy) {}
|
||||
|
||||
public:
|
||||
static bool classof(const ValueBase *V) {
|
||||
return V->getKind() == ValueKind::TailAddrInst;
|
||||
}
|
||||
|
||||
SILType getTailType() const { return getType().getObjectType(); }
|
||||
};
|
||||
|
||||
/// IndexRawPointerInst
|
||||
/// %2 : $Builtin.RawPointer \
|
||||
/// = index_raw_pointer %0 : $Builtin.RawPointer, %1 : $Builtin.Word
|
||||
|
||||
Reference in New Issue
Block a user