[llvm] [X86] Support APX CMOV/CFCMOV instructions (PR #82592)
Shengchen Kan via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 3 23:41:20 PST 2024
================
@@ -13,46 +13,72 @@
// CMOV instructions.
-let isCodeGenOnly = 1, ForceDisassemble = 1 in {
-let Uses = [EFLAGS], Predicates = [HasCMOV], Constraints = "$src1 = $dst",
- isCommutable = 1, SchedRW = [WriteCMOV] in {
- def CMOV16rr
- : I<0x40, MRMSrcRegCC, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, ccode:$cond),
- "cmov${cond}{w}\t{$src2, $dst|$dst, $src2}",
- [(set GR16:$dst,
- (X86cmov GR16:$src1, GR16:$src2, timm:$cond, EFLAGS))]>,
- TB, OpSize16;
- def CMOV32rr
- : I<0x40, MRMSrcRegCC, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, ccode:$cond),
- "cmov${cond}{l}\t{$src2, $dst|$dst, $src2}",
- [(set GR32:$dst,
- (X86cmov GR32:$src1, GR32:$src2, timm:$cond, EFLAGS))]>,
- TB, OpSize32;
- def CMOV64rr
- :RI<0x40, MRMSrcRegCC, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, ccode:$cond),
- "cmov${cond}{q}\t{$src2, $dst|$dst, $src2}",
- [(set GR64:$dst,
- (X86cmov GR64:$src1, GR64:$src2, timm:$cond, EFLAGS))]>, TB;
+multiclass Cmov<X86TypeInfo t, string args, bit ndd = 0, string suffix = ""> {
+let isCommutable = 1, SchedRW = [WriteCMOV] in
+ def rr#suffix : ITy<0x40, MRMSrcRegCC, t, (outs t.RegClass:$dst),
+ (ins t.RegClass:$src1, t.RegClass:$src2, ccode:$cond),
+ "cmov${cond}", args,
+ [(set t.RegClass:$dst, (X86cmov t.RegClass:$src1,
+ t.RegClass:$src2, timm:$cond, EFLAGS))]>, UseEFLAGS, NDD<ndd>;
+let SchedRW = [WriteCMOV.Folded, WriteCMOV.ReadAfterFold] in
+ def rm#suffix : ITy<0x40, MRMSrcMemCC, t, (outs t.RegClass:$dst),
+ (ins t.RegClass:$src1, t.MemOperand:$src2, ccode:$cond),
+ "cmov${cond}", args,
+ [(set t.RegClass:$dst, (X86cmov t.RegClass:$src1,
+ (t.LoadNode addr:$src2), timm:$cond, EFLAGS))]>, UseEFLAGS, NDD<ndd>;
+}
+
+multiclass Cfcmov<X86TypeInfo t> {
+let isCommutable = 1, SchedRW = [WriteCMOV] in {
+let Predicates = [HasCMOV, HasCF, In64BitMode] in {
+ def rr : ITy<0x40, MRMSrcRegCC, t, (outs t.RegClass:$dst),
+ (ins t.RegClass:$src1, ccode:$cond),
+ "cfcmov${cond}", unaryop_ndd_args,
+ [(set t.RegClass:$dst, (X86cmov 0,
+ t.RegClass:$src1, timm:$cond, EFLAGS))]>, UseEFLAGS, EVEX, T_MAP4;
+ def rr_REV : ITy<0x40, MRMDestRegCC, t, (outs t.RegClass:$dst),
+ (ins t.RegClass:$src1, ccode:$cond),
+ "cfcmov${cond}", unaryop_ndd_args, []>, UseEFLAGS, NF;
+}
+let Predicates = [HasCMOV, HasCF, HasNDD, In64BitMode] in
+ def rr_ND : ITy<0x40, MRMSrcRegCC, t, (outs t.RegClass:$dst),
+ (ins t.RegClass:$src1, t.RegClass:$src2, ccode:$cond),
+ "cfcmov${cond}", binop_ndd_args, []>, UseEFLAGS, NDD<1>, NF;
}
+let SchedRW = [WriteCMOV.Folded, WriteCMOV.ReadAfterFold] in {
----------------
KanRobert wrote:
The SchedRW is incorrect for CFCMOVmr
https://github.com/llvm/llvm-project/pull/82592
More information about the llvm-commits
mailing list