15796c8dcSSimon Schubert /* Target-dependent code for the i387. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright (C) 2000-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #ifndef I387_TDEP_H 215796c8dcSSimon Schubert #define I387_TDEP_H 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert struct gdbarch; 245796c8dcSSimon Schubert struct frame_info; 255796c8dcSSimon Schubert struct regcache; 265796c8dcSSimon Schubert struct type; 275796c8dcSSimon Schubert struct ui_file; 285796c8dcSSimon Schubert 29cf7f2e2dSJohn Marino /* Number of i387 floating point registers. */ 30cf7f2e2dSJohn Marino #define I387_NUM_REGS 16 31cf7f2e2dSJohn Marino 325796c8dcSSimon Schubert #define I387_ST0_REGNUM(tdep) ((tdep)->st0_regnum) 335796c8dcSSimon Schubert #define I387_NUM_XMM_REGS(tdep) ((tdep)->num_xmm_regs) 345796c8dcSSimon Schubert #define I387_MM0_REGNUM(tdep) ((tdep)->mm0_regnum) 35cf7f2e2dSJohn Marino #define I387_NUM_YMM_REGS(tdep) ((tdep)->num_ymm_regs) 36cf7f2e2dSJohn Marino #define I387_YMM0H_REGNUM(tdep) ((tdep)->ymm0h_regnum) 375796c8dcSSimon Schubert 385796c8dcSSimon Schubert #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 8) 395796c8dcSSimon Schubert #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 1) 405796c8dcSSimon Schubert #define I387_FTAG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 2) 415796c8dcSSimon Schubert #define I387_FISEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 3) 425796c8dcSSimon Schubert #define I387_FIOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 4) 435796c8dcSSimon Schubert #define I387_FOSEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 5) 445796c8dcSSimon Schubert #define I387_FOOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 6) 455796c8dcSSimon Schubert #define I387_FOP_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 7) 465796c8dcSSimon Schubert #define I387_XMM0_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 16) 475796c8dcSSimon Schubert #define I387_MXCSR_REGNUM(tdep) \ 485796c8dcSSimon Schubert (I387_XMM0_REGNUM (tdep) + I387_NUM_XMM_REGS (tdep)) 49cf7f2e2dSJohn Marino #define I387_YMMENDH_REGNUM(tdep) \ 50cf7f2e2dSJohn Marino (I387_YMM0H_REGNUM (tdep) + I387_NUM_YMM_REGS (tdep)) 515796c8dcSSimon Schubert 525796c8dcSSimon Schubert /* Print out the i387 floating point state. */ 535796c8dcSSimon Schubert 545796c8dcSSimon Schubert extern void i387_print_float_info (struct gdbarch *gdbarch, 555796c8dcSSimon Schubert struct ui_file *file, 565796c8dcSSimon Schubert struct frame_info *frame, 575796c8dcSSimon Schubert const char *args); 585796c8dcSSimon Schubert 595796c8dcSSimon Schubert /* Return nonzero if a value of type TYPE stored in register REGNUM 605796c8dcSSimon Schubert needs any special handling. */ 615796c8dcSSimon Schubert 625796c8dcSSimon Schubert extern int i387_convert_register_p (struct gdbarch *gdbarch, int regnum, 635796c8dcSSimon Schubert struct type *type); 645796c8dcSSimon Schubert 655796c8dcSSimon Schubert /* Read a value of type TYPE from register REGNUM in frame FRAME, and 665796c8dcSSimon Schubert return its contents in TO. */ 675796c8dcSSimon Schubert 68c50c785cSJohn Marino extern int i387_register_to_value (struct frame_info *frame, int regnum, 69c50c785cSJohn Marino struct type *type, gdb_byte *to, 70c50c785cSJohn Marino int *optimizedp, int *unavailablep); 715796c8dcSSimon Schubert 725796c8dcSSimon Schubert /* Write the contents FROM of a value of type TYPE into register 735796c8dcSSimon Schubert REGNUM in frame FRAME. */ 745796c8dcSSimon Schubert 755796c8dcSSimon Schubert extern void i387_value_to_register (struct frame_info *frame, int regnum, 765796c8dcSSimon Schubert struct type *type, const gdb_byte *from); 775796c8dcSSimon Schubert 785796c8dcSSimon Schubert 795796c8dcSSimon Schubert /* Size of the memory area use by the 'fsave' and 'fxsave' 805796c8dcSSimon Schubert instructions. */ 815796c8dcSSimon Schubert #define I387_SIZEOF_FSAVE 108 825796c8dcSSimon Schubert #define I387_SIZEOF_FXSAVE 512 835796c8dcSSimon Schubert 845796c8dcSSimon Schubert /* Fill register REGNUM in REGCACHE with the appropriate value from 855796c8dcSSimon Schubert *FSAVE. This function masks off any of the reserved bits in 865796c8dcSSimon Schubert *FSAVE. */ 875796c8dcSSimon Schubert 885796c8dcSSimon Schubert extern void i387_supply_fsave (struct regcache *regcache, int regnum, 895796c8dcSSimon Schubert const void *fsave); 905796c8dcSSimon Schubert 915796c8dcSSimon Schubert /* Fill register REGNUM (if it is a floating-point register) in *FSAVE 925796c8dcSSimon Schubert with the value from REGCACHE. If REGNUM is -1, do this for all 935796c8dcSSimon Schubert registers. This function doesn't touch any of the reserved bits in 945796c8dcSSimon Schubert *FSAVE. */ 955796c8dcSSimon Schubert 965796c8dcSSimon Schubert extern void i387_collect_fsave (const struct regcache *regcache, int regnum, 975796c8dcSSimon Schubert void *fsave); 985796c8dcSSimon Schubert 995796c8dcSSimon Schubert /* Fill register REGNUM in REGCACHE with the appropriate 1005796c8dcSSimon Schubert floating-point or SSE register value from *FXSAVE. This function 1015796c8dcSSimon Schubert masks off any of the reserved bits in *FXSAVE. */ 1025796c8dcSSimon Schubert 1035796c8dcSSimon Schubert extern void i387_supply_fxsave (struct regcache *regcache, int regnum, 1045796c8dcSSimon Schubert const void *fxsave); 1055796c8dcSSimon Schubert 106cf7f2e2dSJohn Marino /* Similar to i387_supply_fxsave, but use XSAVE extended state. */ 107cf7f2e2dSJohn Marino 108cf7f2e2dSJohn Marino extern void i387_supply_xsave (struct regcache *regcache, int regnum, 109cf7f2e2dSJohn Marino const void *xsave); 110cf7f2e2dSJohn Marino 1115796c8dcSSimon Schubert /* Fill register REGNUM (if it is a floating-point or SSE register) in 1125796c8dcSSimon Schubert *FXSAVE with the value from REGCACHE. If REGNUM is -1, do this for 1135796c8dcSSimon Schubert all registers. This function doesn't touch any of the reserved 1145796c8dcSSimon Schubert bits in *FXSAVE. */ 1155796c8dcSSimon Schubert 1165796c8dcSSimon Schubert extern void i387_collect_fxsave (const struct regcache *regcache, int regnum, 1175796c8dcSSimon Schubert void *fxsave); 1185796c8dcSSimon Schubert 119cf7f2e2dSJohn Marino /* Similar to i387_collect_fxsave, but use XSAVE extended state. */ 120cf7f2e2dSJohn Marino 121cf7f2e2dSJohn Marino extern void i387_collect_xsave (const struct regcache *regcache, 122cf7f2e2dSJohn Marino int regnum, void *xsave, int gcore); 123cf7f2e2dSJohn Marino 1245796c8dcSSimon Schubert /* Prepare the FPU stack in REGCACHE for a function return. */ 1255796c8dcSSimon Schubert 1265796c8dcSSimon Schubert extern void i387_return_value (struct gdbarch *gdbarch, 1275796c8dcSSimon Schubert struct regcache *regcache); 1285796c8dcSSimon Schubert 1295796c8dcSSimon Schubert #endif /* i387-tdep.h */ 130