1130803Smarcel/* Target-dependent code for the i387. 2130803Smarcel 3130803Smarcel Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. 4130803Smarcel 5130803Smarcel This file is part of GDB. 6130803Smarcel 7130803Smarcel This program is free software; you can redistribute it and/or modify 8130803Smarcel it under the terms of the GNU General Public License as published by 9130803Smarcel the Free Software Foundation; either version 2 of the License, or 10130803Smarcel (at your option) any later version. 11130803Smarcel 12130803Smarcel This program is distributed in the hope that it will be useful, 13130803Smarcel but WITHOUT ANY WARRANTY; without even the implied warranty of 14130803Smarcel MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15130803Smarcel GNU General Public License for more details. 16130803Smarcel 17130803Smarcel You should have received a copy of the GNU General Public License 18130803Smarcel along with this program; if not, write to the Free Software 19130803Smarcel Foundation, Inc., 59 Temple Place - Suite 330, 20130803Smarcel Boston, MA 02111-1307, USA. */ 21130803Smarcel 22130803Smarcel#ifndef I387_TDEP_H 23130803Smarcel#define I387_TDEP_H 24130803Smarcel 25130803Smarcelstruct gdbarch; 26130803Smarcelstruct frame_info; 27130803Smarcelstruct regcache; 28130803Smarcelstruct type; 29130803Smarcelstruct ui_file; 30130803Smarcel 31130803Smarcel/* Because the number of general-purpose registers is different for 32130803Smarcel AMD64, the floating-point registers and SSE registers get shifted. 33130803Smarcel The following definitions are intended to help writing code that 34130803Smarcel needs the register numbers of floating-point registers and SSE 35130803Smarcel registers. In order to use these, one should provide a definition 36130803Smarcel for I387_ST0_REGNUM, and possibly I387_NUM_XMM_REGS, preferably by 37130803Smarcel using a local "#define" in the body of the function that uses this. 38130803Smarcel Please "#undef" them before the end of the function. */ 39130803Smarcel 40130803Smarcel#define I387_FCTRL_REGNUM (I387_ST0_REGNUM + 8) 41130803Smarcel#define I387_FSTAT_REGNUM (I387_FCTRL_REGNUM + 1) 42130803Smarcel#define I387_FTAG_REGNUM (I387_FCTRL_REGNUM + 2) 43130803Smarcel#define I387_FISEG_REGNUM (I387_FCTRL_REGNUM + 3) 44130803Smarcel#define I387_FIOFF_REGNUM (I387_FCTRL_REGNUM + 4) 45130803Smarcel#define I387_FOSEG_REGNUM (I387_FCTRL_REGNUM + 5) 46130803Smarcel#define I387_FOOFF_REGNUM (I387_FCTRL_REGNUM + 6) 47130803Smarcel#define I387_FOP_REGNUM (I387_FCTRL_REGNUM + 7) 48130803Smarcel#define I387_XMM0_REGNUM (I387_ST0_REGNUM + 16) 49130803Smarcel#define I387_MXCSR_REGNUM (I387_XMM0_REGNUM + I387_NUM_XMM_REGS) 50130803Smarcel 51130803Smarcel 52130803Smarcel/* Print out the i387 floating point state. */ 53130803Smarcel 54130803Smarcelextern void i387_print_float_info (struct gdbarch *gdbarch, 55130803Smarcel struct ui_file *file, 56130803Smarcel struct frame_info *frame, 57130803Smarcel const char *args); 58130803Smarcel 59130803Smarcel/* Read a value of type TYPE from register REGNUM in frame FRAME, and 60130803Smarcel return its contents in TO. */ 61130803Smarcel 62130803Smarcelextern void i387_register_to_value (struct frame_info *frame, int regnum, 63130803Smarcel struct type *type, void *to); 64130803Smarcel 65130803Smarcel/* Write the contents FROM of a value of type TYPE into register 66130803Smarcel REGNUM in frame FRAME. */ 67130803Smarcel 68130803Smarcelextern void i387_value_to_register (struct frame_info *frame, int regnum, 69130803Smarcel struct type *type, const void *from); 70130803Smarcel 71130803Smarcel 72130803Smarcel/* Size of the memory area use by the 'fsave' and 'fxsave' 73130803Smarcel instructions. */ 74130803Smarcel#define I387_SIZEOF_FSAVE 108 75130803Smarcel#define I387_SIZEOF_FXSAVE 512 76130803Smarcel 77130803Smarcel/* Fill register REGNUM in REGCACHE with the appropriate value from 78130803Smarcel *FSAVE. This function masks off any of the reserved bits in 79130803Smarcel *FSAVE. */ 80130803Smarcel 81130803Smarcelextern void i387_supply_fsave (struct regcache *regcache, int regnum, 82130803Smarcel const void *fsave); 83130803Smarcel 84130803Smarcel/* Fill register REGNUM (if it is a floating-point register) in *FSAVE 85130803Smarcel with the value in GDB's register cache. If REGNUM is -1, do this 86130803Smarcel for all registers. This function doesn't touch any of the reserved 87130803Smarcel bits in *FSAVE. */ 88130803Smarcel 89130803Smarcelextern void i387_fill_fsave (void *fsave, int regnum); 90130803Smarcel 91130803Smarcel/* Fill register REGNUM in REGCACHE with the appropriate 92130803Smarcel floating-point or SSE register value from *FXSAVE. This function 93130803Smarcel masks off any of the reserved bits in *FXSAVE. */ 94130803Smarcel 95130803Smarcelextern void i387_supply_fxsave (struct regcache *regcache, int regnum, 96130803Smarcel const void *fxsave); 97130803Smarcel 98130803Smarcel/* Fill register REGNUM (if it is a floating-point or SSE register) in 99130803Smarcel *FXSAVE with the value from REGCACHE. If REGNUM is -1, do this for 100130803Smarcel all registers. This function doesn't touch any of the reserved 101130803Smarcel bits in *FXSAVE. */ 102130803Smarcel 103130803Smarcelextern void i387_collect_fxsave (const struct regcache *regcache, int regnum, 104130803Smarcel void *fxsave); 105130803Smarcel 106130803Smarcel/* Fill register REGNUM (if it is a floating-point or SSE register) in 107130803Smarcel *FXSAVE with the value in GDB's register cache. If REGNUM is -1, do 108130803Smarcel this for all registers. This function doesn't touch any of the 109130803Smarcel reserved bits in *FXSAVE. */ 110130803Smarcel 111130803Smarcelextern void i387_fill_fxsave (void *fxsave, int regnum); 112130803Smarcel 113130803Smarcel/* Prepare the FPU stack in REGCACHE for a function return. */ 114130803Smarcel 115130803Smarcelextern void i387_return_value (struct gdbarch *gdbarch, 116130803Smarcel struct regcache *regcache); 117130803Smarcel 118130803Smarcel#endif /* i387-tdep.h */ 119