Skip to content

Commit e24c466

Browse files
lukaszgotszaldinteligcbot
authored andcommitted
refactor asserts in GenXCategory.cpp
1 parent 316cd8b commit e24c466

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXCategory.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ namespace {
276276

277277
private:
278278
void validate() const {
279-
IGC_ASSERT((ShiftedMask_ % 2 == 1 || CurCat_ == RegCategory::NUMCATEGORIES) &&
280-
"invalid state");
279+
IGC_ASSERT_MESSAGE((ShiftedMask_ % 2 == 1 || CurCat_ == RegCategory::NUMCATEGORIES),
280+
"invalid state");
281281
}
282282
};
283283

@@ -341,8 +341,10 @@ namespace {
341341
// When there's no real category uses (real is anything but NONE)
342342
// behavior is undefined.
343343
unsigned getMostUsedCat() const {
344-
IGC_ASSERT(!empty() && !allHaveCat(RegCategory::NONE) &&
345-
"works only for cases when there are uses with real categories");
344+
IGC_ASSERT_MESSAGE(!empty(),
345+
"works only for cases when there are uses with real categories");
346+
IGC_ASSERT_MESSAGE(!allHaveCat(RegCategory::NONE),
347+
"works only for cases when there are uses with real categories");
346348
return MostUsedCat_;
347349
}
348350

@@ -356,7 +358,7 @@ namespace {
356358
Conv->insertAfter(Inst);
357359
Conv->setDebugLoc(Inst->getDebugLoc());
358360
} else {
359-
IGC_ASSERT(isa<Argument>(Def) && "must be an argument if not an instruction");
361+
IGC_ASSERT_MESSAGE(isa<Argument>(Def), "must be an argument if not an instruction");
360362
// Original value is a function argument. Insert at the start of the
361363
// function.
362364
Conv->insertBefore(&*Func->begin()->begin());
@@ -652,7 +654,7 @@ bool GenXCategory::processValue(Value *V)
652654
// The "no categories at all" case can only happen for a value that is
653655
// defined by a function argument or a phi node and used only in phi
654656
// nodes or subroutine call args.
655-
IGC_ASSERT((isa<Argument>(V) || isa<PHINode>(V)) && "no register category");
657+
IGC_ASSERT_MESSAGE((isa<Argument>(V) || isa<PHINode>(V)), "no register category");
656658
return false;
657659
}
658660
// Value defined with a category but only used in phi nodes.
@@ -684,7 +686,7 @@ bool GenXCategory::processValue(Value *V)
684686
}
685687
else
686688
Conv = Convs[UseInfo.Cat];
687-
IGC_ASSERT(Conv && "must have such conversion");
689+
IGC_ASSERT_MESSAGE(Conv, "must have such conversion");
688690
UseInfo.user->setOperand(UseInfo.OperandNum, Conv);
689691
}
690692
}
@@ -707,7 +709,8 @@ bool GenXCategory::processValue(Value *V)
707709
*/
708710
Instruction *GenXCategory::createConversion(Value *V, unsigned Cat)
709711
{
710-
IGC_ASSERT(V->getType()->getScalarType()->isIntegerTy() && "createConversion expects int type");
712+
IGC_ASSERT_MESSAGE(V->getType()->getScalarType()->isIntegerTy(),
713+
"createConversion expects int type");
711714
if (Cat == RegCategory::ADDRESS) {
712715
Value *Input = V;
713716
int Offset = 0;
@@ -893,9 +896,9 @@ CategoryAndAlignment GenXCategory::getCategoryAndAlignmentForDef(Value *V) const
893896
unsigned GenXCategory::getCategoryForInlasmConstraintedOp(CallInst *CI,
894897
unsigned ArgNo,
895898
bool IsOutput) const {
896-
IGC_ASSERT(CI->isInlineAsm() && "Inline asm expected");
899+
IGC_ASSERT_MESSAGE(CI->isInlineAsm(), "Inline asm expected");
897900
InlineAsm *IA = dyn_cast<InlineAsm>(IGCLLVM::getCalledValue(CI));
898-
IGC_ASSERT(!IA->getConstraintString().empty() && "Here should be constraints");
901+
IGC_ASSERT_MESSAGE(!IA->getConstraintString().empty(), "Here should be constraints");
899902

900903
auto ConstraintsInfo = genx::getGenXInlineAsmInfo(CI);
901904

0 commit comments

Comments
 (0)