Skip to content

Commit 3b279bc

Browse files
committed
Add asserts and comments
1 parent 9ebb155 commit 3b279bc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,17 +1182,29 @@ namespace X86II {
11821182
}
11831183
}
11841184

1185+
/// \returns true if the register is a XMM.
11851186
inline bool isXMMReg(unsigned RegNo) {
1187+
assert(X86::XMM15 - X86::XMM0 == 15 &&
1188+
"XMM0-15 registers are not continuous");
1189+
assert(X86::XMM31 - X86::XMM16 == 15 &&
1190+
"XMM16-31 registers are not continuous");
11861191
return (RegNo >= X86::XMM0 && RegNo <= X86::XMM15) ||
11871192
(RegNo >= X86::XMM16 && RegNo <= X86::XMM31);
11881193
}
11891194

1195+
/// \returns true if the register is a YMM.
11901196
inline bool isYMMReg(unsigned RegNo) {
1197+
assert(X86::YMM15 - X86::YMM0 == 15 &&
1198+
"YMM0-15 registers are not continuous");
1199+
assert(X86::YMM31 - X86::YMM16 == 15 &&
1200+
"YMM16-31 registers are not continuous");
11911201
return (RegNo >= X86::YMM0 && RegNo <= X86::YMM15) ||
11921202
(RegNo >= X86::YMM16 && RegNo <= X86::YMM31);
11931203
}
11941204

1205+
/// \returns true if the register is a ZMM.
11951206
inline bool isZMMReg(unsigned RegNo) {
1207+
assert(X86::ZMM31 - X86::ZMM0 == 31 && "ZMM registers are not continuous");
11961208
return RegNo >= X86::ZMM0 && RegNo <= X86::ZMM31;
11971209
}
11981210

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ unsigned X86RegisterInfo::getNumSupportedRegs(const MachineFunction &MF) const {
631631
//
632632
// and try to return the minimum number of registers supported by the target.
633633

634+
assert((X86::R15WH + 1 == X86 ::YMM0) && (X86::YMM15 + 1 == X86::K0) &&
635+
(X86::K6_K7 + 1 == X86::TMMCFG) &&
636+
(X86::TMM7 + 1 == X86::NUM_TARGET_REGS) &&
637+
"Register number may be incorrect");
638+
634639
bool HasAVX = ST.hasAVX();
635640
bool HasAVX512 = ST.hasAVX512();
636641
bool HasAMX = ST.hasAMXTILE();

0 commit comments

Comments
 (0)