Skip to content

Commit 1aa0492

Browse files
authored
Revert "TSCUtility: deprecate Bitstream interfaces (#351)"
This reverts commit 84449cd.
1 parent 84449cd commit 1aa0492

File tree

4 files changed

+0
-44
lines changed

4 files changed

+0
-44
lines changed

Sources/TSCUtility/Bits.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import Foundation
1212
import TSCBasic
1313

14-
@available(*, deprecated, message: "moved to swift-driver")
1514
struct Bits: RandomAccessCollection {
1615
var buffer: ByteString
1716

Sources/TSCUtility/Bitstream.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import Foundation
1212

1313
/// Represents the contents of a file encoded using the
1414
/// [LLVM bitstream container format](https://llvm.org/docs/BitCodeFormat.html#bitstream-container-format)
15-
@available(*, deprecated, message: "moved to swift-driver")
1615
public struct Bitcode {
1716
public let signature: Signature
1817
public let elements: [BitcodeElement]
1918
public let blockInfo: [UInt64: BlockInfo]
2019
}
2120

2221
/// A non-owning view of a bitcode element.
23-
@available(*, deprecated, message: "moved to swift-driver")
2422
public enum BitcodeElement {
2523
public struct Block {
2624
public var id: UInt64
@@ -49,7 +47,6 @@ public enum BitcodeElement {
4947
case record(Record)
5048
}
5149

52-
@available(*, deprecated, message: "moved to swift-driver")
5350
extension BitcodeElement.Record.Payload: CustomStringConvertible {
5451
public var description: String {
5552
switch self {
@@ -65,14 +62,12 @@ extension BitcodeElement.Record.Payload: CustomStringConvertible {
6562
}
6663
}
6764

68-
@available(*, deprecated, message: "moved to swift-driver")
6965
public struct BlockInfo {
7066
public var name: String = ""
7167
public var recordNames: [UInt64: String] = [:]
7268
}
7369

7470
extension Bitcode {
75-
@available(*, deprecated, message: "moved to swift-driver")
7671
public struct Signature: Equatable {
7772
private var value: UInt32
7873

@@ -93,7 +88,6 @@ extension Bitcode {
9388
}
9489

9590
/// A visitor which receives callbacks while reading a bitstream.
96-
@available(*, deprecated, message: "moved to swift-driver")
9791
public protocol BitstreamVisitor {
9892
/// Customization point to validate a bitstream's signature or "magic number".
9993
func validate(signature: Bitcode.Signature) throws
@@ -107,14 +101,12 @@ public protocol BitstreamVisitor {
107101
}
108102

109103
/// A top-level namespace for all bitstream-related structures.
110-
@available(*, deprecated, message: "moved to swift-driver")
111104
public enum Bitstream {}
112105

113106
extension Bitstream {
114107
/// An `Abbreviation` represents the encoding definition for a user-defined
115108
/// record. An `Abbreviation` is the primary form of compression available in
116109
/// a bitstream file.
117-
@available(*, deprecated, message: "moved to swift-driver")
118110
public struct Abbreviation {
119111
public enum Operand {
120112
/// A literal value (emitted as a VBR8 field).
@@ -182,7 +174,6 @@ extension Bitstream {
182174
/// a name is given to a block or record with `blockName` or
183175
/// `setRecordName`, debugging tools like `llvm-bcanalyzer` can be used to
184176
/// introspect the structure of blocks and records in the bitstream file.
185-
@available(*, deprecated, message: "moved to swift-driver")
186177
public enum BlockInfoCode: UInt8 {
187178
/// Indicates which block ID is being described.
188179
case setBID = 1
@@ -212,7 +203,6 @@ extension Bitstream {
212203
/// static let diagnostics = Self.firstApplicationID + 1
213204
/// }
214205
/// ```
215-
@available(*, deprecated, message: "moved to swift-driver")
216206
public struct BlockID: RawRepresentable, Equatable, Hashable, Comparable, Identifiable {
217207
public var rawValue: UInt8
218208

@@ -250,7 +240,6 @@ extension Bitstream {
250240
/// abbreviation defined by `BitstreamWriter`. Always use
251241
/// `BitstreamWriter.defineBlockInfoAbbreviation(_:_:)`
252242
/// to register abbreviations.
253-
@available(*, deprecated, message: "moved to swift-driver")
254243
public struct AbbreviationID: RawRepresentable, Equatable, Hashable, Comparable, Identifiable {
255244
public var rawValue: UInt64
256245

Sources/TSCUtility/BitstreamReader.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import TSCBasic
1414
extension Bitcode {
1515
/// Traverse a bitstream using the specified `visitor`, which will receive
1616
/// callbacks when blocks and records are encountered.
17-
@available(*, deprecated, message: "moved to swift-driver")
1817
public static func read<Visitor: BitstreamVisitor>(bytes: ByteString, using visitor: inout Visitor) throws {
1918
precondition(bytes.count > 4)
2019
var reader = BitstreamReader(buffer: bytes)
@@ -27,12 +26,10 @@ extension Bitcode {
2726
}
2827

2928
private extension Bits.Cursor {
30-
@available(*, deprecated, message: "moved to swift-driver")
3129
enum BitcodeError: Swift.Error {
3230
case vbrOverflow
3331
}
3432

35-
@available(*, deprecated, message: "moved to swift-driver")
3633
mutating func readVBR(_ width: Int) throws -> UInt64 {
3734
precondition(width > 1)
3835
let testBit = UInt64(1 << (width &- 1))
@@ -52,7 +49,6 @@ private extension Bits.Cursor {
5249
}
5350
}
5451

55-
@available(*, deprecated, message: "moved to swift-driver")
5652
private struct BitstreamReader {
5753
enum Error: Swift.Error {
5854
case invalidAbbrev

Sources/TSCUtility/BitstreamWriter.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
///
9191
/// The higher-level APIs will automatically ensure that `BitstreamWriter.data`
9292
/// is valid. Once serialization has completed, simply emit this data to a file.
93-
@available(*, deprecated, message: "moved to swift-driver")
9493
public final class BitstreamWriter {
9594
/// The buffer of data being written to.
9695
private(set) public var data: [UInt8]
@@ -160,7 +159,6 @@ public final class BitstreamWriter {
160159

161160
extension BitstreamWriter {
162161
/// Writes the provided UInt32 to the data stream directly.
163-
@available(*, deprecated, message: "moved to swift-driver")
164162
public func write(_ int: UInt32) {
165163
let index = data.count
166164

@@ -179,7 +177,6 @@ extension BitstreamWriter {
179177
/// - int: The integer containing the bits you'd like to write
180178
/// - width: The number of low-bits of the integer you're writing to the
181179
/// buffer
182-
@available(*, deprecated, message: "moved to swift-driver")
183180
public func writeVBR<IntType>(_ int: IntType, width: UInt8)
184181
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
185182
{
@@ -202,7 +199,6 @@ extension BitstreamWriter {
202199
/// - int: The integer containing the bits you'd like to write
203200
/// - width: The number of low-bits of the integer you're writing to the
204201
/// buffer
205-
@available(*, deprecated, message: "moved to swift-driver")
206202
public func write<IntType>(_ int: IntType, width: UInt8)
207203
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
208204
{
@@ -249,7 +245,6 @@ extension BitstreamWriter {
249245
currentBit = (currentBit + width) & 31
250246
}
251247

252-
@available(*, deprecated, message: "moved to swift-driver")
253248
public func alignIfNeeded() {
254249
guard currentBit > 0 else { return }
255250
write(currentValue)
@@ -259,13 +254,11 @@ extension BitstreamWriter {
259254
}
260255

261256
/// Writes a Bool as a 1-bit integer value.
262-
@available(*, deprecated, message: "moved to swift-driver")
263257
public func write(_ bool: Bool) {
264258
write(bool ? 1 as UInt : 0, width: 1)
265259
}
266260

267261
/// Writes the provided BitCode Abbrev operand to the stream.
268-
@available(*, deprecated, message: "moved to swift-driver")
269262
public func write(_ abbrevOp: Bitstream.Abbreviation.Operand) {
270263
write(abbrevOp.isLiteral) // the Literal bit.
271264
switch abbrevOp {
@@ -295,21 +288,18 @@ extension BitstreamWriter {
295288
}
296289

297290
/// Writes the specified abbreviaion value to the stream, as a 32-bit quantity.
298-
@available(*, deprecated, message: "moved to swift-driver")
299291
public func writeCode(_ code: Bitstream.AbbreviationID) {
300292
writeCode(code.rawValue)
301293
}
302294

303295
/// Writes the specified Code value to the stream, as a 32-bit quantity.
304-
@available(*, deprecated, message: "moved to swift-driver")
305296
public func writeCode<IntType>(_ code: IntType)
306297
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
307298
{
308299
write(code, width: codeBitWidth)
309300
}
310301

311302
/// Writes an ASCII character to the stream, as an 8-bit ascii value.
312-
@available(*, deprecated, message: "moved to swift-driver")
313303
public func writeASCII(_ character: Character) {
314304
precondition(character.unicodeScalars.count == 1, "character is not ASCII")
315305
let c = UInt8(ascii: character.unicodeScalars.first!)
@@ -322,7 +312,6 @@ extension BitstreamWriter {
322312
extension BitstreamWriter {
323313
/// Defines an abbreviation and returns the unique identifier for that
324314
/// abbreviation.
325-
@available(*, deprecated, message: "moved to swift-driver")
326315
public func defineAbbreviation(_ abbrev: Bitstream.Abbreviation) -> Bitstream.AbbreviationID {
327316
encodeAbbreviation(abbrev)
328317
currentAbbreviations.append(abbrev)
@@ -332,7 +321,6 @@ extension BitstreamWriter {
332321
}
333322

334323
/// Encodes the definition of an abbreviation to the stream.
335-
@available(*, deprecated, message: "moved to swift-driver")
336324
private func encodeAbbreviation(_ abbrev: Bitstream.Abbreviation) {
337325
writeCode(.defineAbbreviation)
338326
writeVBR(UInt(abbrev.operands.count), width: 5)
@@ -345,7 +333,6 @@ extension BitstreamWriter {
345333
// MARK: Writing Records
346334

347335
extension BitstreamWriter {
348-
@available(*, deprecated, message: "moved to swift-driver")
349336
public struct RecordBuffer {
350337
private(set) var values = [UInt32]()
351338

@@ -389,7 +376,6 @@ extension BitstreamWriter {
389376
}
390377

391378
/// Writes an unabbreviated record to the stream.
392-
@available(*, deprecated, message: "moved to swift-driver")
393379
public func writeRecord<CodeType>(_ code: CodeType, _ composeRecord: (inout RecordBuffer) -> Void)
394380
where CodeType: RawRepresentable, CodeType.RawValue == UInt8
395381
{
@@ -406,7 +392,6 @@ extension BitstreamWriter {
406392
/// Writes a record with the provided abbreviation ID and record contents.
407393
/// Optionally, emits the provided blob if the abbreviation referenced
408394
/// by that ID requires it.
409-
@available(*, deprecated, message: "moved to swift-driver")
410395
public func writeRecord(
411396
_ abbrevID: Bitstream.AbbreviationID,
412397
_ composeRecord: (inout RecordBuffer) -> Void,
@@ -470,14 +455,12 @@ extension BitstreamWriter {
470455
/// '0' .. '9' --- 52 .. 61
471456
/// '.' --- 62
472457
/// '_' --- 63
473-
@available(*, deprecated, message: "moved to swift-driver")
474458
private static let char6Map =
475459
Array(zip("abcdefghijklmnopqrstuvwxyz" +
476460
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
477461
"0123456789._", (0 as UInt)...))
478462

479463
/// Writes a char6-encoded value.
480-
@available(*, deprecated, message: "moved to swift-driver")
481464
public func writeChar6<IntType>(_ value: IntType)
482465
where IntType: UnsignedInteger & ExpressibleByIntegerLiteral
483466
{
@@ -489,7 +472,6 @@ extension BitstreamWriter {
489472
}
490473

491474
/// Writes a value with the provided abbreviation encoding.
492-
@available(*, deprecated, message: "moved to swift-driver")
493475
public func writeAbbrevField(_ op: Bitstream.Abbreviation.Operand, value: UInt32) {
494476
switch op {
495477
case .literal(let literalValue):
@@ -510,7 +492,6 @@ extension BitstreamWriter {
510492

511493
/// Writes a block, beginning with the provided block code and the
512494
/// abbreviation width
513-
@available(*, deprecated, message: "moved to swift-driver")
514495
public func writeBlock(
515496
_ blockID: Bitstream.BlockID,
516497
newAbbrevWidth: UInt8? = nil,
@@ -521,7 +502,6 @@ extension BitstreamWriter {
521502
endBlock()
522503
}
523504

524-
@available(*, deprecated, message: "moved to swift-driver")
525505
public func writeBlob<S>(_ bytes: S, includeSize: Bool = true)
526506
where S: Collection, S.Element == UInt8
527507
{
@@ -547,7 +527,6 @@ extension BitstreamWriter {
547527

548528
/// Writes the blockinfo block and allows emitting abbreviations
549529
/// and records in it.
550-
@available(*, deprecated, message: "moved to swift-driver")
551530
public func writeBlockInfoBlock(emitRecords: () -> Void) {
552531
writeBlock(.blockInfo, newAbbrevWidth: 2) {
553532
currentBlockID = nil
@@ -566,7 +545,6 @@ extension BitstreamWriter {
566545
/// - blockID: The ID of the block to emit.
567546
/// - abbreviationBitWidth: The width of the largest abbreviation ID in this block.
568547
/// - defineSubBlock: A closure that is called to define the contents of the new block.
569-
@available(*, deprecated, message: "moved to swift-driver")
570548
public func withSubBlock(
571549
_ blockID: Bitstream.BlockID,
572550
abbreviationBitWidth: UInt8? = nil,
@@ -588,7 +566,6 @@ extension BitstreamWriter {
588566
/// - Parameters:
589567
/// - blockID: The ID of the block to emit.
590568
/// - abbreviationBitWidth: The width of the largest abbreviation ID in this block.
591-
@available(*, deprecated, message: "moved to swift-driver")
592569
public func enterSubblock(
593570
_ blockID: Bitstream.BlockID,
594571
abbreviationBitWidth: UInt8? = nil
@@ -622,7 +599,6 @@ extension BitstreamWriter {
622599
}
623600

624601
/// Marks the end of a new block record.
625-
@available(*, deprecated, message: "moved to swift-driver")
626602
public func endBlock() {
627603
guard let block = blockScope.popLast() else {
628604
fatalError("endBlock() called with no block registered")
@@ -645,7 +621,6 @@ extension BitstreamWriter {
645621

646622
/// Defines an abbreviation within the blockinfo block for the provided
647623
/// block ID.
648-
@available(*, deprecated, message: "moved to swift-driver")
649624
public func defineBlockInfoAbbreviation(
650625
_ blockID: Bitstream.BlockID,
651626
_ abbrev: Bitstream.Abbreviation
@@ -659,7 +634,6 @@ extension BitstreamWriter {
659634
}
660635

661636

662-
@available(*, deprecated, message: "moved to swift-driver")
663637
private func overwriteBytes(_ int: UInt32, byteIndex: Int) {
664638
let i = int.littleEndian
665639
data.withUnsafeMutableBytes { ptr in
@@ -669,15 +643,13 @@ extension BitstreamWriter {
669643

670644
/// Gets the BlockInfo for the provided ID or creates it if it hasn't been
671645
/// created already.
672-
@available(*, deprecated, message: "moved to swift-driver")
673646
private func getOrCreateBlockInfo(_ id: UInt8) -> BlockInfo {
674647
if let blockInfo = blockInfoRecords[id] { return blockInfo }
675648
let info = BlockInfo()
676649
blockInfoRecords[id] = info
677650
return info
678651
}
679652

680-
@available(*, deprecated, message: "moved to swift-driver")
681653
private func `switch`(to blockID: Bitstream.BlockID) {
682654
if currentBlockID == blockID { return }
683655
writeRecord(Bitstream.BlockInfoCode.setBID) {

0 commit comments

Comments
 (0)