[llvm] e7c9481 - [TableGen] Fix indentation. NFC
Michael Liao via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 09:22:29 PDT 2023
Author: Michael Liao
Date: 2023-06-05T12:22:00-04:00
New Revision: e7c9481b709424f87c62613a92d80b85533b1427
URL: https://github.com/llvm/llvm-project/commit/e7c9481b709424f87c62613a92d80b85533b1427
DIFF: https://github.com/llvm/llvm-project/commit/e7c9481b709424f87c62613a92d80b85533b1427.diff
LOG: [TableGen] Fix indentation. NFC
Added:
Modified:
llvm/lib/TableGen/Record.cpp
Removed:
################################################################################
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index eb7a213675e4b..ac25de1e81b08 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -1026,89 +1026,90 @@ Init *BinOpInit::getListConcat(TypedInit *LHS, Init *RHS) {
assert(isa<ListRecTy>(LHS->getType()) && "First arg must be a list");
// Shortcut for the common case of concatenating two lists.
- if (const ListInit *LHSList = dyn_cast<ListInit>(LHS))
- if (const ListInit *RHSList = dyn_cast<ListInit>(RHS))
- return ConcatListInits(LHSList, RHSList);
- return BinOpInit::get(BinOpInit::LISTCONCAT, LHS, RHS, LHS->getType());
-}
-
-std::optional<bool> BinOpInit::CompareInit(unsigned Opc, Init *LHS, Init *RHS) const {
- // First see if we have two bit, bits, or int.
- IntInit *LHSi = dyn_cast_or_null<IntInit>(
- LHS->convertInitializerTo(IntRecTy::get(getRecordKeeper())));
- IntInit *RHSi = dyn_cast_or_null<IntInit>(
- RHS->convertInitializerTo(IntRecTy::get(getRecordKeeper())));
-
- if (LHSi && RHSi) {
- bool Result;
- switch (Opc) {
- case EQ:
- Result = LHSi->getValue() == RHSi->getValue();
- break;
- case NE:
- Result = LHSi->getValue() != RHSi->getValue();
- break;
- case LE:
- Result = LHSi->getValue() <= RHSi->getValue();
- break;
- case LT:
- Result = LHSi->getValue() < RHSi->getValue();
- break;
- case GE:
- Result = LHSi->getValue() >= RHSi->getValue();
- break;
- case GT:
- Result = LHSi->getValue() > RHSi->getValue();
- break;
- default:
- llvm_unreachable("unhandled comparison");
- }
- return Result;
- }
-
- // Next try strings.
- StringInit *LHSs = dyn_cast<StringInit>(LHS);
- StringInit *RHSs = dyn_cast<StringInit>(RHS);
-
- if (LHSs && RHSs) {
- bool Result;
- switch (Opc) {
- case EQ:
- Result = LHSs->getValue() == RHSs->getValue();
- break;
- case NE:
- Result = LHSs->getValue() != RHSs->getValue();
- break;
- case LE:
- Result = LHSs->getValue() <= RHSs->getValue();
- break;
- case LT:
- Result = LHSs->getValue() < RHSs->getValue();
- break;
- case GE:
- Result = LHSs->getValue() >= RHSs->getValue();
- break;
- case GT:
- Result = LHSs->getValue() > RHSs->getValue();
- break;
- default:
- llvm_unreachable("unhandled comparison");
- }
- return Result;
- }
-
- // Finally, !eq and !ne can be used with records.
- if (Opc == EQ || Opc == NE) {
- DefInit *LHSd = dyn_cast<DefInit>(LHS);
- DefInit *RHSd = dyn_cast<DefInit>(RHS);
- if (LHSd && RHSd)
- return (Opc == EQ) ? LHSd == RHSd : LHSd != RHSd;
- }
-
- return std::nullopt;
-}
-
- Init *BinOpInit::Fold(Record *CurRec) const {
+ if (const ListInit *LHSList = dyn_cast<ListInit>(LHS))
+ if (const ListInit *RHSList = dyn_cast<ListInit>(RHS))
+ return ConcatListInits(LHSList, RHSList);
+ return BinOpInit::get(BinOpInit::LISTCONCAT, LHS, RHS, LHS->getType());
+}
+
+std::optional<bool> BinOpInit::CompareInit(unsigned Opc, Init *LHS,
+ Init *RHS) const {
+ // First see if we have two bit, bits, or int.
+ IntInit *LHSi = dyn_cast_or_null<IntInit>(
+ LHS->convertInitializerTo(IntRecTy::get(getRecordKeeper())));
+ IntInit *RHSi = dyn_cast_or_null<IntInit>(
+ RHS->convertInitializerTo(IntRecTy::get(getRecordKeeper())));
+
+ if (LHSi && RHSi) {
+ bool Result;
+ switch (Opc) {
+ case EQ:
+ Result = LHSi->getValue() == RHSi->getValue();
+ break;
+ case NE:
+ Result = LHSi->getValue() != RHSi->getValue();
+ break;
+ case LE:
+ Result = LHSi->getValue() <= RHSi->getValue();
+ break;
+ case LT:
+ Result = LHSi->getValue() < RHSi->getValue();
+ break;
+ case GE:
+ Result = LHSi->getValue() >= RHSi->getValue();
+ break;
+ case GT:
+ Result = LHSi->getValue() > RHSi->getValue();
+ break;
+ default:
+ llvm_unreachable("unhandled comparison");
+ }
+ return Result;
+ }
+
+ // Next try strings.
+ StringInit *LHSs = dyn_cast<StringInit>(LHS);
+ StringInit *RHSs = dyn_cast<StringInit>(RHS);
+
+ if (LHSs && RHSs) {
+ bool Result;
+ switch (Opc) {
+ case EQ:
+ Result = LHSs->getValue() == RHSs->getValue();
+ break;
+ case NE:
+ Result = LHSs->getValue() != RHSs->getValue();
+ break;
+ case LE:
+ Result = LHSs->getValue() <= RHSs->getValue();
+ break;
+ case LT:
+ Result = LHSs->getValue() < RHSs->getValue();
+ break;
+ case GE:
+ Result = LHSs->getValue() >= RHSs->getValue();
+ break;
+ case GT:
+ Result = LHSs->getValue() > RHSs->getValue();
+ break;
+ default:
+ llvm_unreachable("unhandled comparison");
+ }
+ return Result;
+ }
+
+ // Finally, !eq and !ne can be used with records.
+ if (Opc == EQ || Opc == NE) {
+ DefInit *LHSd = dyn_cast<DefInit>(LHS);
+ DefInit *RHSd = dyn_cast<DefInit>(RHS);
+ if (LHSd && RHSd)
+ return (Opc == EQ) ? LHSd == RHSd : LHSd != RHSd;
+ }
+
+ return std::nullopt;
+}
+
+Init *BinOpInit::Fold(Record *CurRec) const {
switch (getOpcode()) {
case CONCAT: {
DagInit *LHSs = dyn_cast<DagInit>(LHS);
More information about the llvm-commits
mailing list