From e7c9481b709424f87c62613a92d80b85533b1427 Mon Sep 17 00:00:00 2001 From: Michael Liao Date: Mon, 5 Jun 2023 12:19:58 -0400 Subject: [PATCH] [TableGen] Fix indentation. NFC --- llvm/lib/TableGen/Record.cpp | 167 ++++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 83 deletions(-) diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index eb7a213..ac25de1 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(LHS->getType()) && "First arg must be a list"); // Shortcut for the common case of concatenating two lists. - if (const ListInit *LHSList = dyn_cast(LHS)) - if (const ListInit *RHSList = dyn_cast(RHS)) - return ConcatListInits(LHSList, RHSList); - return BinOpInit::get(BinOpInit::LISTCONCAT, LHS, RHS, LHS->getType()); -} - -std::optional 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( - LHS->convertInitializerTo(IntRecTy::get(getRecordKeeper()))); - IntInit *RHSi = dyn_cast_or_null( - 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(LHS); - StringInit *RHSs = dyn_cast(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(LHS); - DefInit *RHSd = dyn_cast(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(LHS)) + if (const ListInit *RHSList = dyn_cast(RHS)) + return ConcatListInits(LHSList, RHSList); + return BinOpInit::get(BinOpInit::LISTCONCAT, LHS, RHS, LHS->getType()); +} + +std::optional 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( + LHS->convertInitializerTo(IntRecTy::get(getRecordKeeper()))); + IntInit *RHSi = dyn_cast_or_null( + 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(LHS); + StringInit *RHSs = dyn_cast(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(LHS); + DefInit *RHSd = dyn_cast(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(LHS); -- 2.7.4