x86: add avx_bcast to cs_x86_op to support AVX512 instructions. this also updates Python & Java binding
diff --git a/arch/X86/X86GenAsmWriter.inc b/arch/X86/X86GenAsmWriter.inc
index 6522541..5f8253d 100644
--- a/arch/X86/X86GenAsmWriter.inc
+++ b/arch/X86/X86GenAsmWriter.inc
@@ -12937,6 +12937,7 @@
// VPCONFLICTDrmbk
printi32mem(MI, 3, O);
SStream_concat0(O, "{1to16}, ");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_16);
printOperand(MI, 0, O);
SStream_concat0(O, " {");
printOperand(MI, 2, O);
@@ -12947,6 +12948,7 @@
// VPCONFLICTQrmbk
printi64mem(MI, 3, O);
SStream_concat0(O, "{1to8}, ");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_8);
printOperand(MI, 0, O);
SStream_concat0(O, " {");
printOperand(MI, 2, O);
@@ -13154,10 +13156,12 @@
case 39:
// VADDPDZrmb, VDIVPDZrmb, VFMADD132PDZmb, VFMADD213PDZmb, VFMADDSUB132PD...
SStream_concat0(O, "{1to8}, ");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_8);
break;
case 40:
// VADDPSZrmb, VDIVPSZrmb, VFMADD132PSZmb, VFMADD213PSZmb, VFMADDSUB132PS...
SStream_concat0(O, "{1to16}, ");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_16);
break;
case 41:
// VALIGNDrmi, VALIGNQrmi, VPCMPDZrmi_alt, VPCMPQZrmi_alt, VPCMPUDZrmi_al...
diff --git a/arch/X86/X86GenAsmWriter1.inc b/arch/X86/X86GenAsmWriter1.inc
index 03a6e5e..51fb4b4 100644
--- a/arch/X86/X86GenAsmWriter1.inc
+++ b/arch/X86/X86GenAsmWriter1.inc
@@ -12842,11 +12842,13 @@
case 9:
// VPCONFLICTDrmb
SStream_concat0(O, "{1to16}");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_16);
return;
break;
case 10:
// VPCONFLICTQrmb
SStream_concat0(O, "{1to8}");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_8);
return;
break;
}
@@ -12955,12 +12957,14 @@
// VPCONFLICTDrmbk
printi32mem(MI, 3, O);
SStream_concat0(O, "{1to16}");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_16);
return;
break;
case 23:
// VPCONFLICTQrmbk
printi64mem(MI, 3, O);
SStream_concat0(O, "{1to8}");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_8);
return;
break;
case 24:
@@ -12995,11 +12999,13 @@
case 2:
// VADDPDZrmb, VDIVPDZrmb, VFMADD132PDZmb, VFMADD213PDZmb, VFMADDSUB132PD...
SStream_concat0(O, "{1to8}");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_8);
return;
break;
case 3:
// VADDPSZrmb, VDIVPSZrmb, VFMADD132PSZmb, VFMADD213PSZmb, VFMADDSUB132PS...
SStream_concat0(O, "{1to16}");
+ op_addAvxBroadcast(MI, X86_AVX_BCAST_16);
return;
break;
case 4:
diff --git a/arch/X86/X86Mapping.c b/arch/X86/X86Mapping.c
index faf11af..5470c3e 100644
--- a/arch/X86/X86Mapping.c
+++ b/arch/X86/X86Mapping.c
@@ -42578,4 +42578,11 @@
}
}
+void op_addAvxBroadcast(MCInst *MI, x86_avx_bcast v)
+{
+ if (MI->csh->detail) {
+ MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count - 1].avx_bcast = v;
+ }
+}
+
#endif
diff --git a/arch/X86/X86Mapping.h b/arch/X86/X86Mapping.h
index 41134a4..8ca8bcc 100644
--- a/arch/X86/X86Mapping.h
+++ b/arch/X86/X86Mapping.h
@@ -47,4 +47,6 @@
void op_addReg(MCInst *MI, int reg);
void op_addImm(MCInst *MI, int v);
+void op_addAvxBroadcast(MCInst *MI, x86_avx_bcast v);
+
#endif
diff --git a/bindings/java/TestX86.java b/bindings/java/TestX86.java
index be77a63..087287a 100644
--- a/bindings/java/TestX86.java
+++ b/bindings/java/TestX86.java
@@ -104,9 +104,14 @@
System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp);
}
+ // AVX broadcast type
+ if (i.avx_bcast != X86_AVX_BCAST_INVALID) {
+ System.out.printf("\t\toperands[%d].avx_bcast: %d\n", c, i.avx_bcast);
+ }
+
// Operand size is irrlevant for X86_OP_IMM operand
if (i.type != X86_OP_IMM) {
- System.out.printf("\t\toperands[%d].size: %d\n",c, i.size);
+ System.out.printf("\t\toperands[%d].size: %d\n", c, i.size);
}
}
}
diff --git a/bindings/java/capstone/X86.java b/bindings/java/capstone/X86.java
index a4cbc46..734caff 100644
--- a/bindings/java/capstone/X86.java
+++ b/bindings/java/capstone/X86.java
@@ -42,6 +42,7 @@
public int type;
public OpValue value;
public int size;
+ public int avx_bcast;
public void read() {
super.read();
@@ -60,7 +61,7 @@
@Override
public List getFieldOrder() {
- return Arrays.asList("type", "value", "size");
+ return Arrays.asList("type", "value", "size", "avx_bcast");
}
}
diff --git a/bindings/java/capstone/X86_const.java b/bindings/java/capstone/X86_const.java
index d5c4321..d5a8feb 100644
--- a/bindings/java/capstone/X86_const.java
+++ b/bindings/java/capstone/X86_const.java
@@ -248,6 +248,12 @@
public static final int X86_OP_FP = 3;
public static final int X86_OP_MEM = 4;
+ // AVX broadcast type
+
+ public static final int X86_AVX_BCAST_INVALID = 0;
+ public static final int X86_AVX_BCAST_8 = 1;
+ public static final int X86_AVX_BCAST_16 = 2;
+
// X86 instructions
public static final int X86_INS_INVALID = 0;
diff --git a/bindings/python/capstone/x86.py b/bindings/python/capstone/x86.py
index 151e053..c5a9a0f 100644
--- a/bindings/python/capstone/x86.py
+++ b/bindings/python/capstone/x86.py
@@ -26,6 +26,7 @@
('type', ctypes.c_uint),
('value', X86OpValue),
('size', ctypes.c_uint8),
+ ('avx_bcast', ctypes.c_uint),
)
@property
diff --git a/bindings/python/capstone/x86_const.py b/bindings/python/capstone/x86_const.py
index 25dd5fb..e15ff6a 100644
--- a/bindings/python/capstone/x86_const.py
+++ b/bindings/python/capstone/x86_const.py
@@ -245,6 +245,12 @@
X86_OP_FP = 3
X86_OP_MEM = 4
+# AVX broadcast type
+
+X86_AVX_BCAST_INVALID = 0
+X86_AVX_BCAST_8 = 1
+X86_AVX_BCAST_16 = 2
+
# X86 instructions
X86_INS_INVALID = 0
diff --git a/bindings/python/test_x86.py b/bindings/python/test_x86.py
index c0b3a2b..65132a9 100755
--- a/bindings/python/test_x86.py
+++ b/bindings/python/test_x86.py
@@ -91,6 +91,10 @@
if i.mem.disp != 0:
print("\t\t\toperands[%u].mem.disp: 0x%s" % (c, to_x(i.mem.disp)))
+ # AVX broadcast type
+ if i.avx_bcast != X86_AVX_BCAST_INVALID:
+ print("\t\toperands[%u].avx_bcast: %u" % (c, i.avx_bcast))
+
# Operand size is irrlevant for X86_OP_IMM operand
if i.type != X86_OP_IMM:
print("\t\toperands[%u].size: %u" % (c, i.size))
diff --git a/include/x86.h b/include/x86.h
index 6090098..b9fa3e7 100644
--- a/include/x86.h
+++ b/include/x86.h
@@ -76,6 +76,13 @@
X86_OP_MEM, // Memory operand
} x86_op_type;
+//> AVX broadcast type
+typedef enum x86_avx_bcast {
+ X86_AVX_BCAST_INVALID = 0, // Uninitialized.
+ X86_AVX_BCAST_8, // AVX512 broadcast type 1to8
+ X86_AVX_BCAST_16, // AVX512 broadcast type 1to16
+} x86_avx_bcast;
+
// Instruction's operand referring to memory
// This is associated with X86_OP_MEM operand type above
typedef struct x86_op_mem {
@@ -99,6 +106,9 @@
// size of this operand (in bytes).
// NOTE: this is irrelevant for operand type X86_OP_IMM
uint8_t size;
+
+ // AVX broadcast type, or 0 if irrelevant
+ x86_avx_bcast avx_bcast;
} cs_x86_op;
// Instruction structure
diff --git a/tests/test_x86.c b/tests/test_x86.c
index 8f896cf..7f879df 100644
--- a/tests/test_x86.c
+++ b/tests/test_x86.c
@@ -102,6 +102,10 @@
}
// the size is irrelevant for X86_OP_IMM
+ if (op->avx_bcast != X86_AVX_BCAST_INVALID)
+ printf("\t\toperands[%u].avx_bcast: %u\n", i, op->avx_bcast);
+
+ // the size is irrelevant for X86_OP_IMM
if (op->type != X86_OP_IMM)
printf("\t\toperands[%u].size: %u\n", i, op->size);
}