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:
Chris Lattner
2013-05-17 05:31:27 +00:00
parent 86d9c43c34
commit fd398e32e3
2 changed files with 22 additions and 10 deletions

View File

@@ -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.

View File

@@ -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());