Skip to content

Commit 9795f4b

Browse files
committed
Swift Optimizer: add bridging for command line options
1 parent 2a2c009 commit 9795f4b

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
swift_compiler_sources(Optimizer
1010
ModulePassContext.swift
11+
Options.swift
1112
Passes.swift
1213
PassContext.swift
1314
PassRegistration.swift)

SwiftCompilerSources/Sources/Optimizer/PassManager/ModulePassContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ struct ModulePassContext {
9191
DefaultWitnessTableList(first: PassContext_firstDefaultWitnessTableInModule(_bridged).table)
9292
}
9393

94+
var options: Options { Options(_bridged: _bridged) }
95+
9496
/// Run a closure with a `PassContext` for a function, which allows to modify that function.
9597
///
9698
/// Only a single `transform` can be alive at the same time, i.e. it's not allowed to nest
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===--- Options.swift ----------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import OptimizerBridging
14+
15+
struct Options {
16+
let _bridged: BridgedPassContext
17+
}

SwiftCompilerSources/Sources/Optimizer/PassManager/PassContext.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ struct PassContext {
2222

2323
let _bridged: BridgedPassContext
2424

25+
var options: Options { Options(_bridged: _bridged) }
26+
2527
func continueWithNextSubpassRun(for inst: Instruction? = nil) -> Bool {
2628
let bridgedInst = OptionalBridgedInstruction(obj: inst?.bridged.obj)
2729
return PassContext_continueWithNextSubpassRun(_bridged, bridgedInst) != 0

0 commit comments

Comments
 (0)