mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Swift SIL: add some Builder APIs
* `createCheckedCastAddrBranch` * `createUnconditionalCheckedCastAddr` * `createDebugValue` * `createWitnessMethod` * `createInitEnumDataAddr`
This commit is contained in:
@@ -175,6 +175,38 @@ public struct Builder {
|
||||
let cast = bridged.createUpcast(value.bridged, type.bridged)
|
||||
return notifyNew(cast.getAs(UpcastInst.self))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func createCheckedCastAddrBranch(
|
||||
source: Value, sourceFormalType: CanonicalType,
|
||||
destination: Value, targetFormalType: CanonicalType,
|
||||
consumptionKind: CheckedCastAddrBranchInst.CastConsumptionKind,
|
||||
successBlock: BasicBlock,
|
||||
failureBlock: BasicBlock
|
||||
) -> CheckedCastAddrBranchInst {
|
||||
|
||||
let bridgedConsumption: BridgedInstruction.CastConsumptionKind
|
||||
switch consumptionKind {
|
||||
case .TakeAlways: bridgedConsumption = .TakeAlways
|
||||
case .TakeOnSuccess: bridgedConsumption = .TakeOnSuccess
|
||||
case .CopyOnSuccess: bridgedConsumption = .CopyOnSuccess
|
||||
}
|
||||
let cast = bridged.createCheckedCastAddrBranch(source.bridged, sourceFormalType.bridged,
|
||||
destination.bridged, targetFormalType.bridged,
|
||||
bridgedConsumption,
|
||||
successBlock.bridged, failureBlock.bridged)
|
||||
return notifyNew(cast.getAs(CheckedCastAddrBranchInst.self))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func createUnconditionalCheckedCastAddr(
|
||||
source: Value, sourceFormalType: CanonicalType,
|
||||
destination: Value, targetFormalType: CanonicalType
|
||||
) -> UnconditionalCheckedCastAddrInst {
|
||||
let cast = bridged.createUnconditionalCheckedCastAddr(source.bridged, sourceFormalType.bridged,
|
||||
destination.bridged, targetFormalType.bridged)
|
||||
return notifyNew(cast.getAs(UnconditionalCheckedCastAddrInst.self))
|
||||
}
|
||||
|
||||
public func createLoad(fromAddress: Value, ownership: LoadInst.LoadOwnership) -> LoadInst {
|
||||
let load = bridged.createLoad(fromAddress.bridged, ownership.rawValue)
|
||||
@@ -285,6 +317,11 @@ public struct Builder {
|
||||
return notifyNew(bridged.createEndLifetime(value.bridged).getAs(EndLifetimeInst.self))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func createDebugValue(value: Value, debugVariable: DebugVariableInstruction.DebugVariable) -> DebugValueInst {
|
||||
return notifyNew(bridged.createDebugValue(value.bridged, debugVariable).getAs(DebugValueInst.self))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func createDebugStep() -> DebugStepInst {
|
||||
return notifyNew(bridged.createDebugStep().getAs(DebugStepInst.self))
|
||||
@@ -324,6 +361,14 @@ public struct Builder {
|
||||
return notifyNew(apply.getAs(TryApplyInst.self))
|
||||
}
|
||||
|
||||
public func createWitnessMethod(lookupType: CanonicalType,
|
||||
conformance: Conformance,
|
||||
member: DeclRef,
|
||||
methodType: Type) -> WitnessMethodInst {
|
||||
return notifyNew(bridged.createWitnessMethod(lookupType.bridged, conformance.bridged,
|
||||
member.bridged, methodType.bridged).getAs(WitnessMethodInst.self))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func createReturn(of value: Value) -> ReturnInst {
|
||||
return notifyNew(bridged.createReturn(value.bridged).getAs(ReturnInst.self))
|
||||
@@ -347,6 +392,11 @@ public struct Builder {
|
||||
return notifyNew(uteda.getAs(UncheckedTakeEnumDataAddrInst.self))
|
||||
}
|
||||
|
||||
public func createInitEnumDataAddr(enumAddress: Value, caseIndex: Int, type: Type) -> InitEnumDataAddrInst {
|
||||
let uteda = bridged.createInitEnumDataAddr(enumAddress.bridged, caseIndex, type.bridged)
|
||||
return notifyNew(uteda.getAs(InitEnumDataAddrInst.self))
|
||||
}
|
||||
|
||||
public func createEnum(caseIndex: Int, payload: Value?, enumType: Type) -> EnumInst {
|
||||
let enumInst = bridged.createEnum(caseIndex, payload.bridged, enumType.bridged)
|
||||
return notifyNew(enumInst.getAs(EnumInst.self))
|
||||
|
||||
Reference in New Issue
Block a user