Small clean-up. Add createUncheckedBitCast to SILBuilder.

This new method eliminates repeated code sequences that all create an
unchecked_trivial_bit_cast if the result type is trivial or
unchecked_ref_bit_cast otherwise.

NFC.

Swift SVN r29486
This commit is contained in:
Mark Lacey
2015-06-18 07:30:42 +00:00
parent a065ae99c8
commit 75b5b1248e
5 changed files with 31 additions and 41 deletions

View File

@@ -443,6 +443,17 @@ public:
return insert(new (F.getModule()) UncheckedRefBitCastInst(Loc, Op, Ty));
}
// Create the appropriate cast instruction based on result type.
SILInstruction *createUncheckedBitCast(SILLocation Loc,
SILValue Op,
SILType Ty) {
auto &M = F.getModule();
if (Ty.isTrivial(M))
return insert(new (M) UncheckedTrivialBitCastInst(Loc, Op, Ty));
else
return insert(new (M) UncheckedRefBitCastInst(Loc, Op, Ty));
}
RefToBridgeObjectInst *createRefToBridgeObject(SILLocation Loc,
SILValue Ref,
SILValue Bits) {