//===- X86ReplaceableInstrs.def ----------------------------------*- C++ -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// These are the replaceable SSE instructions. Some of these have Int variants
// that we don't include here. We don't want to replace instructions selected
// by intrinsics.

#define ENTRY(A, B, C) {X86::A, X86::B, X86::C},
static const uint16_t ReplaceableInstrs[][3] = {
// PackedSingle, PackedDouble, PackedInt
ENTRY(MOVAPSmr, MOVAPDmr, MOVDQAmr)
ENTRY(MOVAPSrm, MOVAPDrm, MOVDQArm)
ENTRY(MOVAPSrr, MOVAPDrr, MOVDQArr)
ENTRY(MOVUPSmr, MOVUPDmr, MOVDQUmr)
ENTRY(MOVUPSrm, MOVUPDrm, MOVDQUrm)
ENTRY(MOVLPSmr, MOVLPDmr, MOVPQI2QImr)
ENTRY(MOVSDmr, MOVSDmr, MOVPQI2QImr)
ENTRY(MOVSSmr, MOVSSmr, MOVPDI2DImr)
ENTRY(MOVSDrm, MOVSDrm, MOVQI2PQIrm)
ENTRY(MOVSDrm_alt, MOVSDrm_alt, MOVQI2PQIrm)
ENTRY(MOVSSrm, MOVSSrm, MOVDI2PDIrm)
ENTRY(MOVSSrm_alt, MOVSSrm_alt, MOVDI2PDIrm)
ENTRY(MOVNTPSmr, MOVNTPDmr, MOVNTDQmr)
ENTRY(ANDNPSrm, ANDNPDrm, PANDNrm)
ENTRY(ANDNPSrr, ANDNPDrr, PANDNrr)
ENTRY(ANDPSrm, ANDPDrm, PANDrm)
ENTRY(ANDPSrr, ANDPDrr, PANDrr)
ENTRY(ORPSrm, ORPDrm, PORrm)
ENTRY(ORPSrr, ORPDrr, PORrr)
ENTRY(XORPSrm, XORPDrm, PXORrm)
ENTRY(XORPSrr, XORPDrr, PXORrr)
ENTRY(UNPCKLPDrm, UNPCKLPDrm, PUNPCKLQDQrm)
ENTRY(MOVLHPSrr,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r, VORPDrr, VPORrr)
ENTRY(VXORPSrm, VXORPDrm, VPXORrm)
ENTRY(VXORPSrr, VXORPDrr, VPXORrr)
ENTRY(VUNPCKLPDrm, VUNPCKLPDrm, VPUNPCKLQDQrm)
ENTRY(VMOVLHPSrr, VUNPCKLPDrr, VPUNPCKLQDQrr)
ENTRY(VUNPCKHPDrm, VUNPCKHPDrm, VPUNPCKHQDQrm)
ENTRY(VUNPCKHPDrr, VUNPCKHPDrr, VPUNPCKHQDQrr)
ENTRY(VUNPCKLPSrm, VUNPCKLPSrm, VPUNPCKLDQrm)
ENTRY(VUNPCKLPSrr, VUNPCKLPSrr, VPUNPCKLDQrr)
ENTRY(VUNPCKHPSrm, VUNPCKHPSrm, VPUNPCKHDQrm)
ENTRY(VUNPCKHPSrr, VUNPCKHPSrr, VPUNPCKHDQrr)
ENTRY(VEXTRACTPSmr, VEXTRACTPSmr, VPEXTRDmr)
ENTRY(VEXTRACTPSrr, VEXTRACTPSrr, VPEXTRDrr)
// AVX 256-bit support
ENTRY(VMOVAPSYmr, VMOVAPDYmr, VMOVDQAYmr)
ENTRY(VMOVAPSYrm, VMOVAPDYrm, VMOVDQAYrm)
ENTRY(VMOVAPSYrr, VMOVAPDYrr, VMOVDQAYrr)
ENTRY(VMOVUPSYmr, VMOVUPDYmr, VMOVDQUYmr)
ENTRY(VMOVUPSYrm, VMOVUPDYrm, VMOVDQUYrm)
ENTRY(VMOVNTPSYmr, VMOVNTPDYmr, VMOVNTDQYmr)
ENTRY(VPERMPSYrm, VPERMPSYrm, VPERMDYrm)
ENTRY(VPERMPSYrr, VPERMPSYrr, VPERMDYrr)
ENTRY(VPERMPDYmi, VPERMPDYmi, VPERMQYmi)
ENTRY(VPERMPDYri, VPERMPDYri, VPERMQYri)
// AVX512 support
ENTRY(VMOVLPSZ128mr, VMOVLPDZ128mr, VMOVPQI2QIZmr)
ENTRY(VMOVNTPSZ128mr, VMOVNTPDZ128mr, VMOVNTDQZ128mr)
ENTRY(VMOVNTPSZ256mr, VMOVNTPDZ256mr, VMOVNTDQZ256mr)
ENTRY(VMOVNTPSZmr, VMOVNTPDZmr, VMOVNTDQZmr)
ENTRY(VMOVSDZmr, VMOVSDZmr, VMOVPQI2QIZmr)
ENTRY(VMOVSSZmr, VMOVSSZmr, VMOVPDI2DIZmr)
ENTRY(VMOVSDZrm, VMOVSDZrm, VMOVQI2PQIZrm)
ENTRY(VMOVSDZrm_alt, VMOVSDZrm_alt, VMOVQI2PQIZrm)
ENTRY(VMOVSSZrm, VMOVSSZrm, VMOVDI2PDIZrm)
ENTRY(VMOVSSZrm_alt, VMOVSSZrm_alt, VMOVDI2PDIZrm)
ENTRY(VBROADCASTSSZ128rr, VBROADCASTSSZ128rr, VPBROADCASTDZ128rr)
ENTRY(VBROADCASTSSZ128rm, VBROADCASTSSZ128rm, VPBROADCASTDZ128rm)
ENTRY(VBROADCASTSSZ256rr, VBROADCASTSSZ256rr, VPBROADCASTDZ256rr)
ENTRY(VBROADCASTSSZ256rm, VBROADCASTSSZ256rm, VPBROADCASTDZ256rm)
ENTRY(VBROADCASTSSZrr, VBROADCASTSSZrr, VPBROADCASTDZrr)
ENTRY(VBROADCASTSSZrm, VBROADCASTSSZrm, VPBROADCASTDZrm)
ENTRY(VMOVDDUPZ128rr, VMOVDDUPZ128rr, VPBROADCASTQZ128rr)
ENTRY(VMOVDDUPZ128rm, VMOVDDUPZ128rm, VPBROADCASTQZ128rm)
ENTRY(VBROADCASTSDZ256rr, VBROADCASTSDZ256rr, VPBROADCASTQZ256rr)
ENTRY(VBROADCASTSDZ256rm, VBROADCASTSDZ256rm, VPBROADCASTQZ256rm)
ENTRY(VBROADCASTSDZrr, VBROADCASTSDZrr, VPBROADCASTQZrr)
ENTRY(VBROADCASTSDZrm, VBROADCASTSDZrm, VPBROADCASTQZrm)
ENTRY(VINSERTF32x4Zrr, VINSERTF32x4Zrr, VINSERTI32x4Zrr)
ENTRY(VINSERTF32x4Zrm, VINSERTF32x4Zrm, VINSERTI32x4Zrm)
ENTRY(VINSERTF32x8Zrr, VINSERTF32x8Zrr, VINSERTI32x8Zrr)
ENTRY(VINSERTF32x8Zrm, VINSERTF32x8Zrm, VINSERTI32x8Zrm)
ENTRY(VINSERTF64x2Zrr, VINSERTF64x2Zrr, VINSERTI64x2Zrr)
ENTRY(VINSERTF64x2Zrm, VINSERTF64x2Zrm, VINSERTI64x2Zrm)
ENTRY(VINSERTF64x4Zrr, VINSERTF64x4Zrr, VINSERTI64x4Zrr)
ENTRY(VINSERTF64x4Zrm, VINSERTF64x4Zrm, VINSERTI64x4Zrm)
ENTRY(VINSERTF32x4Z256rr, VINSERTF32x4Z256rr, VINSERTI32x4Z256rr)
ENTRY(VINSERTF32x4Z256rm, VINSERTF32x4Z256rm, VINSERTI32x4Z256rm)
ENTRY(VINSERTF64x2Z256rr, VINSERTF64x2Z256rr, VINSERTI64x2Z256rr)
ENTRY(VINSERTF64x2Z256rm, VINSERTF64x2Z256rm, VINSERTI64x2Z256rm)
ENTRY(VEXTRACTF32x4Zrr, VEXTRACTF32x4Zrr, VEXTRACTI32x4Zrr)
ENTRY(VEXTRACTF32x4Zmr, VEXTRACTF32x4Zmr, VEXTRACTI32x4Zmr)
ENTRY(VEXTRACTF32x8Zrr, VEXTRACTF32x8Zrr, VEXTRACTI32x8Zrr)
ENTRY(VEXTRACTF32x8Zmr, VEXTRACTF32x8Zmr, VEXTRACTI32x8Zmr)
ENTRY(VEXTRACTF64x2Zrr, VEXTRACTF64x2Zrr, VEXTRACTI64x2Zrr)
ENTRY(VEXTRACTF64x2Zmr, VEXTRACTF64x2Zmr, VEXTRACTI64x2Zmr)
ENTRY(VEXTRACTF64x4Zrr, VEXTRACTF64x4Zrr, VEXTRACTI64x4Zrr)
ENTRY(VEXTRACTF64x4Zmr, VEXTRACTF64x4Zmr, VEXTRACTI64x4Zmr)
ENTRY(VEXTRACTF32x4Z256rr, VEXTRACTF32x4Z256rr, VEXTRACTI32x4Z256rr)
ENTRY(VEXTRACTF32x4Z256mr, VEXTRACTF32x4Z256mr, VEXTRACTI32x4Z256mr)
ENTRY(VEXTRACTF64x2Z256rr, VEXTRACTF64x2Z256rr, VEXTRACTI64x2Z256rr)
ENTRY(VEXTRACTF64x2Z256mr, VEXTRACTF64x2Z256mr, VEXTRACTI64x2Z256mr)
ENTRY(VPERMILPSmi, VPERMILPSmi, VPSHUFDmi)
ENTRY(VPERMILPSri, VPERMILPSri, VPSHUFDri)
ENTRY(VPERMILPSZ128mi, VPERMILPSZ128mi, VPSHUFDZ128mi)
ENTRY(VPERMILPSZ128ri, VPERMILPSZ128ri, VPSHUFDZ128ri)
ENTRY(VPERMILPSZ256mi, VPERMILPSZ256mi, VPSHUFDZ256mi)
ENTRY(VPERMILPSZ256ri, VPERMILPSZ256ri, VPSHUFDZ256ri)
ENTRY(VPERMILPSZmi, VPERMILPSZmi, VPSHUFDZmi)
ENTRY(VPERMILPSZri, VPERMILPSZri, VPSHUFDZri)
ENTRY(VPERMPSZ256rm, VPERMPSZ256rm, VPERMDZ256rm)
ENTRY(VPERMPSZ256rr, VPERMPSZ256rr, VPERMDZ256rr)
ENTRY(VPERMPDZ256mi, VPERMPDZ256mi, VPERMQZ256mi)
ENTRY(VPERMPDZ256ri, VPERMPDZ256ri, VPERMQZ256ri)
ENTRY(VPERMPDZ256rm, VPERMPDZ256rm, VPERMQZ256rm)
ENTRY(VPERMPDZ256rr, VPERMPDZ256rr, VPERMQZ256rr)
ENTRY(VPERMPSZrm, VPERMPSZrm, VPERMDZrm)
ENTRY(VPERMPSZrr, VPERMPSZrr, VPERMDZrr)
ENTRY(VPERMPDZmi, VPERMPDZmi, VPERMQZmi)
ENTRY(VPERMPDZri, VPERMPDZri, VPERMQZri)
ENTRY(VPERMPDZrm, VPERMPDZrm, VPERMQZrm)
ENTRY(VPERMPDZrr, VPERMPDZrr, VPERMQZrr)
ENTRY(VUNPCKLPDZ256rm, VUNPCKLPDZ256rm, VPUNPCKLQDQZ256rm)
ENTRY(VUNPCKLPD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ENTRY(VUNPCKLPSZrr, VUNPCKLPSZrr, VPUNPCKLDQZrr)
ENTRY(VUNPCKHPSZrm, VUNPCKHPSZrm, VPUNPCKHDQZrm)
ENTRY(VUNPCKHPSZrr, VUNPCKHPSZrr, VPUNPCKHDQZrr)
ENTRY(VEXTRACTPSZmr, VEXTRACTPSZmr, VPEXTRDZmr)
ENTRY(VEXTRACTPSZrr, VEXTRACTPSZrr, VPEXTRDZrr)
};

static const uint16_t ReplaceableInstrsAVX2[][3] = {
// PackedSingle, PackedDouble, PackedInt
ENTRY(VANDNPSYrm, VANDNPDYrm, VPANDNYrm)
ENTRY(VANDNPSYrr, VANDNPDYrr, VPANDNYrr)
ENTRY(VANDPSYrm, VANDPDYrm, VPANDYrm)
ENTRY(VANDPSYrr, VANDPDYrr, VPANDYrr)
ENTRY(VORPSYrm, VORPDYrm, VPORYrm)
ENTRY(VORPSYrr, VORPDYrr, VPORYrr)
ENTRY(VXORPSYrm, VXORPDYrm, VPXORYrm)
ENTRY(VXORPSYrr, VXORPDYrr, VPXORYrr)
ENTRY(VPERM2F128rm, VPERM2F128rm, VPERM2I128rm)
ENTRY(VPERM2F128rr, VPERM2F128rr, VPERM2I128rr)
ENTRY(VBROADCASTSSrm, VBROADCASTSSrm, VPBROADCASTDrm)
ENTRY(VBROADCASTSSrr, VBROADCASTSSrr, VPBROADCASTDrr)
ENTRY(VMOVDDUPrm, VMOVDDUPrm, VPBROADCASTQrm)
ENTRY(VMOVDDUPrr, VMOVDDUPrr, VPBROADCASTQrr)
ENTRY(VBROADCASTSSYrr, VBROADCASTSSYrr, VPBROADCASTDYrr)
ENTRY(VBROADCASTSSYrm, VBROADCASTSSYrm, VPBROADCASTDYrm)
ENTRY(VBROADCASTSDYrr, VBROADCASTSDYrr, VPBROADCASTQYrr)
ENTRY(VBROADCASTSDYrm, VBROADCASTSDYrm, VPBROADCASTQYrm)
ENTRY(VBROADCASTF128rm, VBROADCASTF128rm, VBROADCASTI128rm)
ENTRY(VBLENDPSYrri, VBLENDPSYrri, VPBLENDDYrri)
ENTRY(VBLENDPSYrmi, VBLENDPSYrmi, VPBLENDDYrmi)
ENTRY(VPERMILPSYmi, VPERMILPSYmi, VPSHUFDYmi)
ENTRY(VPERMILPSYri, VPERMILPSYri, VPSHUFDYri)
ENTRY(VUNPCKLPDYrm, VUNPCKLPDYrm, VPUNPCKLQDQYrm)
ENTRY(VUNPCKLPDYrr, VUNPCKLPDYrr, VPUNPCKLQDQYrr)
ENTRY(VUNPCKHPDYrm, VUNPCKHPDYrm, VPUNPCKHQDQYrm)
ENTRY(VUNPCKHPDYrr, VUNPCKHPDYrr, VPUNPCKHQDQYrr)
ENTRY(VUNPCKLPSYrm, VUNPCKLPSYrm, VPUNPCKLDQYrm)
ENTRY(VUNPCKLPSYrr, VUNPCKLPSYrr, VPUNPCKLDQYrr)
ENTRY(VUNPCKHPSYrm, VUNPCKHPSYrm, VPUNPCKHDQYrm)
ENTRY(VUNPCKHPSYrr, VUNPCKHPSYrr, VPUNPCKHDQYrr)
};

static const uint16_t ReplaceableInstrsFP[][3] = {
// PackedSingle, PackedDouble
ENTRY(MOVLPSrm, MOVLPDrm, INSTRUCTION_LIST_END)
ENTRY(MOVHPSrm, MOVHPDrm, INSTRUCTION_LIST_END)
ENTRY(MOVHPSmr, MOVHPDmr, INSTRUCTION_LIST_END)
ENTRY(VMOVLPSrm, VMOVLPDrm, INSTRUCTION_LIST_END)
ENTRY(VMOVHPSrm, VMOVHPDrm, INSTRUCTION_LIST_END)
ENTRY(VMOVHPSmr, VMOVHPDmr, INSTRUCTION_LIST_END)
ENTRY(VMOVLPSZ128rm, VMOVLPDZ128rm, INSTRUCTION_LIST_END)
ENTRY(VMOVHPSZ128rm, VMOVHPDZ128rm, INSTRUCTION_LIST_END)
ENTRY(VMOVHPSZ128mr, VMOVHPDZ128mr, INSTRUCTION_LIST_END)
};

static const uint16_t ReplaceableInstrsAVX2InsertExtract[][3] = {
// PackedSingle, PackedDouble, PackedInt
ENTRY(VEXTRACTF128mr, VEXTRACTF128mr, VEXTRACTI128mr)
ENTRY(VEXTRACTF128rr, VEXTRACTF128rr, VEXTRACTI128rr)
ENTRY(VINSERTF128rm, VINSERTF128rm, VINSERTI128rm)
ENTRY(VINSERTF128rr, VINSERTF128rr, VINSERTI128rr)
};

// NOTE: These should only be used by the custom domain methods.
static const uint16_t ReplaceableBlendInstrs[][3] = {
//PackedSingle, PackedDouble, PackedInt
ENTRY(BLENDPSrmi, BLENDPDrmi, PBLENDWrmi)
ENTRY(BLENDPSrri, BLENDPDrri, PBLENDWrri)
ENTRY(VBLENDPSrmi, VBLENDPDrmi, VPBLENDWrmi)
ENTRY(VBLENDPSrri, VBLENDPDrri, VPBLENDWrri)
ENTRY(VBLENDPSYrmi, VBLENDPDYrmi, VPBLENDWYrmi)
ENTRY(VBLENDPSYrri, VBLENDPDYrri, VPBLENDWYrri)
};

static const uint16_t ReplaceableBlendAVX2Instrs[][3] = {
// PackedSingle, PackedDouble, PackedInt
ENTRY(VBLENDPSrmi, VBLENDPDrmi, VPBLENDDrmi)
ENTRY(VBLENDPSrri, VBLENDPDrri, VPBLENDDrri)
ENTRY(VBLENDPSYrmi, VBLENDPDYrmi, VPBLENDDYrmi)
ENTRY(VBLENDPSYrri, VBLENDPDYrri, VPBLENDDYrri)
};

#undef ENTRY
#define ENTRY(A, B, C, D) {X86::A, X86::B, X86::C, X86::D},
static const uint16_t ReplaceableInstrsAVX512[][4] = {
// Two integer columns for 64-bit and 32-bit elements.
//PackedSingle, PackedDouble, PackedInt, PackedInt
ENTRY(VMOVAPSZ128mr, VMOVAPDZ128mr, VMOVDQA64Z128mr, VMOVDQA32Z128mr)
ENTRY(VMOVAPSZ128rm, VMOVAPDZ128rm, VMOVDQA64Z128rm, VMOVDQA32Z128rm)
ENTRY(VMOVAPSZ128rr, VMOVAPDZ128rr, VMOVDQA64Z128rr, VMOVDQA32Z128rr)
ENTRY(VMOVUPSZ128mr, VMOVUPDZ128mr, VMOVDQU64Z128mr, VMOVDQU32Z128mr)
ENTRY(VMOVUPSZ128rm, VMOVUPDZ128rm, VMOVDQU64Z128rm, VMOVDQU32Z128rm)
ENTRY(VMOVAPSZ256mr, VMOVAPDZ256mr, VMOVDQA64Z256mr, VMOVDQA32Z256mr)
ENTRY(VMOVAPSZ256rm, VMOVAPDZ256rm, VMOVDQA64Z256rm, VMOVDQA32Z256rm)
ENTRY(VMOVAPSZ256rr, VMOVAPDZ256rr, VMOVDQA64Z256rr, VMOVDQA32Z256rr)
ENTRY(VMOVUPSZ256mr, VMOVUPDZ256mr, VMOVDQU64Z256mr, VMOVDQU32Z256mr)
ENTRY(VMOVUPSZ256rm, VMOVUPDZ256rm, VMOVDQU64Z256rm, VMOVDQU32Z256rm)
ENTRY(VMOVAPSZmr, VMOVAPDZmr, VMOVDQA64Zmr, VMOVDQA32Zmr)
ENTRY(VMOVAPSZrm, VMOVAPDZrm, VMOVDQA64Zrm, VMOVDQA32Zrm)
ENTRY(VMOVAPSZrr, VMOVAPDZrr, VMOVDQA64Zrr, VMOVDQA32Zrr)
ENTRY(VMOVUPSZmr, VMOVUPDZmr, VMOVDQU64Zmr, VMOVDQU32Zmr)
ENTRY(VMOVUPSZrm, VMOVUPDZrm, VMOVDQU64Zrm, VMOVDQU32Zrm)
};

static const uint16_t ReplaceableInstrsAVX512DQ[][4] = {
// Two integer columns for 64-bit and 32-bit elements.
// PackedSingle, PackedDouble, PackedInt, PackedInt
ENTRY(VANDNPSZ128rm, VANDNPDZ128rm, VPANDNQZ128rm, VPANDNDZ128rm)
ENTRY(VANDNPSZ128rr, VANDNPDZ128rr, VPANDNQZ128rr, VPANDNDZ128rr)
ENTRY(VANDPSZ128rm, VANDPDZ128rm, VPANDQZ128rm, VPANDDZ128rm)
ENTRY(VANDPSZ128rr, VANDPDZ128rr, VPANDQZ128rr, VPANDDZ128rr)
ENTRY(VORPSZ128rm, VORPDZ128rm, VPORQZ128rm, VPORDZ128rm)
ENTRY(VORPSZ128rr, VORPDZ128rr, VPORQZ128rr, VPORDZ128rr)
ENTRY(VXORPSZ128rm, VXORPDZ128rm, VPXORQZ128rm, VPXORDZ128rm)
ENTRY(VXORPSZ128rr, VXORPDZ128rr, VPXORQZ128rr, VPXORDZ128rr)
ENTRY(VANDNPSZ256rm, VANDNPDZ256rm, VPANDNQZ256rm, VPANDNDZ256rm)
ENTRY(VANDNPSZ256rr, VANDNPDZ256rr, VPANDNQZ256rr, VPANDNDZ256rr)
ENTRY(VANDPSZ256rm, VANDPDZ256rm, VPANDQZ256rm, VPANDDZ256rm)
ENTRY(VANDPSZ256rr, VANDPDZ256rr, VPANDQZ256rr, VPANDDZ256rr)
ENTRY(VORPSZ256rm, VORPDZ256rm, VPORQZ256rm, VPORDZ256rm)
ENTRY(VORPSZ256rr, VORPDZ256rr, VPORQZ256rr, VPORDZ256rr)
ENTRY(VXORPSZ256rm, VXORPDZ256rm, VPXORQZ256rm, VPXORDZ256rm)
ENTRY(VXORPSZ256rr, VXORPDZ256rr, VPXORQZ256rr, VPXORDZ256rr)
ENTRY(VANDNPSZrm, VANDNPDZrm, VPANDNQZrm, VPANDNDZrm)
ENTRY(VANDNPSZrr, VANDNPDZrr, VPANDNQZrr, VPANDNDZrr)
ENTRY(VANDPSZrm, VANDPDZrm, VPANDQZrm, VPANDDZrm)
ENTRY(VANDPSZrr, VANDPDZrr, VPANDQZrr, VPANDDZrr)
ENTRY(VORPSZrm, VORPDZrm, VPORQZrm, VPORDZrm)
ENTRY(VORPSZrr, VORPDZrr, VPORQZrr, VPORDZrr)
ENTRY(VXORPSZrm, VXORPDZrm, VPXORQZrm, VPXORDZrm)
ENTRY(VXORPSZrr, VXORPDZrr, VPXORQZrr, VPXORDZrr)
};

static const uint16_t ReplaceableInstrsAVX512DQMasked[][4] = {
// Two integer columns for 64-bit and 32-bit elements.
// PackedSingle, PackedDouble, PackedInt, PackedInt
ENTRY(VANDNPSZ128rmk, VANDNPDZ128rmk, VPANDNQZ128rmk, VPANDNDZ128rmk)
ENTRY(VANDNPSZ128rmkz, VANDNPDZ128rmkz, VPANDNQZ128rmkz, VPANDNDZ128rmkz)
ENTRY(VANDNPSZ128rrk, VANDNPDZ128rrk, VPANDNQZ128rrk, VPANDNDZ128rrk)
ENTRY(VANDNPSZ128rrkz, VANDNPDZ128rrkz, VPANDNQZ128rrkz, VPANDNDZ128rrkz)
ENTRY(VANDPSZ128rmk, VANDPDZ128rmk, VPANDQZ128rmk, VPANDDZ128rmk)
ENTRY(VANDPSZ128rmkz, VANDPDZ128rmkz, VPANDQZ128rmkz, VPANDDZ128rmkz)
ENTRY(VANDPSZ128rrk, VANDPDZ128rrk, VPANDQZ128rrk, VPANDDZ128rrk)
ENTRY(VANDPSZ128rrkz, VANDPDZ128rrkz, VPANDQZ128rrkz, VPANDDZ128rrkz)
ENTRY(VORPSZ128rmk, VORPDZ128rmk, VPORQZ128rmk, VPORDZ128rmk)
ENTRY(VORPSZ128rmkz, VORPDZ128rmkz, VPORQZ128rmkz, VPORDZ128rmkz)
ENTRY(VORPSZ128rrk, VORPDZ128rrk, VPORQZ128rrk, VPORDZ128rrk)
ENTRY(VORPSZ128rrkz, VORPDZ128rrkz, VPORQZ128rrkz, VPORDZ128rrkz)
ENTRY(VXORPSZ128rmk, VXORPDZ128rmk, VPXORQZ128rmk, VPXORDZ128rmk)
ENTRY(VXORPSZ128rmkz, VXORPDZ128rmkz, VPXORQZ128rmkz, VPXORDZ128rmkz)
ENTRY(VXORPSZ128rrk, VXORPDZ128rrk, VPXORQZ128rrk, VPXORDZ128rrk)
ENTRY(VXORPSZ128rrkz, VXORPDZ128rrkz, VPXORQZ128rrkz, VPXORDZ128rrkz)
ENTRY(VANDNPSZ256rmk, VANDNPDZ256rmk, VPANDNQZ256rmk, VPANDNDZ256rmk)
ENTRY(VANDNPSZ256rmkz, VANDNPDZ256rmkz, VPANDNQZ256rmkz, VPANDNDZ256rmkz)
ENTRY(VANDNPSZ256rrk, VANDNPDZ256rrk, VPANDNQZ256rrk, VPANDNDZ256rrk)
ENTRY(VANDNPSZ256rrkz, VANDNPDZ256rrkz, VPANDNQZ256rrkz, VPANDNDZ256rrkz)
ENTRY(VANDPSZ256rmk, VANDPDZ256rmk, VPANDQZ256rmk, VPANDDZ256rmk)
ENTRY(VANDPSZ256rmkz, VANDPDZ256rmkz, VPANDQZ256rmkz, VPANDDZ256rmkz)
ENTRY(VANDPSZ256rrk, VANDPDZ256rrk, VPANDQZ256rrk, VPANDDZ256rrk)
ENTRY(VANDPSZ256rrkz, VANDPDZ256rrkz, VPANDQZ256rrkz, VPANDDZ256rrkz)
ENTRY(VORPSZ256rmk, VORPDZ256rmk, VPORQZ256rmk, VPORDZ256rmk)
ENTRY(VORPSZ256rmkz, VORPDZ256rmkz, VPORQZ256rmkz, VPORDZ256rmkz)
ENTRY(VORPSZ256rrk, VORPDZ256rrk, VPORQZ256rrk, VPORDZ256rrk)
ENTRY(VORPSZ256rrkz, VORPDZ256rrkz, VPORQZ256rrkz, VPORDZ256rrkz)
ENTRY(VXORPSZ256rmk, VXORPDZ256rmk, VPXORQZ256rmk, VPXORDZ256rmk)
ENTRY(VXORPSZ256rmkz, VXORPDZ256rmkz, VPXORQZ256rmkz, VPXORDZ256rmkz)
ENTRY(VXORPSZ256rrk, VXORPDZ256rrk, VPXORQZ256rrk, VPXORDZ256rrk)
ENTRY(VXORPSZ256rrkz, VXORPDZ256rrkz, VPXORQZ256rrkz, VPXORDZ256rrkz)
ENTRY(VANDNPSZrmk, VANDNPDZrmk, VPANDNQZrmk, VPANDNDZrmk)
ENTRY(VANDNPSZrmkz, VANDNPDZrmkz, VPANDNQZrmkz, VPANDNDZrmkz)
ENTRY(VANDNPSZrrk, VANDNPDZrrk, VPANDNQZrrk, VPANDNDZrrk)
ENTRY(VANDNPSZrrkz, VANDNPDZrrkz, VPANDNQZrrkz, VPANDNDZrrkz)
ENTRY(VANDPSZrmk, VANDPDZrmk, VPANDQZrmk, VPANDDZrmk)
ENTRY(VANDPSZrmkz, VANDPDZrmkz, VPANDQZrmkz, VPANDDZrmkz)
ENTRY(VANDPSZrrk, VANDPDZrrk, VPANDQZrrk, VPANDDZrrk)
ENTRY(VANDPSZrrkz, VANDPDZrrkz, VPANDQZrrkz, VPANDDZrrkz)
ENTRY(VORPSZrmk, VORPDZrmk, VPORQZrmk, VPORDZrmk)
ENTRY(VORPSZrmkz, VORPDZrmkz, VPORQZrmkz, VPORDZrmkz)
ENTRY(VORPSZrrk, VORPDZrrk, VPORQZrrk, VPORDZrrk)
ENTRY(VORPSZrrkz, VORPDZrrkz, VPORQZrrkz, VPORDZrrkz)
ENTRY(VXORPSZrmk, VXORPDZrmk, VPXORQZrmk, VPXORDZrmk)
ENTRY(VXORPSZrmkz, VXORPDZrmkz, VPXORQZrmkz, VPXORDZrmkz)
ENTRY(VXORPSZrrk, VXORPDZrrk, VPXORQZrrk, VPXORDZrrk)
ENTRY(VXORPSZrrkz, VXORPDZrrkz, VPXORQZrrkz, VPXORDZrrkz)
// Broadcast loads can be handled the same as masked operations to avoid
// changing element size.
ENTRY(VANDNPSZ128rmb, VANDNPDZ128rmb, VPANDNQZ128rmb, VPANDNDZ128rmb)
ENTRY(VANDPSZ128rmb, VANDPDZ128rmb, VPANDQZ128rmb, VPANDDZ128rmb)
ENTRY(VORPSZ128rmb, VORPDZ128rmb, VPORQZ128rmb, VPORDZ128rmb)
ENTRY(VXORPSZ128rmb, VXORPDZ128rmb, VPXORQZ128rmb, VPXORDZ128rmb)
ENTRY(VANDNPSZ256rmb, VANDNPDZ256rmb, VPANDNQZ256rmb, VPANDNDZ256rmb)
ENTRY(VANDPSZ256rmb, VANDPDZ256rmb, VPANDQZ256rmb, VPANDDZ256rmb)
ENTRY(VORPSZ256rmb, VORPDZ256rmb, VPORQZ256rmb, VPORDZ256rmb)
ENTRY(VXORPSZ256rmb, VXORPDZ256rmb, VPXORQZ256rmb, VPXORDZ256rmb)
ENTRY(VANDNPSZrmb, VANDNPDZrmb, VPANDNQZrmb, VPANDNDZrmb)
ENTRY(VANDPSZrmb, VANDPDZrmb, VPANDQZrmb, VPANDDZrmb)
ENTRY(VANDPSZrmb, VANDPDZrmb, VPANDQZrmb, VPANDDZrmb)
ENTRY(VORPSZrmb, VORPDZrmb, VPORQZrmb, VPORDZrmb)
ENTRY(VXORPSZrmb, VXORPDZrmb, VPXORQZrmb, VPXORDZrmb)
ENTRY(VANDNPSZ128rmbk, VANDNPDZ128rmbk, VPANDNQZ128rmbk, VPANDNDZ128rmbk)
ENTRY(VANDPSZ128rmbk, VANDPDZ128rmbk, VPANDQZ128rmbk, VPANDDZ128rmbk)
ENTRY(VORPSZ128rmbk, VORPDZ128rmbk, VPORQZ128rmbk, VPORDZ128rmbk)
ENTRY(VXORPSZ128rmbk, VXORPDZ128rmbk, VPXORQZ128rmbk, VPXORDZ128rmbk)
ENTRY(VANDNPSZ256rmbk, VANDNPDZ256rmbk, VPANDNQZ256rmbk, VPANDNDZ256rmbk)
ENTRY(VANDPSZ256rmbk, VANDPDZ256rmbk, VPANDQZ256rmbk, VPANDDZ256rmbk)
ENTRY(VORPSZ256rmbk, VORPDZ256rmbk, VPORQZ256rmbk, VPORDZ256rmbk)
ENTRY(VXORPSZ256rmbk, VXORPDZ256rmbk, VPXORQZ256rmbk, VPXORDZ256rmbk)
ENTRY(VANDNPSZrmbk, VANDNPDZrmbk, VPANDNQZrmbk, VPANDNDZrmbk)
ENTRY(VANDPSZrmbk, VANDPDZrmbk, VPANDQZrmbk, VPANDDZrmbk)
ENTRY(VANDPSZrmbk, VANDPDZrmbk, VPANDQZrmbk, VPANDDZrmbk)
ENTRY(VORPSZrmbk, VORPDZrmbk, VPORQZrmbk, VPORDZrmbk)
ENTRY(VXORPSZrmbk, VXORPDZrmbk, VPXORQZrmbk, VPXORDZrmbk)
ENTRY(VANDNPSZ128rmbkz, VANDNPDZ128rmbkz, VPANDNQZ128rmbkz, VPANDNDZ128rmbkz)
ENTRY(VANDPSZ128rmbkz, VANDPDZ128rmbkz, VPANDQZ128rmbkz, VPANDDZ128rmbkz)
ENTRY(VORPSZ128rmbkz, VORPDZ128rmbkz, VPORQZ128rmbkz, VPORDZ128rmbkz)
ENTRY(VXORPSZ128rmbkz, VXORPDZ128rmbkz, VPXORQZ128rmbkz, VPXORDZ128rmbkz)
ENTRY(VANDNPSZ256rmbkz, VANDNPDZ256rmbkz, VPANDNQZ256rmbkz, VPANDNDZ256rmbkz)
ENTRY(VANDPSZ256rmbkz, VANDPDZ256rmbkz, VPANDQZ256rmbkz, VPANDDZ256rmbkz)
ENTRY(VORPSZ256rmbkz, VORPDZ256rmbkz, VPORQZ256rmbkz, VPORDZ256rmbkz)
ENTRY(VXORPSZ256rmbkz, VXORPDZ256rmbkz, VPXORQZ256rmbkz, VPXORDZ256rmbkz)
ENTRY(VANDNPSZrmbkz, VANDNPDZrmbkz, VPANDNQZrmbkz, VPANDNDZrmbkz)
ENTRY(VANDPSZrmbkz, VANDPDZrmbkz, VPANDQZrmbkz, VPANDDZrmbkz)
ENTRY(VANDPSZrmbkz, VANDPDZrmbkz, VPANDQZrmbkz, VPANDDZrmbkz)
ENTRY(VORPSZrmbkz, VORPDZrmbkz, VPORQZrmbkz, VPORDZrmbkz)
ENTRY(VXORPSZrmbkz, VXORPDZrmbkz, VPXORQZrmbkz, VPXORDZrmbkz)
};

// Special table for changing EVEX logic instructions to VEX.
// TODO: Should we run EVEX->VEX earlier?
static const uint16_t ReplaceableCustomAVX512LogicInstrs[][4] = {
// Two integer columns for 64-bit and 32-bit elements.
// PackedSingle, PackedDouble, PackedInt, PackedInt
ENTRY(VANDNPSrm, VANDNPDrm, VPANDNQZ128rm, VPANDNDZ128rm)
ENTRY(VANDNPSrr, VANDNPDrr, VPANDNQZ128rr, VPANDNDZ128rr)
ENTRY(VANDPSrm, VANDPDrm, VPANDQZ128rm, VPANDDZ128rm)
ENTRY(VANDPSrr, VANDPDrr, VPANDQZ128rr, VPANDDZ128rr)
ENTRY(VORPSrm, VORPDrm, VPORQZ128rm, VPORDZ128rm)
ENTRY(VORPSrr, VORPDrr, VPORQZ128rr, VPORDZ128rr)
ENTRY(VXORPSrm, VXORPDrm, VPXORQZ128rm, VPXORDZ128rm)
ENTRY(VXORPSrr, VXORPDrr, VPXORQZ128rr, VPXORDZ128rr)
ENTRY(VANDNPSYrm, VANDNPDYrm, VPANDNQZ256rm, VPANDNDZ256rm)
ENTRY(VANDNPSYrr, VANDNPDYrr, VPANDNQZ256rr, VPANDNDZ256rr)
ENTRY(VANDPSYrm, VANDPDYrm, VPANDQZ256rm, VPANDDZ256rm)
ENTRY(VANDPSYrr, VANDPDYrr, VPANDQZ256rr, VPANDDZ256rr)
ENTRY(VORPSYrm, VORPDYrm, VPORQZ256rm, VPORDZ256rm)
ENTRY(VORPSYrr, VORPDYrr, VPORQZ256rr, VPORDZ256rr)
ENTRY(VXORPSYrm, VXORPDYrm, VPXORQZ256rm, VPXORDZ256rm)
ENTRY(VXORPSYrr, VXORPDYrr, VPXORQZ256rr, VPXORDZ256rr)
};
