2017-09-05 Yao Qi <yao.qi@linaro.org>
+ * amd64-linux-tdep.c: Include arch/amd64.h. Don't include
+ features/i386/*.c.
+ (amd64_linux_read_description): Call
+ amd64_create_target_description.
+ * arch/amd64.c: New file.
+ * arch/amd64.h: New file.
+ * configure.tgt (x86_64-*-linux*): Append amd64.o.
+ * Makefile.in (ALL_64_TARGET_OBS): Append amd64.o.
+
+2017-09-05 Yao Qi <yao.qi@linaro.org>
+
* amd64-linux-tdep.c: Don't include amd64-XXX-linux and
x32-XXX-linux.c. Include 64bit-XX.c and x32-XX.c.
(amd64_linux_read_description): Create target descriptions.
alpha-nbsd-tdep.o \
alpha-obsd-tdep.o \
alpha-tdep.o \
+ amd64.o \
amd64-darwin-tdep.o \
amd64-dicos-tdep.o \
amd64-fbsd-tdep.o \
#include "solib-svr4.h"
#include "xml-syscall.h"
#include "glibc-tdep.h"
+#include "arch/amd64.h"
#include "target-descriptions.h"
-#include "features/i386/64bit-avx.c"
-#include "features/i386/64bit-avx512.c"
-#include "features/i386/64bit-core.c"
-#include "features/i386/64bit-linux.c"
-#include "features/i386/64bit-mpx.c"
-#include "features/i386/64bit-pkeys.c"
-#include "features/i386/64bit-segments.c"
-#include "features/i386/64bit-sse.c"
-
-#include "features/i386/x32-core.c"
-
/* The syscall's XML filename for i386. */
#define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
}
if (*tdesc == NULL)
- {
- *tdesc = allocate_target_description ();
-
- set_tdesc_architecture (*tdesc,
- is_x32 ? "i386:x64-32" : "i386:x86-64");
-
- set_tdesc_osabi (*tdesc, osabi_from_tdesc_string ("GNU/Linux"));
-
- long regnum = 0;
-
- if (is_x32)
- regnum = create_feature_i386_x32_core (*tdesc, regnum);
- else
- regnum = create_feature_i386_64bit_core (*tdesc, regnum);
-
- regnum = create_feature_i386_64bit_sse (*tdesc, regnum);
- regnum = create_feature_i386_64bit_linux (*tdesc, regnum);
- regnum = create_feature_i386_64bit_segments (*tdesc, regnum);
-
- if (xcr0_features_bit & X86_XSTATE_AVX)
- regnum = create_feature_i386_64bit_avx (*tdesc, regnum);
-
- if ((xcr0_features_bit & X86_XSTATE_MPX) && !is_x32)
- regnum = create_feature_i386_64bit_mpx (*tdesc, regnum);
-
- if (xcr0_features_bit & X86_XSTATE_AVX512)
- regnum = create_feature_i386_64bit_avx512 (*tdesc, regnum);
-
- if ((xcr0_features_bit & X86_XSTATE_PKRU) && !is_x32)
- regnum = create_feature_i386_64bit_pkeys (*tdesc, regnum);
- }
+ *tdesc = amd64_create_target_description (xcr0_features_bit, is_x32);
return *tdesc;
}
--- /dev/null
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "amd64.h"
+#include "x86-xstate.h"
+#include <stdlib.h>
+
+#include "../features/i386/64bit-avx.c"
+#include "../features/i386/64bit-avx512.c"
+#include "../features/i386/64bit-core.c"
+#include "../features/i386/64bit-linux.c"
+#include "../features/i386/64bit-mpx.c"
+#include "../features/i386/64bit-pkeys.c"
+#include "../features/i386/64bit-segments.c"
+#include "../features/i386/64bit-sse.c"
+
+#include "../features/i386/x32-core.c"
+
+/* Create amd64 target descriptions according to XCR0. If IS_X32 is
+ true, create the x32 ones. */
+
+target_desc *
+amd64_create_target_description (uint64_t xcr0, bool is_x32)
+{
+ target_desc *tdesc = allocate_target_description ();
+
+#ifndef IN_PROCESS_AGENT
+ set_tdesc_architecture (tdesc, is_x32 ? "i386:x64-32" : "i386:x86-64");
+
+ set_tdesc_osabi (tdesc, "GNU/Linux");
+#endif
+
+ long regnum = 0;
+
+ if (is_x32)
+ regnum = create_feature_i386_x32_core (tdesc, regnum);
+ else
+ regnum = create_feature_i386_64bit_core (tdesc, regnum);
+
+ regnum = create_feature_i386_64bit_sse (tdesc, regnum);
+ regnum = create_feature_i386_64bit_linux (tdesc, regnum);
+ regnum = create_feature_i386_64bit_segments (tdesc, regnum);
+
+ if (xcr0 & X86_XSTATE_AVX)
+ regnum = create_feature_i386_64bit_avx (tdesc, regnum);
+
+ if ((xcr0 & X86_XSTATE_MPX) && !is_x32)
+ regnum = create_feature_i386_64bit_mpx (tdesc, regnum);
+
+ if (xcr0 & X86_XSTATE_AVX512)
+ regnum = create_feature_i386_64bit_avx512 (tdesc, regnum);
+
+ if ((xcr0 & X86_XSTATE_PKRU) && !is_x32)
+ regnum = create_feature_i386_64bit_pkeys (tdesc, regnum);
+
+ return tdesc;
+}
--- /dev/null
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "tdesc.h"
+#include <stdint.h>
+
+target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32);
;;
x86_64-*-linux*)
# Target: GNU/Linux x86-64
- gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o i386-tdep.o \
+ gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o amd64.o i386-tdep.o \
i387-tdep.o i386.o i386-linux-tdep.o glibc-tdep.o \
solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
build_gdbserver=yes
2017-09-05 Yao Qi <yao.qi@linaro.org>
+ * Makefile.in (arch-amd64.o): New rule.
+ * configure.srv: Append arch-amd64.o.
+ * linux-amd64-ipa.c: Include common/x86-xstate.h.
+ (get_ipa_tdesc): Call amd64_linux_read_description.
+ (initialize_low_tracepoint): Don't call init_registers_x32_XXX
+ and init_registers_amd64_XXX.
+ * linux-x86-low.c (x86_linux_read_description): Call
+ amd64_linux_read_description.
+ (x86_get_ipa_tdesc_idx): Call amd64_get_ipa_tdesc_idx.
+ (initialize_low_arch): Don't call init_registers_x32_XXX and
+ init_registers_amd64_XXX.
+ * linux-x86-tdesc-selftest.c: Declare init_registers_amd64_XXX
+ and tdesc_amd64_XXX.
+ [__x86_64__] (amd64_tdesc_test): New function.
+ (initialize_low_tdesc) [__x86_64__]: Call init_registers_x32_XXX
+ and init_registers_amd64_XXX.
+ * linux-x86-tdesc.c: Include arch/amd64.h.
+ (xcr0_to_tdesc_idx): New function.
+ (i386_linux_read_description): New function.
+ (amd64_get_ipa_tdesc_idx): New function.
+ * linux-x86-tdesc.h (amd64_get_ipa_tdesc_idx): Declare.
+ (amd64_get_ipa_tdesc): Declare.
+
+2017-09-05 Yao Qi <yao.qi@linaro.org>
+
* configure.srv (srv_i386_linux_xmlfiles): Remove
i386/i386-XXX-linux.xml from it.
$(COMPILE) $<
$(POSTCOMPILE)
+arch-amd64.o: ../arch/amd64.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
# Rules for objects that go in the in-process agent.
%-ipa.o: %-generated.c
;;
x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj"
srv_tgtobj="$srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o"
- srv_tgtobj="${srv_tgtobj} arch-i386.o"
+ srv_tgtobj="${srv_tgtobj} arch-i386.o arch-amd64.o"
srv_tgtobj="${srv_tgtobj} linux-x86-tdesc.o"
srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o"
srv_tgtobj="${srv_tgtobj} x86-linux-dregs.o"
ipa_obj="${ipa_amd64_linux_regobj}"
fi
ipa_obj="${ipa_obj} linux-amd64-ipa.o linux-x86-tdesc-ipa.o"
+ ipa_obj="${ipa_obj} amd64-ipa.o"
;;
x86_64-*-mingw*) srv_regobj="$srv_amd64_regobj"
srv_tgtobj="x86-low.o x86-dregs.o i387-fp.o win32-low.o win32-i386-low.o"
#include <sys/mman.h>
#include "tracepoint.h"
#include "linux-x86-tdesc.h"
+#include "common/x86-xstate.h"
/* Defined in auto-generated file amd64-linux.c. */
void init_registers_amd64_linux (void);
const struct target_desc *
get_ipa_tdesc (int idx)
{
+ if (idx >= X86_TDESC_LAST)
+ {
+ internal_error (__FILE__, __LINE__,
+ "unknown ipa tdesc index: %d", idx);
+ }
+
#if defined __ILP32__
switch (idx)
{
case X86_TDESC_SSE:
- return tdesc_x32_linux;
+ return amd64_linux_read_description (X86_XSTATE_SSE_MASK, true);
case X86_TDESC_AVX:
- return tdesc_x32_avx_linux;
+ return amd64_linux_read_description (X86_XSTATE_AVX_MASK, true);
case X86_TDESC_AVX_AVX512:
- return tdesc_x32_avx_avx512_linux;
+ return amd64_linux_read_description (X86_XSTATE_AVX_AVX512_MASK, true);
default:
break;
}
#else
- switch (idx)
- {
- case X86_TDESC_SSE:
- return tdesc_amd64_linux;
- case X86_TDESC_AVX:
- return tdesc_amd64_avx_linux;
- case X86_TDESC_MPX:
- return tdesc_amd64_mpx_linux;
- case X86_TDESC_AVX_MPX:
- return tdesc_amd64_avx_mpx_linux;
- case X86_TDESC_AVX_MPX_AVX512_PKU:
- return tdesc_amd64_avx_mpx_avx512_pku_linux;
- case X86_TDESC_AVX_AVX512:
- return tdesc_amd64_avx_avx512_linux;
- default:
- internal_error (__FILE__, __LINE__,
- "unknown ipa tdesc index: %d", idx);
- return tdesc_amd64_linux;
- }
+ /* Map the tdesc index to xcr0 mask. */
+ uint64_t idx2mask[X86_TDESC_LAST] = {
+ X86_XSTATE_X87_MASK,
+ X86_XSTATE_SSE_MASK,
+ X86_XSTATE_AVX_MASK,
+ X86_XSTATE_MPX_MASK,
+ X86_XSTATE_AVX_MPX_MASK,
+ X86_XSTATE_AVX_AVX512_MASK,
+ X86_XSTATE_AVX_MPX_AVX512_PKU_MASK,
+ };
+
+ return amd64_linux_read_description (idx2mask[idx], false);
#endif
internal_error (__FILE__, __LINE__,
void
initialize_low_tracepoint (void)
{
-#if defined __ILP32__
- init_registers_x32_linux ();
- init_registers_x32_avx_linux ();
- init_registers_x32_avx_avx512_linux ();
-#else
- init_registers_amd64_linux ();
- init_registers_amd64_avx_linux ();
- init_registers_amd64_mpx_linux ();
- init_registers_amd64_avx_mpx_linux ();
- init_registers_amd64_avx_avx512_linux ();
- init_registers_amd64_avx_mpx_avx512_pku_linux ();
-#endif
}
if (machine == EM_X86_64)
{
#ifdef __x86_64__
- if (is_elf64)
- {
- if (xcr0_features)
- {
- switch (xcr0 & X86_XSTATE_ALL_MASK)
- {
- case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- return tdesc_amd64_avx_mpx_avx512_pku_linux;
-
- case X86_XSTATE_AVX_AVX512_MASK:
- return tdesc_amd64_avx_avx512_linux;
-
- case X86_XSTATE_AVX_MPX_MASK:
- return tdesc_amd64_avx_mpx_linux;
-
- case X86_XSTATE_MPX_MASK:
- return tdesc_amd64_mpx_linux;
-
- case X86_XSTATE_AVX_MASK:
- return tdesc_amd64_avx_linux;
+ const target_desc *tdesc = NULL;
- default:
- return tdesc_amd64_linux;
- }
- }
- else
- return tdesc_amd64_linux;
- }
- else
+ if (xcr0_features)
{
- if (xcr0_features)
- {
- switch (xcr0 & X86_XSTATE_ALL_MASK)
- {
- case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- /* No x32 MPX and PKU, fall back to avx_avx512. */
- return tdesc_x32_avx_avx512_linux;
-
- case X86_XSTATE_AVX_AVX512_MASK:
- return tdesc_x32_avx_avx512_linux;
-
- case X86_XSTATE_MPX_MASK: /* No MPX on x32. */
- case X86_XSTATE_AVX_MASK:
- return tdesc_x32_avx_linux;
-
- default:
- return tdesc_x32_linux;
- }
- }
- else
- return tdesc_x32_linux;
+ tdesc = amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
+ !is_elf64);
}
+
+ if (tdesc == NULL)
+ tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, !is_elf64);
+ return tdesc;
#endif
}
else
const struct target_desc *tdesc = regcache->tdesc;
#ifdef __x86_64__
- if (tdesc == tdesc_amd64_linux || tdesc == tdesc_amd64_linux_no_xml
- || tdesc == tdesc_x32_linux)
- return X86_TDESC_SSE;
- if (tdesc == tdesc_amd64_avx_linux || tdesc == tdesc_x32_avx_linux)
- return X86_TDESC_AVX;
- if (tdesc == tdesc_amd64_mpx_linux)
- return X86_TDESC_MPX;
- if (tdesc == tdesc_amd64_avx_mpx_linux)
- return X86_TDESC_AVX_MPX;
- if (tdesc == tdesc_amd64_avx_mpx_avx512_pku_linux || tdesc == tdesc_x32_avx_avx512_linux)
- return X86_TDESC_AVX_MPX_AVX512_PKU;
- if (tdesc == tdesc_amd64_avx_avx512_linux)
- return X86_TDESC_AVX_AVX512;
+ return amd64_get_ipa_tdesc_idx (tdesc);
#endif
if (tdesc == tdesc_i386_linux_no_xml)
{
/* Initialize the Linux target descriptions. */
#ifdef __x86_64__
- init_registers_amd64_linux ();
- init_registers_amd64_avx_linux ();
- init_registers_amd64_mpx_linux ();
- init_registers_amd64_avx_mpx_linux ();
- init_registers_amd64_avx_avx512_linux ();
- init_registers_amd64_avx_mpx_avx512_pku_linux ();
-
- init_registers_x32_linux ();
- init_registers_x32_avx_linux ();
- init_registers_x32_avx_avx512_linux ();
-
tdesc_amd64_linux_no_xml = XNEW (struct target_desc);
- copy_target_description (tdesc_amd64_linux_no_xml, tdesc_amd64_linux);
+ copy_target_description (tdesc_amd64_linux_no_xml,
+ amd64_linux_read_description (X86_XSTATE_SSE_MASK,
+ false));
tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml;
#endif
void init_registers_i386_mpx_linux (void);
extern const struct target_desc *tdesc_i386_mpx_linux;
+#ifdef __x86_64__
+
+/* Defined in auto-generated file amd64-linux.c. */
+void init_registers_amd64_linux (void);
+extern const struct target_desc *tdesc_amd64_linux;
+
+/* Defined in auto-generated file amd64-avx-linux.c. */
+void init_registers_amd64_avx_linux (void);
+extern const struct target_desc *tdesc_amd64_avx_linux;
+
+/* Defined in auto-generated file amd64-avx-avx512-linux.c. */
+void init_registers_amd64_avx_avx512_linux (void);
+extern const struct target_desc *tdesc_amd64_avx_avx512_linux;
+
+/* Defined in auto-generated file amd64-avx-mpx-avx512-pku-linux.c. */
+void init_registers_amd64_avx_mpx_avx512_pku_linux (void);
+extern const struct target_desc *tdesc_amd64_avx_mpx_avx512_pku_linux;
+
+/* Defined in auto-generated file amd64-avx-mpx-linux.c. */
+void init_registers_amd64_avx_mpx_linux (void);
+extern const struct target_desc *tdesc_amd64_avx_mpx_linux;
+
+/* Defined in auto-generated file amd64-mpx-linux.c. */
+void init_registers_amd64_mpx_linux (void);
+extern const struct target_desc *tdesc_amd64_mpx_linux;
+
+/* Defined in auto-generated file x32-linux.c. */
+void init_registers_x32_linux (void);
+extern const struct target_desc *tdesc_x32_linux;
+
+/* Defined in auto-generated file x32-avx-linux.c. */
+void init_registers_x32_avx_linux (void);
+extern const struct target_desc *tdesc_x32_avx_linux;
+
+/* Defined in auto-generated file x32-avx-avx512-linux.c. */
+void init_registers_x32_avx_avx512_linux (void);
+extern const struct target_desc *tdesc_x32_avx_avx512_linux;
+
+#endif
+
namespace selftests {
namespace tdesc {
static void
SELF_CHECK (*tdesc == *elem.tdesc);
}
}
+
+#ifdef __x86_64__
+
+static void
+amd64_tdesc_test ()
+{
+ struct
+ {
+ unsigned int mask;
+ const target_desc *tdesc[2];
+ } tdesc_tests[] = {
+ { X86_XSTATE_SSE_MASK, { tdesc_amd64_linux, tdesc_x32_linux } },
+ { X86_XSTATE_AVX_MASK, { tdesc_amd64_avx_linux, tdesc_x32_avx_linux } },
+ { X86_XSTATE_MPX_MASK, { tdesc_amd64_mpx_linux, tdesc_x32_avx_linux } },
+ { X86_XSTATE_AVX_MPX_MASK, { tdesc_amd64_avx_mpx_linux,
+ tdesc_x32_avx_linux } },
+ { X86_XSTATE_AVX_AVX512_MASK, { tdesc_amd64_avx_avx512_linux,
+ tdesc_x32_avx_avx512_linux } },
+ { X86_XSTATE_AVX_MPX_AVX512_PKU_MASK,
+ { tdesc_amd64_avx_mpx_avx512_pku_linux, tdesc_x32_avx_avx512_linux } },
+ };
+
+ for (auto &elem : tdesc_tests)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ const target_desc *tdesc = amd64_linux_read_description (elem.mask,
+ i);
+
+ SELF_CHECK (*tdesc == *elem.tdesc[i]);
+ }
+ }
+}
+
+#endif
}
} // namespace selftests
init_registers_i386_avx_mpx_avx512_pku_linux ();
selftests::register_test (selftests::tdesc::i386_tdesc_test);
+
+#ifdef __x86_64__
+ init_registers_x32_linux ();
+ init_registers_x32_avx_linux ();
+ init_registers_x32_avx_avx512_linux ();
+
+ init_registers_amd64_linux ();
+ init_registers_amd64_avx_linux ();
+ init_registers_amd64_mpx_linux ();
+ init_registers_amd64_avx_mpx_linux ();
+ init_registers_amd64_avx_avx512_linux ();
+ init_registers_amd64_avx_mpx_avx512_pku_linux ();
+
+ selftests::register_test (selftests::tdesc::amd64_tdesc_test);
+#endif
}
#include "linux-x86-tdesc.h"
#include "arch/i386.h"
#include "common/x86-xstate.h"
+#ifdef __x86_64__
+#include "arch/amd64.h"
+#endif
-static struct target_desc *i386_tdescs[X86_TDESC_LAST] = { };
+/* Return the right x86_linux_tdesc index for a given XCR0. Return
+ X86_TDESC_LAST if can't find a match. */
-#if defined __i386__ || !defined IN_PROCESS_AGENT
-
-/* Return the target description according to XCR0. */
-
-const struct target_desc *
-i386_linux_read_description (uint64_t xcr0)
+static enum x86_linux_tdesc
+xcr0_to_tdesc_idx (uint64_t xcr0, bool is_x32)
{
- struct target_desc **tdesc = NULL;
-
if (xcr0 & X86_XSTATE_PKRU)
- tdesc = &i386_tdescs[X86_TDESC_AVX_MPX_AVX512_PKU];
+ {
+ if (is_x32)
+ {
+ /* No x32 MPX and PKU, fall back to avx_avx512. */
+ return X86_TDESC_AVX_AVX512;
+ }
+ else
+ return X86_TDESC_AVX_MPX_AVX512_PKU;
+ }
else if (xcr0 & X86_XSTATE_AVX512)
- tdesc = &i386_tdescs[X86_TDESC_AVX_AVX512];
+ return X86_TDESC_AVX_AVX512;
else if ((xcr0 & X86_XSTATE_AVX_MPX_MASK) == X86_XSTATE_AVX_MPX_MASK)
- tdesc = &i386_tdescs[X86_TDESC_AVX_MPX];
+ {
+ if (is_x32) /* No MPX on x32. */
+ return X86_TDESC_AVX;
+ else
+ return X86_TDESC_AVX_MPX;
+ }
else if (xcr0 & X86_XSTATE_MPX)
- tdesc = &i386_tdescs[X86_TDESC_MPX];
+ {
+ if (is_x32) /* No MPX on x32. */
+ return X86_TDESC_AVX;
+ else
+ return X86_TDESC_MPX;
+ }
else if (xcr0 & X86_XSTATE_AVX)
- tdesc = &i386_tdescs[X86_TDESC_AVX];
+ return X86_TDESC_AVX;
else if (xcr0 & X86_XSTATE_SSE)
- tdesc = &i386_tdescs[X86_TDESC_SSE];
+ return X86_TDESC_SSE;
else if (xcr0 & X86_XSTATE_X87)
- tdesc = &i386_tdescs[X86_TDESC_MMX];
+ return X86_TDESC_MMX;
+ else
+ return X86_TDESC_LAST;
+}
- if (tdesc == NULL)
+static struct target_desc *i386_tdescs[X86_TDESC_LAST] = { };
+
+#if defined __i386__ || !defined IN_PROCESS_AGENT
+
+/* Return the target description according to XCR0. */
+
+const struct target_desc *
+i386_linux_read_description (uint64_t xcr0)
+{
+ enum x86_linux_tdesc idx = xcr0_to_tdesc_idx (xcr0, false);
+
+ if (idx == X86_TDESC_LAST)
return NULL;
+ struct target_desc **tdesc = &i386_tdescs[idx];
+
if (*tdesc == NULL)
{
*tdesc = i386_create_target_description (xcr0);
}
#endif
+#ifdef __x86_64__
+
+static target_desc *amd64_tdescs[X86_TDESC_LAST] = { };
+static target_desc *x32_tdescs[X86_TDESC_LAST] = { };
+
+const struct target_desc *
+amd64_linux_read_description (uint64_t xcr0, bool is_x32)
+{
+ enum x86_linux_tdesc idx = xcr0_to_tdesc_idx (xcr0, is_x32);
+
+ if (idx == X86_TDESC_LAST)
+ return NULL;
+
+ struct target_desc **tdesc = NULL;
+
+ if (is_x32)
+ tdesc = &x32_tdescs[idx];
+ else
+ tdesc = &amd64_tdescs[idx];
+
+ if (*tdesc == NULL)
+ {
+ *tdesc = amd64_create_target_description (xcr0, is_x32);
+
+ init_target_desc (*tdesc);
+
+#ifndef IN_PROCESS_AGENT
+ static const char *expedite_regs_amd64[] = { "rbp", "rsp", "rip", NULL };
+ (*tdesc)->expedite_regs = expedite_regs_amd64;
+#endif
+ }
+ return *tdesc;
+}
+
+#endif
+
#ifndef IN_PROCESS_AGENT
+
int
i386_get_ipa_tdesc_idx (const struct target_desc *tdesc)
{
return X86_TDESC_MMX;
}
+#if defined __x86_64__
+int
+amd64_get_ipa_tdesc_idx (const struct target_desc *tdesc)
+{
+ for (int i = 0; i < X86_TDESC_LAST; i++)
+ {
+ if (tdesc == amd64_tdescs[i])
+ return i;
+ }
+ for (int i = 0; i < X86_TDESC_LAST; i++)
+ {
+ if (tdesc == x32_tdescs[i])
+ return i;
+ }
+
+ return X86_TDESC_SSE;
+}
+
+#endif
#endif
X86_TDESC_LAST = 7,
};
-#ifdef __x86_64__
-
-#if defined __LP64__ || !defined IN_PROCESS_AGENT
-/* Defined in auto-generated file amd64-linux.c. */
-void init_registers_amd64_linux (void);
-extern const struct target_desc *tdesc_amd64_linux;
-
-/* Defined in auto-generated file amd64-avx-linux.c. */
-void init_registers_amd64_avx_linux (void);
-extern const struct target_desc *tdesc_amd64_avx_linux;
-
-/* Defined in auto-generated file amd64-avx-avx512-linux.c. */
-void init_registers_amd64_avx_avx512_linux (void);
-extern const struct target_desc *tdesc_amd64_avx_avx512_linux;
-
-/* Defined in auto-generated file amd64-avx-mpx-avx512-pku-linux.c. */
-void init_registers_amd64_avx_mpx_avx512_pku_linux (void);
-extern const struct target_desc *tdesc_amd64_avx_mpx_avx512_pku_linux;
-
-/* Defined in auto-generated file amd64-avx-mpx-linux.c. */
-void init_registers_amd64_avx_mpx_linux (void);
-extern const struct target_desc *tdesc_amd64_avx_mpx_linux;
-
-/* Defined in auto-generated file amd64-mpx-linux.c. */
-void init_registers_amd64_mpx_linux (void);
-extern const struct target_desc *tdesc_amd64_mpx_linux;
+#if defined __i386__ || !defined IN_PROCESS_AGENT
+int i386_get_ipa_tdesc_idx (const struct target_desc *tdesc);
#endif
-#if defined __ILP32__ || !defined IN_PROCESS_AGENT
-/* Defined in auto-generated file x32-linux.c. */
-void init_registers_x32_linux (void);
-extern const struct target_desc *tdesc_x32_linux;
-
-/* Defined in auto-generated file x32-avx-linux.c. */
-void init_registers_x32_avx_linux (void);
-extern const struct target_desc *tdesc_x32_avx_linux;
-
-/* Defined in auto-generated file x32-avx-avx512-linux.c. */
-void init_registers_x32_avx_avx512_linux (void);
-extern const struct target_desc *tdesc_x32_avx_avx512_linux;
+#if defined __x86_64__ && !defined IN_PROCESS_AGENT
+int amd64_get_ipa_tdesc_idx (const struct target_desc *tdesc);
#endif
-#endif
+const struct target_desc *i386_get_ipa_tdesc (int idx);
-#if defined __i386__ || !defined IN_PROCESS_AGENT
-int i386_get_ipa_tdesc_idx (const struct target_desc *tdesc);
+#ifdef __x86_64__
+const struct target_desc *amd64_linux_read_description (uint64_t xcr0,
+ bool is_x32);
#endif
const struct target_desc *i386_linux_read_description (uint64_t xcr0);