1*6881a400Schristos /* Copyright (C) 2017-2023 Free Software Foundation, Inc. 27f2ac410Schristos 37f2ac410Schristos This file is part of GDB. 47f2ac410Schristos 57f2ac410Schristos This program is free software; you can redistribute it and/or modify 67f2ac410Schristos it under the terms of the GNU General Public License as published by 77f2ac410Schristos the Free Software Foundation; either version 3 of the License, or 87f2ac410Schristos (at your option) any later version. 97f2ac410Schristos 107f2ac410Schristos This program is distributed in the hope that it will be useful, 117f2ac410Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 127f2ac410Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 137f2ac410Schristos GNU General Public License for more details. 147f2ac410Schristos 157f2ac410Schristos You should have received a copy of the GNU General Public License 167f2ac410Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 177f2ac410Schristos 187d62b00eSchristos #include "gdbsupport/common-defs.h" 197f2ac410Schristos #include "i386.h" 207d62b00eSchristos #include "gdbsupport/tdesc.h" 217d62b00eSchristos #include "gdbsupport/x86-xstate.h" 227f2ac410Schristos #include <stdlib.h> 237f2ac410Schristos 247f2ac410Schristos #include "../features/i386/32bit-core.c" 257f2ac410Schristos #include "../features/i386/32bit-linux.c" 267f2ac410Schristos #include "../features/i386/32bit-sse.c" 277f2ac410Schristos #include "../features/i386/32bit-avx.c" 287f2ac410Schristos #include "../features/i386/32bit-avx512.c" 297f2ac410Schristos #include "../features/i386/32bit-mpx.c" 307d62b00eSchristos #include "../features/i386/32bit-segments.c" 31*6881a400Schristos #include "../features/i386/pkeys.c" 327f2ac410Schristos 337f2ac410Schristos /* Create i386 target descriptions according to XCR0. */ 347f2ac410Schristos 357f2ac410Schristos target_desc * 367d62b00eSchristos i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments) 377f2ac410Schristos { 38*6881a400Schristos target_desc_up tdesc = allocate_target_description (); 397f2ac410Schristos 407f2ac410Schristos #ifndef IN_PROCESS_AGENT 41*6881a400Schristos set_tdesc_architecture (tdesc.get (), "i386"); 427f2ac410Schristos if (is_linux) 43*6881a400Schristos set_tdesc_osabi (tdesc.get (), "GNU/Linux"); 447f2ac410Schristos #endif 457f2ac410Schristos 467f2ac410Schristos long regnum = 0; 477f2ac410Schristos 487f2ac410Schristos if (xcr0 & X86_XSTATE_X87) 49*6881a400Schristos regnum = create_feature_i386_32bit_core (tdesc.get (), regnum); 507f2ac410Schristos 517f2ac410Schristos if (xcr0 & X86_XSTATE_SSE) 52*6881a400Schristos regnum = create_feature_i386_32bit_sse (tdesc.get (), regnum); 537f2ac410Schristos 547f2ac410Schristos if (is_linux) 55*6881a400Schristos regnum = create_feature_i386_32bit_linux (tdesc.get (), regnum); 567f2ac410Schristos 577d62b00eSchristos if (segments) 58*6881a400Schristos regnum = create_feature_i386_32bit_segments (tdesc.get (), regnum); 597d62b00eSchristos 607f2ac410Schristos if (xcr0 & X86_XSTATE_AVX) 61*6881a400Schristos regnum = create_feature_i386_32bit_avx (tdesc.get (), regnum); 627f2ac410Schristos 637f2ac410Schristos if (xcr0 & X86_XSTATE_MPX) 64*6881a400Schristos regnum = create_feature_i386_32bit_mpx (tdesc.get (), regnum); 657f2ac410Schristos 667f2ac410Schristos if (xcr0 & X86_XSTATE_AVX512) 67*6881a400Schristos regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum); 687f2ac410Schristos 697f2ac410Schristos if (xcr0 & X86_XSTATE_PKRU) 70*6881a400Schristos regnum = create_feature_i386_pkeys (tdesc.get (), regnum); 717f2ac410Schristos 72*6881a400Schristos return tdesc.release (); 737f2ac410Schristos } 74