mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
@@ -996,9 +996,7 @@ class ApplyInstBase;
|
||||
// partial specialization for full applies inherits from this.
|
||||
template <class Impl, class Base>
|
||||
class ApplyInstBase<Impl, Base, false> : public Base {
|
||||
enum {
|
||||
Callee
|
||||
};
|
||||
enum { Callee, NumStaticOperands };
|
||||
|
||||
/// The type of the callee with our substitutions applied.
|
||||
SILType SubstCalleeType;
|
||||
@@ -1015,7 +1013,7 @@ class ApplyInstBase<Impl, Base, false> : public Base {
|
||||
unsigned NumCallArguments;
|
||||
|
||||
/// The fixed operand is the callee; the rest are arguments.
|
||||
TailAllocatedOperandList<1> Operands;
|
||||
TailAllocatedOperandList<NumStaticOperands> Operands;
|
||||
|
||||
Substitution *getSubstitutionsStorage() {
|
||||
return reinterpret_cast<Substitution*>(Operands.asArray().end());
|
||||
@@ -1117,6 +1115,8 @@ public:
|
||||
return {getSubstitutionsStorage(), NumSubstitutions};
|
||||
}
|
||||
|
||||
static unsigned getOperandIndexOfFirstArgument() { return NumStaticOperands; }
|
||||
|
||||
/// The arguments passed to this instruction.
|
||||
MutableArrayRef<Operand> getArgumentOperands() {
|
||||
return Operands.getDynamicAsArray().slice(0, getNumCallArguments());
|
||||
@@ -1459,6 +1459,11 @@ public:
|
||||
StoredProperty,
|
||||
GettableProperty,
|
||||
SettableProperty,
|
||||
Last_Packed = SettableProperty, // Last enum value that can be packed in
|
||||
// a PointerIntPair
|
||||
OptionalChain,
|
||||
OptionalForce,
|
||||
OptionalWrap,
|
||||
};
|
||||
|
||||
// The pair of a captured index value and its Hashable conformance for a
|
||||
@@ -1469,40 +1474,63 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
// Value is the VarDecl* for StoredProperty, and the SILFunction* of the
|
||||
// Getter for computed properties
|
||||
llvm::PointerIntPair<void *, 2, Kind> ValueAndKind;
|
||||
static constexpr const unsigned KindPackingBits = 2;
|
||||
static constexpr const unsigned UnpackedKind = (1u << KindPackingBits) - 1;
|
||||
static_assert((unsigned)Kind::Last_Packed < UnpackedKind,
|
||||
"too many kinds to pack");
|
||||
|
||||
// Value is the VarDecl* for StoredProperty, the SILFunction* of the
|
||||
// Getter for computed properties, or the Kind for other kinds
|
||||
llvm::PointerIntPair<void *, KindPackingBits, unsigned> ValueAndKind;
|
||||
// false if id is a SILFunction*; true if id is a SILDeclRef
|
||||
llvm::PointerIntPair<SILFunction *, 2, ComputedPropertyId::KindType>
|
||||
llvm::PointerIntPair<SILFunction *, 2,
|
||||
ComputedPropertyId::KindType>
|
||||
SetterAndIdKind;
|
||||
ComputedPropertyId::ValueType IdValue;
|
||||
ArrayRef<IndexPair> Indices;
|
||||
CanType ComponentType;
|
||||
|
||||
|
||||
unsigned kindForPacking(Kind k) {
|
||||
auto value = (unsigned)k;
|
||||
assert(value <= (unsigned)Kind::Last_Packed);
|
||||
return value;
|
||||
}
|
||||
|
||||
KeyPathPatternComponent(Kind kind, CanType ComponentType)
|
||||
: ValueAndKind((void*)((uintptr_t)kind << KindPackingBits), UnpackedKind),
|
||||
ComponentType(ComponentType)
|
||||
{
|
||||
assert(kind > Kind::Last_Packed && "wrong initializer");
|
||||
}
|
||||
|
||||
KeyPathPatternComponent(VarDecl *storedProp, Kind kind,
|
||||
CanType ComponentType)
|
||||
: ValueAndKind(storedProp, kind), ComponentType(ComponentType) {}
|
||||
: ValueAndKind(storedProp, kindForPacking(kind)),
|
||||
ComponentType(ComponentType) {}
|
||||
|
||||
KeyPathPatternComponent(ComputedPropertyId id, Kind kind,
|
||||
SILFunction *getter,
|
||||
SILFunction *setter,
|
||||
ArrayRef<IndexPair> indices,
|
||||
CanType ComponentType)
|
||||
: ValueAndKind(getter, kind),
|
||||
: ValueAndKind(getter, kindForPacking(kind)),
|
||||
SetterAndIdKind(setter, id.Kind),
|
||||
IdValue(id.Value),
|
||||
Indices(indices),
|
||||
ComponentType(ComponentType) {}
|
||||
|
||||
public:
|
||||
KeyPathPatternComponent() : ValueAndKind(nullptr, (Kind)0) {}
|
||||
KeyPathPatternComponent() : ValueAndKind(nullptr, 0) {}
|
||||
|
||||
bool isNull() const {
|
||||
return ValueAndKind.getPointer() == nullptr;
|
||||
}
|
||||
|
||||
Kind getKind() const {
|
||||
return ValueAndKind.getInt();
|
||||
auto packedKind = ValueAndKind.getInt();
|
||||
if (packedKind != UnpackedKind)
|
||||
return (Kind)packedKind;
|
||||
return (Kind)((uintptr_t)ValueAndKind.getPointer() >> KindPackingBits);
|
||||
}
|
||||
|
||||
CanType getComponentType() const {
|
||||
@@ -1515,6 +1543,9 @@ public:
|
||||
return static_cast<VarDecl*>(ValueAndKind.getPointer());
|
||||
case Kind::GettableProperty:
|
||||
case Kind::SettableProperty:
|
||||
case Kind::OptionalChain:
|
||||
case Kind::OptionalForce:
|
||||
case Kind::OptionalWrap:
|
||||
llvm_unreachable("not a stored property");
|
||||
}
|
||||
llvm_unreachable("unhandled kind");
|
||||
@@ -1523,6 +1554,9 @@ public:
|
||||
ComputedPropertyId getComputedPropertyId() const {
|
||||
switch (getKind()) {
|
||||
case Kind::StoredProperty:
|
||||
case Kind::OptionalChain:
|
||||
case Kind::OptionalForce:
|
||||
case Kind::OptionalWrap:
|
||||
llvm_unreachable("not a computed property");
|
||||
case Kind::GettableProperty:
|
||||
case Kind::SettableProperty:
|
||||
@@ -1534,6 +1568,9 @@ public:
|
||||
SILFunction *getComputedPropertyGetter() const {
|
||||
switch (getKind()) {
|
||||
case Kind::StoredProperty:
|
||||
case Kind::OptionalChain:
|
||||
case Kind::OptionalForce:
|
||||
case Kind::OptionalWrap:
|
||||
llvm_unreachable("not a computed property");
|
||||
case Kind::GettableProperty:
|
||||
case Kind::SettableProperty:
|
||||
@@ -1546,6 +1583,9 @@ public:
|
||||
switch (getKind()) {
|
||||
case Kind::StoredProperty:
|
||||
case Kind::GettableProperty:
|
||||
case Kind::OptionalChain:
|
||||
case Kind::OptionalForce:
|
||||
case Kind::OptionalWrap:
|
||||
llvm_unreachable("not a settable computed property");
|
||||
case Kind::SettableProperty:
|
||||
return SetterAndIdKind.getPointer();
|
||||
@@ -1556,6 +1596,9 @@ public:
|
||||
ArrayRef<IndexPair> getComputedPropertyIndices() const {
|
||||
switch (getKind()) {
|
||||
case Kind::StoredProperty:
|
||||
case Kind::OptionalChain:
|
||||
case Kind::OptionalForce:
|
||||
case Kind::OptionalWrap:
|
||||
llvm_unreachable("not a computed property");
|
||||
case Kind::GettableProperty:
|
||||
case Kind::SettableProperty:
|
||||
@@ -1589,6 +1632,24 @@ public:
|
||||
getter, setter, indices, ty);
|
||||
}
|
||||
|
||||
static KeyPathPatternComponent
|
||||
forOptional(Kind kind, CanType ty) {
|
||||
switch (kind) {
|
||||
case Kind::OptionalChain:
|
||||
case Kind::OptionalForce:
|
||||
break;
|
||||
case Kind::OptionalWrap:
|
||||
assert(ty->getAnyOptionalObjectType()
|
||||
&& "optional wrap didn't form optional?!");
|
||||
break;
|
||||
case Kind::StoredProperty:
|
||||
case Kind::GettableProperty:
|
||||
case Kind::SettableProperty:
|
||||
llvm_unreachable("not an optional kind");
|
||||
}
|
||||
return KeyPathPatternComponent(kind, ty);
|
||||
}
|
||||
|
||||
void incrementRefCounts() const;
|
||||
void decrementRefCounts() const;
|
||||
|
||||
@@ -6371,6 +6432,12 @@ public:
|
||||
FOREACH_IMPL_RETURN(getNumCallArguments());
|
||||
}
|
||||
|
||||
unsigned getOperandIndexOfFirstArgument() {
|
||||
FOREACH_IMPL_RETURN(getOperandIndexOfFirstArgument());
|
||||
}
|
||||
|
||||
#undef FOREACH_IMPL_RETURN
|
||||
|
||||
/// The arguments passed to this instruction, without self.
|
||||
OperandValueArrayRef getArgumentsWithoutSelf() const {
|
||||
switch (Inst->getKind()) {
|
||||
@@ -6394,12 +6461,26 @@ public:
|
||||
case ValueKind::TryApplyInst:
|
||||
return 0;
|
||||
case ValueKind::PartialApplyInst:
|
||||
// The arguments to partial_apply are a suffix of the arguments to the
|
||||
// the actually-called function.
|
||||
return getSubstCalleeConv().getNumSILArguments() - getNumArguments();
|
||||
default:
|
||||
llvm_unreachable("not implemented for this instruction!");
|
||||
}
|
||||
}
|
||||
|
||||
// Translate the index of the argument to the full apply or partial_apply into
|
||||
// to the corresponding index into the arguments of the called function.
|
||||
unsigned getCalleeArgIndex(Operand &oper) {
|
||||
assert(oper.getUser() == Inst);
|
||||
assert(oper.getOperandNumber() >= getOperandIndexOfFirstArgument());
|
||||
|
||||
unsigned appliedArgIdx =
|
||||
oper.getOperandNumber() - getOperandIndexOfFirstArgument();
|
||||
|
||||
return getCalleeArgIndexOfFirstAppliedArg() + appliedArgIdx;
|
||||
}
|
||||
|
||||
Operand &getArgumentRef(unsigned i) const { return getArgumentOperands()[i]; }
|
||||
|
||||
/// Return the ith argument passed to this instruction.
|
||||
@@ -6446,8 +6527,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#undef FOREACH_IMPL_RETURN
|
||||
|
||||
SILArgumentConvention getArgumentConvention(unsigned index) const {
|
||||
return getSubstCalleeConv().getSILArgumentConvention(index);
|
||||
}
|
||||
|
||||
@@ -252,6 +252,20 @@ inline SILLinkage effectiveLinkageForClassMember(SILLinkage linkage,
|
||||
return linkage;
|
||||
}
|
||||
|
||||
// FIXME: This should not be necessary, but it looks like visibility rules for
|
||||
// extension members are slightly bogus, and so some protocol witness thunks
|
||||
// need to be public.
|
||||
//
|
||||
// We allow a 'public' member of an extension to witness a public
|
||||
// protocol requirement, even if the extended type is not public;
|
||||
// then SILGen gives the member private linkage, ignoring the more
|
||||
// visible accessibility it was given in the AST.
|
||||
inline bool
|
||||
fixmeWitnessHasLinkageThatNeedsToBePublic(SILLinkage witnessLinkage) {
|
||||
return !hasPublicVisibility(witnessLinkage) &&
|
||||
!hasSharedVisibility(witnessLinkage);
|
||||
}
|
||||
|
||||
} // end swift namespace
|
||||
|
||||
#endif
|
||||
|
||||
@@ -209,9 +209,6 @@ private:
|
||||
/// optimizations can assume that they see the whole module.
|
||||
bool wholeModule;
|
||||
|
||||
/// True if this SILModule is being completely serialized.
|
||||
bool WholeModuleSerialized;
|
||||
|
||||
/// The options passed into this SILModule.
|
||||
SILOptions &Options;
|
||||
|
||||
@@ -222,7 +219,7 @@ private:
|
||||
// Intentionally marked private so that we need to use 'constructSIL()'
|
||||
// to construct a SILModule.
|
||||
SILModule(ModuleDecl *M, SILOptions &Options, const DeclContext *associatedDC,
|
||||
bool wholeModule, bool wholeModuleSerialized);
|
||||
bool wholeModule);
|
||||
|
||||
SILModule(const SILModule&) = delete;
|
||||
void operator=(const SILModule&) = delete;
|
||||
@@ -285,23 +282,18 @@ public:
|
||||
///
|
||||
/// If a source file is provided, SIL will only be emitted for decls in that
|
||||
/// source file, starting from the specified element number.
|
||||
///
|
||||
/// If \p makeModuleFragile is true, all functions and global variables of
|
||||
/// the module are marked as serialized. This is used for compiling the stdlib.
|
||||
static std::unique_ptr<SILModule>
|
||||
constructSIL(ModuleDecl *M, SILOptions &Options, FileUnit *sf = nullptr,
|
||||
Optional<unsigned> startElem = None,
|
||||
bool makeModuleFragile = false,
|
||||
bool isWholeModule = false);
|
||||
|
||||
/// \brief Create and return an empty SIL module that we can
|
||||
/// later parse SIL bodies directly into, without converting from an AST.
|
||||
static std::unique_ptr<SILModule>
|
||||
createEmptyModule(ModuleDecl *M, SILOptions &Options,
|
||||
bool WholeModule = false,
|
||||
bool WholeModuleSerialized = false) {
|
||||
bool WholeModule = false) {
|
||||
return std::unique_ptr<SILModule>(
|
||||
new SILModule(M, Options, M, WholeModule, WholeModuleSerialized));
|
||||
new SILModule(M, Options, M, WholeModule));
|
||||
}
|
||||
|
||||
/// Get the Swift module associated with this SIL module.
|
||||
@@ -330,7 +322,7 @@ public:
|
||||
}
|
||||
|
||||
/// Returns true if everything in this SILModule is being serialized.
|
||||
bool isWholeModuleSerialized() const { return WholeModuleSerialized; }
|
||||
bool isWholeModuleSerialized() const { return Options.SILSerializeAll; }
|
||||
|
||||
SILOptions &getOptions() const { return Options; }
|
||||
|
||||
|
||||
@@ -34,8 +34,10 @@ namespace swift {
|
||||
|
||||
class SILFunction;
|
||||
class SILModule;
|
||||
class ProtocolConformance;
|
||||
class NormalProtocolConformance;
|
||||
enum IsSerialized_t : unsigned char;
|
||||
enum class ResilienceStrategy : unsigned;
|
||||
|
||||
/// A mapping from each requirement of a protocol to the SIL-level entity
|
||||
/// satisfying the requirement for a concrete type.
|
||||
@@ -269,13 +271,18 @@ public:
|
||||
void convertToDefinition(ArrayRef<Entry> newEntries,
|
||||
IsSerialized_t isSerialized);
|
||||
|
||||
// Whether a conformance should be serialized.
|
||||
static bool conformanceIsSerialized(ProtocolConformance *conformance,
|
||||
ResilienceStrategy strategy,
|
||||
bool silSerializeWitnessTables);
|
||||
|
||||
/// Print the witness table.
|
||||
void print(llvm::raw_ostream &OS, bool Verbose = false) const;
|
||||
|
||||
/// Dump the witness table to stderr.
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
|
||||
} // end swift namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user