Skip to content

Commit b9fb6b6

Browse files
[llvm] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) (llvm#115681)
Note that PointerUnion::{is,get,dyn_cast} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T>
1 parent d893c5a commit b9fb6b6

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

llvm/include/llvm/IR/DebugProgramInstruction.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -371,29 +371,29 @@ class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
371371
return I == RHS.I;
372372
}
373373
const Value *operator*() const {
374-
ValueAsMetadata *VAM = I.is<ValueAsMetadata *>()
375-
? I.get<ValueAsMetadata *>()
376-
: *I.get<ValueAsMetadata **>();
374+
ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
375+
? cast<ValueAsMetadata *>(I)
376+
: *cast<ValueAsMetadata **>(I);
377377
return VAM->getValue();
378378
};
379379
Value *operator*() {
380-
ValueAsMetadata *VAM = I.is<ValueAsMetadata *>()
381-
? I.get<ValueAsMetadata *>()
382-
: *I.get<ValueAsMetadata **>();
380+
ValueAsMetadata *VAM = isa<ValueAsMetadata *>(I)
381+
? cast<ValueAsMetadata *>(I)
382+
: *cast<ValueAsMetadata **>(I);
383383
return VAM->getValue();
384384
}
385385
location_op_iterator &operator++() {
386-
if (I.is<ValueAsMetadata *>())
387-
I = I.get<ValueAsMetadata *>() + 1;
386+
if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
387+
I = VAM + 1;
388388
else
389-
I = I.get<ValueAsMetadata **>() + 1;
389+
I = cast<ValueAsMetadata **>(I) + 1;
390390
return *this;
391391
}
392392
location_op_iterator &operator--() {
393-
if (I.is<ValueAsMetadata *>())
394-
I = I.get<ValueAsMetadata *>() - 1;
393+
if (auto *VAM = dyn_cast<ValueAsMetadata *>(I))
394+
I = VAM - 1;
395395
else
396-
I = I.get<ValueAsMetadata **>() - 1;
396+
I = cast<ValueAsMetadata **>(I) - 1;
397397
return *this;
398398
}
399399
};

llvm/utils/TableGen/GlobalISelEmitter.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,9 +2118,9 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
21182118
return failedImport(
21192119
"Cannot infer register class for SUBREG_TO_REG operand #0");
21202120
MatchedRC = *MaybeRegClass;
2121-
} else if (MatchedRC.get<const Record *>()->isSubClassOf("RegisterOperand"))
2122-
MatchedRC = MatchedRC.get<const Record *>()->getValueAsDef("RegClass");
2123-
else if (!MatchedRC.get<const Record *>()->isSubClassOf("RegisterClass"))
2121+
} else if (cast<const Record *>(MatchedRC)->isSubClassOf("RegisterOperand"))
2122+
MatchedRC = cast<const Record *>(MatchedRC)->getValueAsDef("RegClass");
2123+
else if (!cast<const Record *>(MatchedRC)->isSubClassOf("RegisterClass"))
21242124
return failedImport("Dst MI def isn't a register class" + to_string(Dst));
21252125

21262126
OperandMatcher &OM = InsnMatcher.getOperand(OpIdx);
@@ -2130,10 +2130,10 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
21302130
// GIM_CheckIsSameOperand predicates by the defineOperand method.
21312131
OM.setSymbolicName(getMangledRootDefName(DstIOperand.Name));
21322132
M.defineOperand(OM.getSymbolicName(), OM);
2133-
if (MatchedRC.is<const Record *>())
2134-
MatchedRC = &Target.getRegisterClass(MatchedRC.get<const Record *>());
2133+
if (auto *R = dyn_cast<const Record *>(MatchedRC))
2134+
MatchedRC = &Target.getRegisterClass(R);
21352135
OM.addPredicate<RegisterBankOperandMatcher>(
2136-
*MatchedRC.get<const CodeGenRegisterClass *>());
2136+
*cast<const CodeGenRegisterClass *>(MatchedRC));
21372137
++OpIdx;
21382138
}
21392139

0 commit comments

Comments
 (0)