Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SPMBuildToolSupport
Submodule SPMBuildToolSupport updated 26 files
+3 −3 .devcontainer/devcontainer.json
+8 −24 .github/workflows/build-and-test.yml
+1 −0 DemoScripts/Echo1Into2.swift
+29 −39 Package.swift
+2 −15 Plugins/CmdPlugin/CommandDemoPlugin.swift
+0 −0 Plugins/CmdPlugin/SPMBuildToolSupport.swift
+9 −9 Plugins/CmdTgtPlugin/LocalTargetCommandDemoPlugin.swift
+0 −0 Plugins/CmdTgtPlugin/SPMBuildToolSupport.swift
+3 −3 Plugins/ExecutablePlugin/ExecutableFileDemoPlugin.swift
+0 −0 Plugins/ExecutablePlugin/SPMBuildToolSupport.swift
+0 −0 Plugins/SwiftScriptPlugin/SPMBuildToolSupport.swift
+3 −3 Plugins/SwiftScriptPlugin/SwiftScriptDemoPlugin.swift
+0 −0 Plugins/SwiftToolchainCmdPlugin/SPMBuildToolSupport.swift
+3 −3 Plugins/SwiftToolchainCmdPlugin/SwiftToolchainCommandDemoPlugin.swift
+1 −10 README.md
+38 −112 SPMBuildToolSupport.swift
+1 −1 Sources/AppWithResource/main.swift
+1 −1 Sources/GenRsrc/main.swift
+0 −0 Sources/LibWithRsrcFromLocalTgt/BuildToolPluginInputs/Test1.in
+0 −0 Sources/LibWithRsrcFromLocalTgt/BuildToolPluginInputs/Test2.in
+0 −0 Sources/LibWithRsrcFromLocalTgt/LibWithResourceGeneratedByLocalTarget.swift
+0 −0 Sources/LibWithRsrcFromToolCmd/LibWithResourceGeneratedBySwiftToolchainCommand.swift
+0 −0 Sources/LibWithSrcFromCmd/LibWithSourceGeneratedByCommand.swift
+0 −0 Sources/LibWithSrcFromExecutable/LibWithSourceGeneratedByExecutableFile.swift
+0 −0 Sources/LibWithSrcFromSwiftScript/LibWithSourceGeneratedBySwiftScript.swift
+17 −2 Tests/SPMBuildToolSupportTests/SPMBuildToolSupportTests.swift
45 changes: 0 additions & 45 deletions Sources/IR/BlockID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ extension Block {
self.address = address
}

/// Creates an instance with the given address.
public init(_ b: Block.AbsoluteID) {
self.address = b.address
}

/// Creates an instance denoting the block containing `i`.
public init(containing i: InstructionID) {
self.address = i.block
Expand All @@ -41,50 +36,10 @@ extension Block {

}

/// The absolute ID of a basic block.
public struct AbsoluteID: Hashable {

/// The ID of the function containing the block.
public var function: Function.ID

/// The address of the block in the containing function.
public var address: Function.Blocks.Address

/// Creates an instance with the given properties.
public init(_ function: Function.ID, _ address: Function.Blocks.Address) {
self.function = function
self.address = address
}

/// Creates an instance with the given properties.
public init(_ function: Function.ID, _ block: Block.ID) {
self.function = function
self.address = block.address
}

/// The ID of the `index`-th parameter of the block.
public func parameter(_ index: Int) -> Operand {
.parameter(Block.ID(self), index)
}

/// The operand denoting the result of the instruction at `instructionAddress` in the block
/// identified by `self`.
public func result(at instructionAddress: Block.Instructions.Address) -> Operand {
.register(InstructionID(address, instructionAddress))
}

}

}

extension Block.ID: CustomStringConvertible {

public var description: String { "b\(address)" }

}

extension Block.AbsoluteID: CustomStringConvertible {

public var description: String { "b\(address)" }

}
15 changes: 13 additions & 2 deletions Sources/IR/Emitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct Emitter: Sendable {
private var loops = LoopIDs()

/// For each block, the state of `frames` where the block was first entered.
private var stackOnEntry: [Block.AbsoluteID: Stack] = [:]
private var stackOnEntry: [BlockAndFunction: Stack] = [:]

/// Where new instructions are inserted.
var insertionPoint: InsertionPoint?
Expand All @@ -68,6 +68,17 @@ struct Emitter: Sendable {
/// The source code associated with instructions to be inserted.
var currentSource: SourceRange

/// The block's ID across functions.
public struct BlockAndFunction: Hashable {

/// The ID of the function containing the block.
public var function: Function.ID

/// The block's ID inside the function.
public var block: Block.ID

}

/// The program being lowered.
private var program: TypedProgram {
module.program
Expand Down Expand Up @@ -3592,7 +3603,7 @@ extension Emitter {
/// This test is used to ensure that all points branching to a block
/// have consistent stack allocations.
fileprivate mutating func checkEntryStack(_ b: Block.ID) {
modify(&stackOnEntry[Block.AbsoluteID(insertionFunction!, b)]) { x in
modify(&stackOnEntry[BlockAndFunction(function: insertionFunction!, block: b)]) { x in
if let y = x {
assert(y.hasSameAllocations(as: frames))
}
Expand Down
Loading