1 /* This file is part of the program psim.
3 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #ifndef STATIC_INLINE_REGISTERS
26 #define STATIC_INLINE_REGISTERS STATIC_INLINE
33 #include "registers.h"
49 registers_dump(registers
*registers
)
53 for (i
= 0; i
< 8; i
++) {
54 printf_filtered("GPR %2d:", i
*4);
55 for (j
= 0; j
< 4; j
++) {
56 printf_filtered(" 0x%08x", registers
->gpr
[i
*4 + j
]);
58 printf_filtered("\n");
62 STATIC_INLINE_REGISTERS sprs
63 find_spr(const char name
[])
66 for (spr
= 0; spr
< nr_of_sprs
; spr
++)
68 && !strcmp(name
, spr_name(spr
))
69 && spr_index(spr
) == spr
)
74 STATIC_INLINE_REGISTERS
int
75 are_digits(const char *digits
)
77 while (isdigit(*digits
))
79 return *digits
== '\0';
83 INLINE_REGISTERS register_descriptions
84 register_description(const char reg
[])
86 register_descriptions description
;
88 /* try for a general-purpose integer or floating point register */
89 if (reg
[0] == 'r' && are_digits(reg
+ 1)) {
90 description
.type
= reg_gpr
;
91 description
.index
= atoi(reg
+1);
92 description
.size
= sizeof(gpreg
);
94 else if (reg
[0] == 'f' && are_digits(reg
+ 1)) {
95 description
.type
= reg_fpr
;
96 description
.index
= atoi(reg
+1);
97 description
.size
= sizeof(fpreg
);
99 else if (!strcmp(reg
, "pc") || !strcmp(reg
, "nia")) {
100 description
.type
= reg_pc
;
101 description
.index
= 0;
102 description
.size
= sizeof(unsigned_word
);
104 else if (!strcmp(reg
, "sp")) {
105 description
.type
= reg_gpr
;
106 description
.index
= 1;
107 description
.size
= sizeof(gpreg
);
109 else if (!strcmp(reg
, "toc")) {
110 description
.type
= reg_gpr
;
111 description
.index
= 2;
112 description
.size
= sizeof(gpreg
);
114 else if (!strcmp(reg
, "cr") || !strcmp(reg
, "cnd")) {
115 description
.type
= reg_cr
;
116 description
.index
= 0;
117 description
.size
= sizeof(creg
); /* FIXME */
119 else if (!strcmp(reg
, "msr") || !strcmp(reg
, "ps")) {
120 description
.type
= reg_msr
;
121 description
.index
= 0;
122 description
.size
= sizeof(msreg
);
124 else if (!strncmp(reg
, "sr", 2) && are_digits(reg
+ 2)) {
125 description
.type
= reg_sr
;
126 description
.index
= atoi(reg
+2);
127 description
.size
= sizeof(sreg
);
129 else if (!strcmp(reg
, "cnt")) {
130 description
.type
= reg_spr
;
131 description
.index
= spr_ctr
;
132 description
.size
= sizeof(spreg
);
135 sprs spr
= find_spr(reg
);
136 if (spr
!= nr_of_sprs
) {
137 description
.type
= reg_spr
;
138 description
.index
= spr
;
139 description
.size
= sizeof(spreg
);
142 description
.type
= reg_invalid
;
143 description
.index
= 0;
144 description
.size
= 0;
150 #endif /* _REGISTERS_C_ */