File tree Expand file tree Collapse file tree 7 files changed +51
-34
lines changed Expand file tree Collapse file tree 7 files changed +51
-34
lines changed Original file line number Diff line number Diff line change 1616#include " llvm/ADT/SmallBitVector.h"
1717#include " llvm/Support/raw_ostream.h"
1818
19- namespace llvm {
19+ namespace swift {
2020
21- inline llvm::raw_ostream &operator <<(llvm::raw_ostream &os,
22- const SmallBitVector &bv) {
23- for (unsigned i = 0 , e = bv.size (); i != e; ++i)
24- os << (bv[i] ? ' 1' : ' 0' );
25- return os;
21+ void printBitsAsArray (llvm::raw_ostream &OS, const llvm::SmallBitVector &bits,
22+ bool bracketed);
23+
24+ inline llvm::raw_ostream &operator <<(llvm::raw_ostream &OS,
25+ const llvm::SmallBitVector &bits) {
26+ printBitsAsArray (OS, bits, /* bracketed=*/ false );
27+ return OS;
2628}
2729
28- } // namespace llvm
30+ void dumpBits (const llvm::SmallBitVector &bits);
31+
32+ } // namespace swift
2933
3034#endif
Original file line number Diff line number Diff line change @@ -29,16 +29,6 @@ class SILFunction;
2929class SILBasicBlock ;
3030class SingleValueInstruction ;
3131
32- void printBitsAsArray (llvm::raw_ostream &OS, const SmallBitVector &bits);
33-
34- inline llvm::raw_ostream &operator <<(llvm::raw_ostream &OS,
35- const SmallBitVector &bits) {
36- printBitsAsArray (OS, bits);
37- return OS;
38- }
39-
40- void dumpBits (const SmallBitVector &bits);
41-
4232// / The MemoryLocations utility provides functions to analyze memory locations.
4333// /
4434// / Memory locations are limited to addresses which are guaranteed to
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ add_swift_host_library(swiftBasic STATIC
6767 Program .cpp
6868 QuotedString.cpp
6969 Sandbox.cpp
70+ SmallBitVector.cpp
7071 SourceLoc.cpp
7172 StableHasher.cpp
7273 Statistic.cpp
Original file line number Diff line number Diff line change 1+ // ===--- SmallBitVector.cpp -----------------------------------------------===//
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+ #include " swift/Basic/SmallBitVector.h"
14+ #include " llvm/Support/Debug.h"
15+
16+ using namespace llvm ;
17+
18+ // / Debug dump a location bit vector.
19+ void swift::printBitsAsArray (raw_ostream &OS, const SmallBitVector &bits,
20+ bool bracketed) {
21+ if (!bracketed) {
22+ for (unsigned i = 0 , e = bits.size (); i != e; ++i)
23+ OS << (bits[i] ? ' 1' : ' 0' );
24+ }
25+ const char *separator = " " ;
26+ OS << ' [' ;
27+ for (int idx = bits.find_first (); idx >= 0 ; idx = bits.find_next (idx)) {
28+ OS << separator << idx;
29+ separator = " ," ;
30+ }
31+ OS << ' ]' ;
32+ }
33+
34+ void swift::dumpBits (const SmallBitVector &bits) { dbgs () << bits << ' \n ' ; }
Original file line number Diff line number Diff line change 1212
1313#define DEBUG_TYPE " bit-dataflow"
1414#include " swift/SIL/BitDataflow.h"
15+ #include " swift/Basic/SmallBitVector.h"
16+ #include " swift/SIL/MemoryLocations.h"
1517#include " swift/SIL/SILBasicBlock.h"
1618#include " swift/SIL/SILFunction.h"
17- #include " swift/SIL/MemoryLocations.h"
1819#include " llvm/Support/raw_ostream.h"
1920
2021using namespace swift ;
Original file line number Diff line number Diff line change 1212
1313#define DEBUG_TYPE " sil-memory-locations"
1414#include " swift/SIL/MemoryLocations.h"
15+ #include " swift/Basic/SmallBitVector.h"
16+ #include " swift/SIL/ApplySite.h"
1517#include " swift/SIL/SILBasicBlock.h"
1618#include " swift/SIL/SILFunction.h"
17- #include " swift/SIL/ApplySite.h"
1819#include " swift/SIL/SILModule.h"
1920#include " llvm/Support/raw_ostream.h"
2021
2122using namespace swift ;
2223
23- // / Debug dump a location bit vector.
24- void swift::printBitsAsArray (llvm::raw_ostream &OS, const SmallBitVector &bits) {
25- const char *separator = " " ;
26- OS << ' [' ;
27- for (int idx = bits.find_first (); idx >= 0 ; idx = bits.find_next (idx)) {
28- OS << separator << idx;
29- separator = " ," ;
30- }
31- OS << ' ]' ;
32- }
33-
34- void swift::dumpBits (const SmallBitVector &bits) {
35- llvm::dbgs () << bits << ' \n ' ;
36- }
37-
3824namespace swift {
3925namespace {
4026
Original file line number Diff line number Diff line change 2020#include " swift/AST/Type.h"
2121#include " swift/Basic/FrozenMultiMap.h"
2222#include " swift/Basic/ImmutablePointerSet.h"
23+ #include " swift/Basic/SmallBitVector.h"
2324#include " swift/SIL/BasicBlockData.h"
2425#include " swift/SIL/BasicBlockDatastructures.h"
2526#include " swift/SIL/DynamicCasts.h"
You can’t perform that action at this time.
0 commit comments