mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
add a public way to get a primitive SILType. SILFunctionTypeInfo and
SILCompoundTypeInfo already have public construction functions that unique in the SILModule. Swift SVN r5201
This commit is contained in:
@@ -140,16 +140,20 @@ class SILType {
|
||||
: value(ty.getPointer(), makeFlags(address, loadable)) {
|
||||
assert((address || loadable) &&
|
||||
"SILType can't be the value of an address-only type");
|
||||
assert(!(ty && ty->is<LValueType>()) &&
|
||||
if (!ty) return;
|
||||
|
||||
assert(!ty->is<LValueType>() &&
|
||||
"LValueTypes should be eliminated by SIL lowering");
|
||||
assert(!(ty && ty->is<AnyFunctionType>()) &&
|
||||
"SIL lowering must produce a SILFunctionTypeInfo for function types");
|
||||
assert(!ty->is<AnyFunctionType>() &&
|
||||
"SIL lowering must produce a SILFunctionTypeInfo for functions");
|
||||
assert(!ty->is<TupleType>() &&
|
||||
"SIL lowering must produce a SILCompoundTypeInfo for this");
|
||||
}
|
||||
|
||||
SILType(SILTypeInfo *ti, bool address, bool loadable)
|
||||
: value(ti, makeFlags(address, loadable)) {
|
||||
assert((address || loadable) &&
|
||||
"SILType can't be the value of an address-only type");
|
||||
"SILType can't be the value of an address-only type");
|
||||
}
|
||||
|
||||
SILType(ValueType value)
|
||||
@@ -160,14 +164,19 @@ class SILType {
|
||||
public:
|
||||
SILType() = default;
|
||||
|
||||
|
||||
/// getPrimitiveType - Form a SILType for a primitive type that does not
|
||||
/// require any special handling (i.e., not a function or aggregate type).
|
||||
static SILType getPrimitiveType(CanType T, bool isAddress, bool isLoadable) {
|
||||
return SILType(T, isAddress, isLoadable);
|
||||
}
|
||||
|
||||
|
||||
bool isNull() const { return value.getPointer().isNull(); }
|
||||
explicit operator bool() const { return bool(value.getPointer()); }
|
||||
|
||||
bool isInvalid() const { return value.getInt() == InvalidFlags; }
|
||||
|
||||
void dump() const;
|
||||
void print(raw_ostream &OS) const;
|
||||
|
||||
/// Gets the address type referencing this type, or the type itself if it is
|
||||
/// already an address type.
|
||||
SILType getAddressType() const {
|
||||
@@ -304,6 +313,9 @@ public:
|
||||
bool operator!=(SILType rhs) const {
|
||||
return value.getOpaqueValue() != rhs.value.getOpaqueValue();
|
||||
}
|
||||
|
||||
void dump() const;
|
||||
void print(raw_ostream &OS) const;
|
||||
};
|
||||
|
||||
/// A high-level calling convention.
|
||||
|
||||
@@ -28,14 +28,14 @@ SILFunctionTypeInfo *SILFunctionTypeInfo::create(CanType swiftType,
|
||||
// return both the begins and ends of each uncurried argument group.
|
||||
void *buffer = M.allocate(sizeof(SILFunctionTypeInfo)
|
||||
+ sizeof(SILType)*inputTypes.size()
|
||||
+ sizeof(unsigned)*(1+uncurriedInputCounts.size()),
|
||||
+ sizeof(unsigned)*(1+uncurriedInputCounts.size()),
|
||||
alignof(SILFunctionTypeInfo));
|
||||
SILFunctionTypeInfo *fi = ::new (buffer) SILFunctionTypeInfo(
|
||||
swiftType,
|
||||
inputTypes.size(),
|
||||
resultType,
|
||||
uncurriedInputCounts.size(),
|
||||
hasIndirectReturn,
|
||||
uncurriedInputCounts.size(),
|
||||
hasIndirectReturn,
|
||||
cc);
|
||||
memcpy(fi->getInputTypeBuffer(), inputTypes.data(),
|
||||
sizeof(SILType) * inputTypes.size());
|
||||
|
||||
Reference in New Issue
Block a user