Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 2e51b76

Browse files
committed
[X86] Move some EVEX->VEX code to a helper function to prepare for a future patch. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316881 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 63745a6 commit 2e51b76

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

lib/Target/X86/X86EvexToVex.cpp

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,38 @@ void EvexToVexInstPass::AddTableEntry(EvexToVexTableType &EvexToVexTable,
132132
EvexToVexTable[EvexOp] = VexOp;
133133
}
134134

135+
static bool usesExtendedRegister(const MachineInstr &MI) {
136+
auto isHiRegIdx = [](unsigned Reg) {
137+
// Check for XMM register with indexes between 16 - 31.
138+
if (Reg >= X86::XMM16 && Reg <= X86::XMM31)
139+
return true;
140+
141+
// Check for YMM register with indexes between 16 - 31.
142+
if (Reg >= X86::YMM16 && Reg <= X86::YMM31)
143+
return true;
144+
145+
return false;
146+
};
147+
148+
// Check that operands are not ZMM regs or
149+
// XMM/YMM regs with hi indexes between 16 - 31.
150+
for (const MachineOperand &MO : MI.explicit_operands()) {
151+
if (!MO.isReg())
152+
continue;
153+
154+
unsigned Reg = MO.getReg();
155+
156+
assert(!(Reg >= X86::ZMM0 && Reg <= X86::ZMM31) &&
157+
"ZMM instructions should not be in the EVEX->VEX tables");
158+
159+
if (isHiRegIdx(Reg))
160+
return true;
161+
}
162+
163+
return false;
164+
}
165+
166+
135167
// For EVEX instructions that can be encoded using VEX encoding
136168
// replace them by the VEX encoding in order to reduce size.
137169
bool EvexToVexInstPass::CompressEvexToVexImpl(MachineInstr &MI) const {
@@ -188,31 +220,8 @@ bool EvexToVexInstPass::CompressEvexToVexImpl(MachineInstr &MI) const {
188220
if (!NewOpc)
189221
return false;
190222

191-
auto isHiRegIdx = [](unsigned Reg) {
192-
// Check for XMM register with indexes between 16 - 31.
193-
if (Reg >= X86::XMM16 && Reg <= X86::XMM31)
194-
return true;
195-
196-
// Check for YMM register with indexes between 16 - 31.
197-
if (Reg >= X86::YMM16 && Reg <= X86::YMM31)
198-
return true;
199-
223+
if (usesExtendedRegister(MI))
200224
return false;
201-
};
202-
203-
// Check that operands are not ZMM regs or
204-
// XMM/YMM regs with hi indexes between 16 - 31.
205-
for (const MachineOperand &MO : MI.explicit_operands()) {
206-
if (!MO.isReg())
207-
continue;
208-
209-
unsigned Reg = MO.getReg();
210-
211-
assert (!(Reg >= X86::ZMM0 && Reg <= X86::ZMM31));
212-
213-
if (isHiRegIdx(Reg))
214-
return false;
215-
}
216225

217226
const MCInstrDesc &MCID = TII->get(NewOpc);
218227
MI.setDesc(MCID);

0 commit comments

Comments
 (0)