Skip to content

Commit 66922a5

Browse files
committed
[X86][NFC] Simplify the definition of MULX by using class ITy
1 parent 64e6388 commit 66922a5

File tree

1 file changed

+34
-39
lines changed

1 file changed

+34
-39
lines changed

llvm/lib/Target/X86/X86InstrArithmetic.td

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,53 +1135,48 @@ let Predicates = [HasBMI], AddedComplexity = -6 in {
11351135
//===----------------------------------------------------------------------===//
11361136
// MULX Instruction
11371137
//
1138-
multiclass bmi_mulx<string mnemonic, RegisterClass RC, X86MemOperand x86memop,
1139-
X86FoldableSchedWrite sched> {
1140-
let hasSideEffects = 0 in {
1141-
let Predicates = [HasBMI2, NoEGPR] in {
1142-
def rr : I<0xF6, MRMSrcReg, (outs RC:$dst1, RC:$dst2), (ins RC:$src),
1143-
!strconcat(mnemonic, "\t{$src, $dst2, $dst1|$dst1, $dst2, $src}"),
1144-
[]>, T8, XD, VEX, VVVV, Sched<[WriteIMulH, sched]>;
1145-
1138+
multiclass MulX<X86TypeInfo t, X86FoldableSchedWrite sched> {
1139+
defvar mulx_args = "{$src, $dst2, $dst1|$dst1, $dst2, $src}";
1140+
defvar mulx_rm_sched =
1141+
[WriteIMulHLd, sched.Folded,
1142+
// Memory operand.
1143+
ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
1144+
// Implicit read of EDX/RDX
1145+
sched.ReadAfterFold];
1146+
1147+
def rr : ITy<0xF6, MRMSrcReg, t, (outs t.RegClass:$dst1, t.RegClass:$dst2),
1148+
(ins t.RegClass:$src), "mulx", mulx_args, []>, T8, XD, VEX,
1149+
VVVV, Sched<[WriteIMulH, sched]>;
11461150
let mayLoad = 1 in
1147-
def rm : I<0xF6, MRMSrcMem, (outs RC:$dst1, RC:$dst2), (ins x86memop:$src),
1148-
!strconcat(mnemonic, "\t{$src, $dst2, $dst1|$dst1, $dst2, $src}"),
1149-
[]>, T8, XD, VEX, VVVV,
1150-
Sched<[WriteIMulHLd, sched.Folded,
1151-
// Memory operand.
1152-
ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
1153-
// Implicit read of EDX/RDX
1154-
sched.ReadAfterFold]>;
1155-
1151+
def rm : ITy<0xF6, MRMSrcMem, t, (outs t.RegClass:$dst1, t.RegClass:$dst2),
1152+
(ins t.MemOperand:$src), "mulx", mulx_args, []>, T8, XD, VEX,
1153+
VVVV, Sched<mulx_rm_sched>;
1154+
1155+
let Predicates = [In64BitMode] in {
1156+
def rr_EVEX : ITy<0xF6, MRMSrcReg, t,
1157+
(outs t.RegClass:$dst1, t.RegClass:$dst2),
1158+
(ins t.RegClass:$src), "mulx", mulx_args, []>, T8, XD,
1159+
EVEX, VVVV, Sched<[WriteIMulH, sched]>;
1160+
let mayLoad = 1 in
1161+
def rm_EVEX : ITy<0xF6, MRMSrcMem, t,
1162+
(outs t.RegClass:$dst1, t.RegClass:$dst2),
1163+
(ins t.MemOperand:$src), "mulx", mulx_args, []>, T8, XD,
1164+
EVEX, VVVV, Sched<mulx_rm_sched>;
1165+
}
11561166
// Pseudo instructions to be used when the low result isn't used. The
11571167
// instruction is defined to keep the high if both destinations are the same.
1158-
def Hrr : PseudoI<(outs RC:$dst), (ins RC:$src),
1159-
[]>, Sched<[sched]>;
1160-
1168+
def Hrr : PseudoI<(outs t.RegClass:$dst), (ins t.RegClass:$src), []>,
1169+
Sched<[sched]>;
11611170
let mayLoad = 1 in
1162-
def Hrm : PseudoI<(outs RC:$dst), (ins x86memop:$src),
1163-
[]>, Sched<[sched.Folded]>;
1164-
}
1165-
let Predicates = [HasBMI2, HasEGPR, In64BitMode] in
1166-
def rr#_EVEX : I<0xF6, MRMSrcReg, (outs RC:$dst1, RC:$dst2), (ins RC:$src),
1167-
!strconcat(mnemonic, "\t{$src, $dst2, $dst1|$dst1, $dst2, $src}"),
1168-
[]>, T8, XD, EVEX, VVVV, Sched<[WriteIMulH, sched]>;
1169-
let Predicates = [HasBMI2, HasEGPR, In64BitMode], mayLoad = 1 in
1170-
def rm#_EVEX : I<0xF6, MRMSrcMem, (outs RC:$dst1, RC:$dst2), (ins x86memop:$src),
1171-
!strconcat(mnemonic, "\t{$src, $dst2, $dst1|$dst1, $dst2, $src}"),
1172-
[]>, T8, XD, EVEX, VVVV,
1173-
Sched<[WriteIMulHLd, sched.Folded,
1174-
// Memory operand.
1175-
ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
1176-
// Implicit read of EDX/RDX
1177-
sched.ReadAfterFold]>;
1178-
}
1171+
def Hrm : PseudoI<(outs t.RegClass:$dst), (ins t.MemOperand:$src), []>,
1172+
Sched<[sched.Folded]>;
11791173
}
11801174

11811175
let Uses = [EDX] in
1182-
defm MULX32 : bmi_mulx<"mulx{l}", GR32, i32mem, WriteMULX32>;
1176+
defm MULX32 : MulX<Xi32, WriteMULX32>;
1177+
11831178
let Uses = [RDX] in
1184-
defm MULX64 : bmi_mulx<"mulx{q}", GR64, i64mem, WriteMULX64>, REX_W;
1179+
defm MULX64 : MulX<Xi64, WriteMULX64>, REX_W;
11851180

11861181
//===----------------------------------------------------------------------===//
11871182
// ADCX and ADOX Instructions

0 commit comments

Comments
 (0)