Skip to content

Commit 501cfd5

Browse files
[X86] Use static_asserts instead of assert (NFC)
Identified with misc-static-assert.
1 parent fa8fda8 commit 501cfd5

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,33 +1168,34 @@ inline int getMemoryOperandNo(uint64_t TSFlags) {
11681168

11691169
/// \returns true if the register is a XMM.
11701170
inline bool isXMMReg(unsigned RegNo) {
1171-
assert(X86::XMM15 - X86::XMM0 == 15 &&
1172-
"XMM0-15 registers are not continuous");
1173-
assert(X86::XMM31 - X86::XMM16 == 15 &&
1174-
"XMM16-31 registers are not continuous");
1171+
static_assert(X86::XMM15 - X86::XMM0 == 15,
1172+
"XMM0-15 registers are not continuous");
1173+
static_assert(X86::XMM31 - X86::XMM16 == 15,
1174+
"XMM16-31 registers are not continuous");
11751175
return (RegNo >= X86::XMM0 && RegNo <= X86::XMM15) ||
11761176
(RegNo >= X86::XMM16 && RegNo <= X86::XMM31);
11771177
}
11781178

11791179
/// \returns true if the register is a YMM.
11801180
inline bool isYMMReg(unsigned RegNo) {
1181-
assert(X86::YMM15 - X86::YMM0 == 15 &&
1182-
"YMM0-15 registers are not continuous");
1183-
assert(X86::YMM31 - X86::YMM16 == 15 &&
1184-
"YMM16-31 registers are not continuous");
1181+
static_assert(X86::YMM15 - X86::YMM0 == 15,
1182+
"YMM0-15 registers are not continuous");
1183+
static_assert(X86::YMM31 - X86::YMM16 == 15,
1184+
"YMM16-31 registers are not continuous");
11851185
return (RegNo >= X86::YMM0 && RegNo <= X86::YMM15) ||
11861186
(RegNo >= X86::YMM16 && RegNo <= X86::YMM31);
11871187
}
11881188

11891189
/// \returns true if the register is a ZMM.
11901190
inline bool isZMMReg(unsigned RegNo) {
1191-
assert(X86::ZMM31 - X86::ZMM0 == 31 && "ZMM registers are not continuous");
1191+
static_assert(X86::ZMM31 - X86::ZMM0 == 31,
1192+
"ZMM registers are not continuous");
11921193
return RegNo >= X86::ZMM0 && RegNo <= X86::ZMM31;
11931194
}
11941195

11951196
/// \returns true if \p RegNo is an apx extended register.
11961197
inline bool isApxExtendedReg(unsigned RegNo) {
1197-
assert(X86::R31WH - X86::R16 == 95 && "EGPRs are not continuous");
1198+
static_assert(X86::R31WH - X86::R16 == 95, "EGPRs are not continuous");
11981199
return RegNo >= X86::R16 && RegNo <= X86::R31WH;
11991200
}
12001201

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,11 @@ unsigned X86RegisterInfo::getNumSupportedRegs(const MachineFunction &MF) const {
649649
// APX registers (R16-R31)
650650
//
651651
// and try to return the minimum number of registers supported by the target.
652-
assert((X86::R15WH + 1 == X86 ::YMM0) && (X86::YMM15 + 1 == X86::K0) &&
653-
(X86::K6_K7 + 1 == X86::TMMCFG) && (X86::TMM7 + 1 == X86::R16) &&
654-
(X86::R31WH + 1 == X86::NUM_TARGET_REGS) &&
655-
"Register number may be incorrect");
652+
static_assert((X86::R15WH + 1 == X86::YMM0) && (X86::YMM15 + 1 == X86::K0) &&
653+
(X86::K6_K7 + 1 == X86::TMMCFG) &&
654+
(X86::TMM7 + 1 == X86::R16) &&
655+
(X86::R31WH + 1 == X86::NUM_TARGET_REGS),
656+
"Register number may be incorrect");
656657

657658
const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
658659
if (ST.hasEGPR())

0 commit comments

Comments
 (0)