[TableGen] Fix indentation. NFC

This commit is contained in:
Michael Liao 2023-06-05 12:19:58 -04:00
parent 658f23fc46
commit e7c9481b70

View File

@ -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());
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())));
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;
}
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);
// 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;
}
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;
}
// 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;
return std::nullopt;
}
Init *BinOpInit::Fold(Record *CurRec) const {
Init *BinOpInit::Fold(Record *CurRec) const {
switch (getOpcode()) {
case CONCAT: {
DagInit *LHSs = dyn_cast<DagInit>(LHS);