mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add SIL instructions to convert between thin functions
and raw pointers. Swift SVN r23992
This commit is contained in:
@@ -333,6 +333,16 @@ public:
|
||||
return insert(new (F.getModule()) ConvertFunctionInst(Loc, Op, Ty));
|
||||
}
|
||||
|
||||
ThinFunctionToPointerInst *
|
||||
createThinFunctionToPointer(SILLocation Loc, SILValue Op, SILType Ty) {
|
||||
return insert(new (F.getModule()) ThinFunctionToPointerInst(Loc, Op, Ty));
|
||||
}
|
||||
|
||||
PointerToThinFunctionInst *
|
||||
createPointerToThinFunction(SILLocation Loc, SILValue Op, SILType Ty) {
|
||||
return insert(new (F.getModule()) PointerToThinFunctionInst(Loc, Op, Ty));
|
||||
}
|
||||
|
||||
UpcastInst *createUpcast(SILLocation Loc, SILValue Op, SILType Ty) {
|
||||
return insert(new (F.getModule()) UpcastInst(Loc, Op, Ty));
|
||||
}
|
||||
|
||||
@@ -652,6 +652,24 @@ SILCloner<ImplClass>::visitConvertFunctionInst(ConvertFunctionInst *Inst) {
|
||||
getOpType(Inst->getType())));
|
||||
}
|
||||
|
||||
template<typename ImplClass>
|
||||
void SILCloner<ImplClass>::visitThinFunctionToPointerInst(
|
||||
ThinFunctionToPointerInst *Inst) {
|
||||
doPostProcess(Inst,
|
||||
getBuilder().createThinFunctionToPointer(getOpLocation(Inst->getLoc()),
|
||||
getOpValue(Inst->getOperand()),
|
||||
getOpType(Inst->getType())));
|
||||
}
|
||||
|
||||
template<typename ImplClass>
|
||||
void SILCloner<ImplClass>::visitPointerToThinFunctionInst(
|
||||
PointerToThinFunctionInst *Inst) {
|
||||
doPostProcess(Inst,
|
||||
getBuilder().createPointerToThinFunction(getOpLocation(Inst->getLoc()),
|
||||
getOpValue(Inst->getOperand()),
|
||||
getOpType(Inst->getType())));
|
||||
}
|
||||
|
||||
template<typename ImplClass>
|
||||
void
|
||||
SILCloner<ImplClass>::visitUpcastInst(UpcastInst *Inst) {
|
||||
|
||||
@@ -1231,8 +1231,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// ConvertFunctionInst - Change the type of some value without affecting how it
|
||||
/// will codegen.
|
||||
/// ConvertFunctionInst - Change the type of a function value without
|
||||
/// affecting how it will codegen.
|
||||
class ConvertFunctionInst
|
||||
: public UnaryInstructionBase<ValueKind::ConvertFunctionInst, ConversionInst>
|
||||
{
|
||||
@@ -1241,6 +1241,28 @@ public:
|
||||
: UnaryInstructionBase(Loc, Operand, Ty) {}
|
||||
};
|
||||
|
||||
/// ThinFunctionToPointerInst - Convert a thin function pointer to a
|
||||
/// Builtin.RawPointer.
|
||||
class ThinFunctionToPointerInst
|
||||
: public UnaryInstructionBase<ValueKind::ThinFunctionToPointerInst,
|
||||
ConversionInst>
|
||||
{
|
||||
public:
|
||||
ThinFunctionToPointerInst(SILLocation loc, SILValue operand, SILType ty)
|
||||
: UnaryInstructionBase(loc, operand, ty) {}
|
||||
};
|
||||
|
||||
/// PointerToThinFunctionInst - Convert a Builtin.RawPointer to a thin
|
||||
/// function pointer.
|
||||
class PointerToThinFunctionInst
|
||||
: public UnaryInstructionBase<ValueKind::PointerToThinFunctionInst,
|
||||
ConversionInst>
|
||||
{
|
||||
public:
|
||||
PointerToThinFunctionInst(SILLocation loc, SILValue operand, SILType ty)
|
||||
: UnaryInstructionBase(loc, operand, ty) {}
|
||||
};
|
||||
|
||||
/// UpcastInst - Perform a conversion of a class instance to a supertype.
|
||||
class UpcastInst
|
||||
: public UnaryInstructionBase<ValueKind::UpcastInst, ConversionInst>
|
||||
|
||||
@@ -192,6 +192,8 @@ ABSTRACT_VALUE(SILInstruction, ValueBase)
|
||||
INST(RefToUnmanagedInst, ConversionInst, None)
|
||||
INST(UnmanagedToRefInst, ConversionInst, None)
|
||||
INST(ConvertFunctionInst, ConversionInst, None)
|
||||
INST(ThinFunctionToPointerInst, ConversionInst, None)
|
||||
INST(PointerToThinFunctionInst, ConversionInst, None)
|
||||
INST(RefToBridgeObjectInst, ConversionInst, None)
|
||||
INST(BridgeObjectToRefInst, ConversionInst, None)
|
||||
INST(BridgeObjectToWordInst, ConversionInst, None)
|
||||
|
||||
Reference in New Issue
Block a user