Skip to content

Commit 8232cba

Browse files
authored
Merge pull request #67285 from etcwilde/ewilde/migrating-llvm-apis
[NFC] Migrating LLVM API usage on main
2 parents 400d3d1 + 83b044f commit 8232cba

File tree

10 files changed

+29
-30
lines changed

10 files changed

+29
-30
lines changed

include/swift/Basic/APIntMap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ struct WidthPreservingAPIntDenseMapInfo {
3131
// for the value, then use a parser that always produces values with
3232
// minimal bit-widths so that we don't get a conflict.
3333
static inline APInt getEmptyKey() {
34-
return APInt::getAllOnesValue(/*bitwidth*/2);
34+
return APInt::getAllOnes(/*bitwidth*/2);
3535
}
3636
static inline APInt getTombstoneKey() {
37-
return APInt::getAllOnesValue(/*bitwidth*/3);
37+
return APInt::getAllOnes(/*bitwidth*/3);
3838
}
3939

4040
static unsigned getHashValue(const APInt &Key) {

include/swift/Basic/ClusteredBitVector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class ClusteredBitVector {
127127
v = v.zext(v.getBitWidth() + numBits);
128128
return;
129129
}
130-
Bits = APInt::getNullValue(numBits);
130+
Bits = APInt::getZero(numBits);
131131
}
132132

133133
/// Extend the vector out to the given length with clear bits.
@@ -148,7 +148,7 @@ class ClusteredBitVector {
148148
v.setBitsFrom(w);
149149
return;
150150
}
151-
Bits = APInt::getAllOnesValue(numBits);
151+
Bits = APInt::getAllOnes(numBits);
152152
return;
153153
}
154154

@@ -268,7 +268,7 @@ class ClusteredBitVector {
268268
if (numBits == 0) {
269269
return ClusteredBitVector();
270270
}
271-
auto vec = APInt::getNullValue(numBits);
271+
auto vec = APInt::getZero(numBits);
272272
if (value) {
273273
vec.flipAllBits();
274274
}

lib/AST/Expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,12 +1114,12 @@ APInt BuiltinIntegerWidth::parse(StringRef text, unsigned radix, bool negate,
11141114
// Now we can safely negate.
11151115
if (negate) {
11161116
value = -value;
1117-
assert(value.isNegative() || value.isNullValue());
1117+
assert(value.isNegative() || value.isZero());
11181118
}
11191119

11201120
// Truncate down to the minimum number of bits required to express
11211121
// this value exactly.
1122-
auto requiredBits = value.getMinSignedBits();
1122+
auto requiredBits = value.getSignificantBits();
11231123
if (value.getBitWidth() > requiredBits)
11241124
value = value.trunc(requiredBits);
11251125

lib/IDE/ModuleInterfacePrinting.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,10 @@ void swift::ide::printModuleInterface(
576576

577577
// If we're supposed to visit submodules, add them now.
578578
if (TraversalOptions & ModuleTraversal::VisitSubmodules) {
579-
for (auto Sub = CM->submodule_begin(), SubEnd = CM->submodule_end();
580-
Sub != SubEnd; ++Sub) {
581-
if (Visited.insert(*Sub).second)
582-
Worklist.push_back(*Sub);
579+
for (clang::Module * submodule: CM->submodules()) {
580+
if (Visited.insert(submodule).second) {
581+
Worklist.push_back(submodule);
582+
}
583583
}
584584
}
585585
}
@@ -593,9 +593,8 @@ void swift::ide::printModuleInterface(
593593
llvm::SmallPtrSet<const clang::Module *, 16> NoImportSubModules;
594594
if (TargetClangMod) {
595595
// Assume all submodules are missing.
596-
for (auto It = TargetClangMod->submodule_begin();
597-
It != TargetClangMod->submodule_end(); ++It) {
598-
NoImportSubModules.insert(*It);
596+
for (clang::Module *submodule: TargetClangMod->submodules()) {
597+
NoImportSubModules.insert(submodule);
599598
}
600599
}
601600
llvm::StringMap<std::vector<Decl*>> FileRangedDecls;

lib/IRGen/BitPatternBuilder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class BitPatternBuilder {
108108
assert(numBits % 8 == 0);
109109
if (numBits) {
110110
Size += numBits;
111-
Elements.push_back(APInt::getAllOnesValue(numBits));
111+
Elements.push_back(APInt::getAllOnes(numBits));
112112
}
113113
}
114114

@@ -119,7 +119,7 @@ class BitPatternBuilder {
119119
assert(numBits % 8 == 0);
120120
if (numBits) {
121121
Size += numBits;
122-
Elements.push_back(APInt::getNullValue(numBits));
122+
Elements.push_back(APInt::getZero(numBits));
123123
}
124124
}
125125

@@ -150,7 +150,7 @@ class BitPatternBuilder {
150150
if (Size == 0) {
151151
return llvm::Optional<APInt>();
152152
}
153-
auto result = APInt::getNullValue(Size);
153+
auto result = APInt::getZero(Size);
154154
unsigned offset = 0;
155155
for (const auto &e : Elements) {
156156
unsigned index = offset;

lib/IRGen/EnumPayload.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static APInt createElementMask(const llvm::DataLayout &DL,
111111

112112
// Pad the valueMask so that it can be applied to the entire
113113
// payload.
114-
auto mask = APInt::getNullValue(payloadSizeInBits);
114+
auto mask = APInt::getZero(payloadSizeInBits);
115115
auto offset = payloadOffset;
116116
if (DL.isBigEndian()) {
117117
offset = payloadSizeInBits - payloadOffset - elStoreSize;
@@ -348,7 +348,7 @@ EnumPayload::emitCompare(IRGenFunction &IGF,
348348
continue;
349349

350350
// Apply the mask and test.
351-
bool isMasked = !maskPiece.isAllOnesValue();
351+
bool isMasked = !maskPiece.isAllOnes();
352352
auto intTy = llvm::IntegerType::get(IGF.IGM.getLLVMContext(), size);
353353
// Need to bitcast to an integer in order to use 'icmp eq' if the piece
354354
// isn't already an int or pointer, or in order to apply a mask.
@@ -381,7 +381,7 @@ EnumPayload::emitCompare(IRGenFunction &IGF,
381381
void
382382
EnumPayload::emitApplyAndMask(IRGenFunction &IGF, const APInt &mask) {
383383
// Early exit if the mask has no effect.
384-
if (mask.isAllOnesValue())
384+
if (mask.isAllOnes())
385385
return;
386386

387387
auto &DL = IGF.IGM.DataLayout;
@@ -395,7 +395,7 @@ EnumPayload::emitApplyAndMask(IRGenFunction &IGF, const APInt &mask) {
395395
auto maskPiece = maskReader.read(size);
396396

397397
// If this piece is all ones, it has no effect.
398-
if (maskPiece.isAllOnesValue())
398+
if (maskPiece.isAllOnes())
399399
continue;
400400

401401
// If the payload value is vacant, the mask can't change it.
@@ -446,7 +446,7 @@ EnumPayload::emitApplyOrMask(IRGenModule &IGM,
446446

447447
// If the payload value is vacant, or the mask is all ones,
448448
// we can adopt the mask value directly.
449-
if (pv.is<llvm::Type *>() || maskPiece.isAllOnesValue()) {
449+
if (pv.is<llvm::Type *>() || maskPiece.isAllOnes()) {
450450
pv = builder.CreateBitOrPointerCast(maskConstant, payloadTy);
451451
continue;
452452
}

lib/IRGen/FixedTypeInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class FixedTypeInfo : public TypeInfo {
151151

152152
/// Get the bit mask that must be applied before testing an extra inhabitant.
153153
virtual APInt getFixedExtraInhabitantMask(IRGenModule &IGM) const {
154-
return APInt::getAllOnesValue(getFixedSize().getValueInBits());
154+
return APInt::getAllOnes(getFixedSize().getValueInBits());
155155
}
156156

157157
/// Create a constant of the given bit width holding one of the extra

lib/IRGen/GenConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static BuiltinInst *getOffsetSubtract(const TupleExtractInst *TE, SILModule &M)
218218
return nullptr;
219219

220220
auto *overflowFlag = dyn_cast<IntegerLiteralInst>(BI->getArguments()[2]);
221-
if (!overflowFlag || !overflowFlag->getValue().isNullValue())
221+
if (!overflowFlag || !overflowFlag->getValue().isZero())
222222
return nullptr;
223223

224224
return BI;

lib/SILOptimizer/SILCombiner/SILCombinerBuiltinVisitors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ SILInstruction *SILCombiner::optimizeBuiltinCompareEq(BuiltinInst *BI,
3939
// cmp_eq %X, -1 -> xor (cmp_eq %X, 0), -1
4040
if (!NegateResult) {
4141
if (auto *ILOp = dyn_cast<IntegerLiteralInst>(BI->getArguments()[1]))
42-
if (ILOp->getValue().isAllOnesValue()) {
42+
if (ILOp->getValue().isAllOnes()) {
4343
auto X = BI->getArguments()[0];
4444
SILValue One(ILOp);
4545
SILValue Zero(
@@ -731,14 +731,14 @@ SILInstruction *SILCombiner::visitBuiltinInst(BuiltinInst *I) {
731731

732732
return optimizeBitOp(I,
733733
[](APInt &left, const APInt &right) { left &= right; } /* combine */,
734-
[](const APInt &i) -> bool { return i.isAllOnesValue(); } /* isNeutral */,
734+
[](const APInt &i) -> bool { return i.isAllOnes(); } /* isNeutral */,
735735
[](const APInt &i) -> bool { return i.isMinValue(); } /* isZero */,
736736
Builder, this);
737737
case BuiltinValueKind::Or:
738738
return optimizeBitOp(I,
739739
[](APInt &left, const APInt &right) { left |= right; } /* combine */,
740740
[](const APInt &i) -> bool { return i.isMinValue(); } /* isNeutral */,
741-
[](const APInt &i) -> bool { return i.isAllOnesValue(); } /* isZero */,
741+
[](const APInt &i) -> bool { return i.isAllOnes(); } /* isZero */,
742742
Builder, this);
743743
case BuiltinValueKind::Xor:
744744
return optimizeBitOp(I,

lib/SILOptimizer/Transforms/SimplifyCFG.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,13 +1377,13 @@ static SILValue skipInvert(SILValue Cond, bool &Inverted,
13771377
if (BI->getBuiltinInfo().ID == BuiltinValueKind::Xor) {
13781378
// Check if it's a boolean inversion of the condition.
13791379
if (auto *IL = dyn_cast<IntegerLiteralInst>(Args[1])) {
1380-
if (IL->getValue().isAllOnesValue()) {
1380+
if (IL->getValue().isAllOnes()) {
13811381
Cond = Args[0];
13821382
Inverted = !Inverted;
13831383
continue;
13841384
}
13851385
} else if (auto *IL = dyn_cast<IntegerLiteralInst>(Args[0])) {
1386-
if (IL->getValue().isAllOnesValue()) {
1386+
if (IL->getValue().isAllOnes()) {
13871387
Cond = Args[1];
13881388
Inverted = !Inverted;
13891389
continue;
@@ -1513,7 +1513,7 @@ bool SimplifyCFG::simplifyCondBrBlock(CondBranchInst *BI) {
15131513
// Check if it's a boolean inversion of the condition.
15141514
OperandValueArrayRef Args = Xor->getArguments();
15151515
if (auto *IL = dyn_cast<IntegerLiteralInst>(Args[1])) {
1516-
if (IL->getValue().isAllOnesValue()) {
1516+
if (IL->getValue().isAllOnes()) {
15171517
LLVM_DEBUG(llvm::dbgs() << "canonicalize cond_br: " << *BI);
15181518
auto Cond = Args[0];
15191519
SILBuilderWithScope Builder(BI);

0 commit comments

Comments
 (0)