+2018-07-31 Jan Beulich <jbeulich@suse.com>
+
+ * config/tc-i386.c (is_any_vex_encoding): New.
+ (process_immext, process_suffix): Use it.
+ (md_assemble): Likewise. Reject DATA_PREFIX with VEX/XOP/EVEX
+ insn.
+ * testsuite/gas/i386/prefix32.s, testsuite/gas/i386/prefix32.l,
+ testsuite/gas/i386/prefix64.s, testsuite/gas/i386/prefix64.l
+ New.
+ * testsuite/gas/i386/i386.exp: Run new tests.
+
2018-07-31 Jan Beulich <jbeulich@suse.com>
* config/tc-i386.c (parse_real_register): Use cpuavx512f instead
|| t->opcode_modifier.staticrounding || t->opcode_modifier.sae;
}
+static INLINE bfd_boolean
+is_any_vex_encoding (const insn_template *t)
+{
+ return t->opcode_modifier.vex || t->opcode_modifier.vexopcode
+ || is_evex_encoding (t);
+}
+
/* Build the EVEX prefix. */
static void
gas_assert (i.imm_operands <= 1
&& (i.operands <= 2
- || ((i.tm.opcode_modifier.vex
- || i.tm.opcode_modifier.vexopcode
- || is_evex_encoding (&i.tm))
+ || (is_any_vex_encoding (&i.tm)
&& i.operands <= 4)));
exp = &im_expressions[i.imm_operands++];
return;
}
+ /* Check for data size prefix on VEX/XOP/EVEX encoded insns. */
+ if (i.prefix[DATA_PREFIX] && is_any_vex_encoding (&i.tm))
+ {
+ as_bad (_("data size prefix invalid with `%s'"), i.tm.name);
+ return;
+ }
+
/* Check if HLE prefix is OK. */
if (i.hle_prefix && !check_hle ())
return;
as_warn (_("translating to `%sp'"), i.tm.name);
}
- if (i.tm.opcode_modifier.vex || i.tm.opcode_modifier.vexopcode
- || is_evex_encoding (&i.tm))
+ if (is_any_vex_encoding (&i.tm))
{
if (flag_code == CODE_16BIT)
{
else if (i.suffix != QWORD_MNEM_SUFFIX
&& !i.tm.opcode_modifier.ignoresize
&& !i.tm.opcode_modifier.floatmf
+ && !i.tm.opcode_modifier.vex
+ && !i.tm.opcode_modifier.vexopcode
+ && !is_evex_encoding (&i.tm)
&& ((i.suffix == LONG_MNEM_SUFFIX) == (flag_code == CODE_16BIT)
|| (flag_code == CODE_64BIT
&& i.tm.opcode_modifier.jumpbyte)))
run_list_test "intelbad" ""
run_dump_test "intelok"
run_dump_test "prefix"
+ run_list_test "prefix32" "-al"
run_dump_test "amd"
run_dump_test "katmai"
run_dump_test "jump"
run_list_test "suffix-bad"
run_list_test "x86-64-suffix-bad"
run_list_test "unspec64" ""
+ run_list_test "prefix64" "-al"
run_dump_test "x86-64-fxsave"
run_dump_test "x86-64-fxsave-intel"
run_dump_test "x86-64-arch-1"
--- /dev/null
+.*: Assembler messages:
+.*:6: Error: invalid .* `addss' after `repe'
+.*:7: Error: invalid .* `addss' after `repne'
+.*:8: Error: invalid .* `vaddss' after `repe'
+.*:9: Error: invalid .* `vaddss' after `repne'
+.*:14: Error: same type of prefix .*
+.*:15: Error: same type of prefix .*
+.*:19: Error: same type of prefix .*
+.*:20: Error: data size .* `vaddps'
+.*:21: Error: data size .* `vaddpd'
+GAS LISTING .*
+#...
+[ ]*1[ ]+\.text
+[ ]*2[ ]+prefix:
+[ ]*3[ ]+\?\?\?\? 67E203[ ]+addr16 loop \.Lrep_ret
+[ ]*4[ ]+\?\?\?\? 67E304[ ]+addr16 jecxz \.Ldata16
+[ ]*5[ ]*
+[ ]*6[ ]+repe addss %xmm0, %xmm0
+[ ]*7[ ]+repne addss %xmm0, %xmm0
+[ ]*8[ ]+repe vaddss %xmm0, %xmm0, %xmm0
+[ ]*9[ ]+repne vaddss %xmm0, %xmm0, %xmm0
+[ ]*10[ ]*
+[ ]*11[ ]+\.Lrep_ret:
+[ ]*12[ ]+\?\?\?\? F2C3[ ]+bnd ret
+[ ]*13[ ]+\?\?\?\? F3C3[ ]+rep ret
+[ ]*14[ ]+bnd rep ret
+[ ]*15[ ]+rep bnd ret
+[ ]*16[ ]*
+[ ]*17[ ]+\.Ldata16:
+[ ]*18[ ]+#bogus data16 addps %xmm0, %xmm0
+[ ]*19[ ]+\?\?\?\? 660F58C0[ ]+data16 addpd %xmm0, %xmm0
+\*\*\*\* Error: .*
+[ ]*20[ ]+data16 vaddps %xmm0, %xmm0, %xmm0
+[ ]*21[ ]+data16 vaddpd %xmm0, %xmm0, %xmm0
--- /dev/null
+ .text
+prefix:
+ addr16 loop .Lrep_ret
+ addr16 jecxz .Ldata16
+
+ repe addss %xmm0, %xmm0
+ repne addss %xmm0, %xmm0
+ repe vaddss %xmm0, %xmm0, %xmm0
+ repne vaddss %xmm0, %xmm0, %xmm0
+
+.Lrep_ret:
+ bnd ret
+ rep ret
+ bnd rep ret
+ rep bnd ret
+
+.Ldata16:
+#bogus data16 addps %xmm0, %xmm0
+ data16 addpd %xmm0, %xmm0
+ data16 vaddps %xmm0, %xmm0, %xmm0
+ data16 vaddpd %xmm0, %xmm0, %xmm0
--- /dev/null
+.*: Assembler messages:
+.*:6: Error: invalid .* `addss' after `repe'
+.*:7: Error: invalid .* `addss' after `repne'
+.*:8: Error: invalid .* `vaddss' after `repe'
+.*:9: Error: invalid .* `vaddss' after `repne'
+.*:14: Error: same type of prefix .*
+.*:15: Error: same type of prefix .*
+.*:19: Error: same type of prefix .*
+.*:20: Error: data size .* `vaddps'
+.*:21: Error: data size .* `vaddpd'
+GAS LISTING .*
+#...
+[ ]*1[ ]+\.text
+[ ]*2[ ]+prefix:
+[ ]*3[ ]+\?\?\?\? 67E203[ ]+addr32 loop \.Lrep_ret
+[ ]*4[ ]+\?\?\?\? 67E304[ ]+addr32 jrcxz \.Ldata16
+[ ]*5[ ]*
+[ ]*6[ ]+repe addss %xmm0, %xmm0
+[ ]*7[ ]+repne addss %xmm0, %xmm0
+[ ]*8[ ]+repe vaddss %xmm0, %xmm0, %xmm0
+[ ]*9[ ]+repne vaddss %xmm0, %xmm0, %xmm0
+[ ]*10[ ]*
+[ ]*11[ ]+\.Lrep_ret:
+[ ]*12[ ]+\?\?\?\? F2C3[ ]+bnd ret
+[ ]*13[ ]+\?\?\?\? F3C3[ ]+rep ret
+[ ]*14[ ]+bnd rep ret
+[ ]*15[ ]+rep bnd ret
+[ ]*16[ ]*
+[ ]*17[ ]+\.Ldata16:
+[ ]*18[ ]+#bogus data16 addps %xmm0, %xmm0
+[ ]*19[ ]+\?\?\?\? 660F58C0[ ]+data16 addpd %xmm0, %xmm0
+\*\*\*\* Error: .*
+[ ]*20[ ]+data16 vaddps %xmm0, %xmm0, %xmm0
+[ ]*21[ ]+data16 vaddpd %xmm0, %xmm0, %xmm0
--- /dev/null
+ .text
+prefix:
+ addr32 loop .Lrep_ret
+ addr32 jrcxz .Ldata16
+
+ repe addss %xmm0, %xmm0
+ repne addss %xmm0, %xmm0
+ repe vaddss %xmm0, %xmm0, %xmm0
+ repne vaddss %xmm0, %xmm0, %xmm0
+
+.Lrep_ret:
+ bnd ret
+ rep ret
+ bnd rep ret
+ rep bnd ret
+
+.Ldata16:
+#bogus data16 addps %xmm0, %xmm0
+ data16 addpd %xmm0, %xmm0
+ data16 vaddps %xmm0, %xmm0, %xmm0
+ data16 vaddpd %xmm0, %xmm0, %xmm0