From e89c5eaa7208f06e927a79facff0316f4e550f6f Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 27 May 2016 06:55:42 -0700 Subject: [PATCH] Correct CpuMax in i386-opc.h CpuMax should be CpuIntel64, not CpuNo64. i386-gen.c is updated to verify that CpuMax is correct. X86 assembler is updated to properly set cpuamd64 and cpuintel64. gas/ PR gas/20154 * config/tc-i386.c (intel64): New. (cpu_flags_match): Set cpuamd64 and cpuintel64. (md_parse_option): Set intel64 instead of cpuamd64 and cpuintel64. opcodes/ PR gas/20154 * i386-gen.c (main): Fail if CpuMax is incorrect. * i386-opc.h (CpuMax): Set to CpuIntel64. * i386-tbl.h: Regenerated. --- gas/ChangeLog | 8 ++++++++ gas/config/tc-i386.c | 19 +++++++++++-------- opcodes/ChangeLog | 7 +++++++ opcodes/i386-gen.c | 11 ++++++++++- opcodes/i386-opc.h | 2 +- opcodes/i386-tbl.h | 4 ++-- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 0411e67..042b698 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,13 @@ 2016-05-27 H.J. Lu + PR gas/20154 + * config/tc-i386.c (intel64): New. + (cpu_flags_match): Set cpuamd64 and cpuintel64. + (md_parse_option): Set intel64 instead of cpuamd64 and + cpuintel64. + +2016-05-27 H.J. Lu + * config/tc-i386.c (cpu_flags_match): Don't clear cpu64 nor cpuno64. diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index fb3f369..f8a3bf0 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -535,6 +535,10 @@ static int shared = 0; 0 if att syntax. */ static int intel_syntax = 0; +/* 1 for Intel64 ISA, + 0 if AMD64 ISA. */ +static int intel64; + /* 1 for intel mnemonic, 0 if att mnemonic. */ static int intel_mnemonic = !SYSV386_COMPAT; @@ -1537,6 +1541,11 @@ cpu_flags_match (const insn_template *t) /* This instruction is available only on some archs. */ i386_cpu_flags cpu = cpu_arch_flags; + /* Set cpuamd64 and cpuintel64 here since they may be changed by + set_cpu_arch. */ + cpu_arch_flags.bitfield.cpuamd64 = !intel64; + cpu_arch_flags.bitfield.cpuintel64 = intel64; + cpu = cpu_flags_and (x, cpu); if (!cpu_flags_all_zero (&cpu)) { @@ -10107,17 +10116,11 @@ md_parse_option (int c, const char *arg) break; case OPTION_MAMD64: - cpu_arch_flags.bitfield.cpuamd64 = 1; - cpu_arch_flags.bitfield.cpuintel64 = 0; - cpu_arch_isa_flags.bitfield.cpuamd64 = 1; - cpu_arch_isa_flags.bitfield.cpuintel64 = 0; + intel64 = 0; break; case OPTION_MINTEL64: - cpu_arch_flags.bitfield.cpuamd64 = 0; - cpu_arch_flags.bitfield.cpuintel64 = 1; - cpu_arch_isa_flags.bitfield.cpuamd64 = 0; - cpu_arch_isa_flags.bitfield.cpuintel64 = 1; + intel64 = 1; break; default: diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 82e3143..eacd10b 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,10 @@ +2016-05-27 H.J. Lu + + PR gas/20154 + * i386-gen.c (main): Fail if CpuMax is incorrect. + * i386-opc.h (CpuMax): Set to CpuIntel64. + * i386-tbl.h: Regenerated. + 2016-05-27 Nick Clifton PR target/20150 diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c index b19bbe1..0afdc90 100644 --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -1379,7 +1379,16 @@ main (int argc, char **argv) srcdir, xstrerror (errno)); /* Check the unused bitfield in i386_cpu_flags. */ -#ifndef CpuUnused +#ifdef CpuUnused + if (cpu_flags[ARRAY_SIZE (cpu_flags) - 2].position != CpuMax) + fail (_("CpuMax != %d!\n"), + cpu_flags[ARRAY_SIZE (cpu_flags) - 2].position); + +#else + if (cpu_flags[ARRAY_SIZE (cpu_flags) - 1].position != CpuMax) + fail (_("CpuMax != %d!\n"), + cpu_flags[ARRAY_SIZE (cpu_flags) - 1].position); + c = CpuNumOfBits - CpuMax - 1; if (c) fail (_("%d unused bits in i386_cpu_flags.\n"), c); diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h index a93c1f3..0782b1a 100644 --- a/opcodes/i386-opc.h +++ b/opcodes/i386-opc.h @@ -211,7 +211,7 @@ enum /* Intel64 support required */ CpuIntel64, /* The last bitfield in i386_cpu_flags. */ - CpuMax = CpuNo64 + CpuMax = CpuIntel64 }; #define CpuNumOfUints \ diff --git a/opcodes/i386-tbl.h b/opcodes/i386-tbl.h index 70e10fb..5c5a991 100644 --- a/opcodes/i386-tbl.h +++ b/opcodes/i386-tbl.h @@ -3200,7 +3200,7 @@ const insn_template i386_optab[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 } }, + 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 } }, { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -3323,7 +3323,7 @@ const insn_template i386_optab[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 } }, + 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 } }, { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -- 2.7.4