[llvm] [TableGen] Simplify Record type checks. NFC. (PR #197450)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed May 13 06:58:27 PDT 2026
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/197450
None
>From 448e11e36ad808881fceaf41673ad6a5dee0c384 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 13 May 2026 14:33:27 +0100
Subject: [PATCH] [TableGen] Simplify Record type checks. NFC.
---
llvm/lib/TableGen/Record.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 3395d2dd10a1b..91579e5dc2c9a 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -810,7 +810,7 @@ std::string ListInit::getAsString() const {
}
const Init *OpInit::getBit(unsigned Bit) const {
- if (getType() == BitRecTy::get(getRecordKeeper()))
+ if (isa<BitRecTy>(getType()))
return this;
return VarBitInit::get(this, Bit);
}
@@ -2329,7 +2329,7 @@ const RecTy *TypedInit::getFieldType(const StringInit *FieldName) const {
}
const Init *TypedInit::convertInitializerTo(const RecTy *Ty) const {
- if (getType() == Ty || getType()->typeIsA(Ty))
+ if (getType()->typeIsA(Ty))
return this;
if (isa<BitRecTy>(getType()) && isa<BitsRecTy>(Ty) &&
@@ -2358,7 +2358,7 @@ TypedInit::convertInitializerBitRange(ArrayRef<unsigned> Bits) const {
const Init *TypedInit::getCastTo(const RecTy *Ty) const {
// Handle the common case quickly
- if (getType() == Ty || getType()->typeIsA(Ty))
+ if (getType()->typeIsA(Ty))
return this;
if (const Init *Converted = convertInitializerTo(Ty)) {
@@ -2392,7 +2392,7 @@ StringRef VarInit::getName() const {
}
const Init *VarInit::getBit(unsigned Bit) const {
- if (getType() == BitRecTy::get(getRecordKeeper()))
+ if (isa<BitRecTy>(getType()))
return this;
return VarBitInit::get(this, Bit);
}
@@ -2585,7 +2585,7 @@ const FieldInit *FieldInit::get(const Init *R, const StringInit *FN) {
}
const Init *FieldInit::getBit(unsigned Bit) const {
- if (getType() == BitRecTy::get(getRecordKeeper()))
+ if (isa<BitRecTy>(getType()))
return this;
return VarBitInit::get(this, Bit);
}
@@ -2871,7 +2871,7 @@ StringRef RecordVal::getName() const {
}
std::string RecordVal::getPrintType() const {
- if (getType() == StringRecTy::get(getRecordKeeper())) {
+ if (isa<StringRecTy>(getType())) {
if (const auto *StrInit = dyn_cast<StringInit>(Value)) {
if (StrInit->hasCodeFormat())
return "code";
More information about the llvm-commits
mailing list