1 {
2     Copyright (c) 1998-2009 by Mazen NEIFER and David Zhang
3 
4     This unit contains the MIPS GAS instruction tables
5 
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 
20  ****************************************************************************
21 }
22 unit itcpugas;
23 
24 {$i fpcdefs.inc}
25 
26 interface
27 
28 uses
29   cpubase, cgbase;
30 
31 const
32   gas_op2str: array[tasmop] of string[15] = ({$INCLUDE strinst.inc});
33 
gas_regnum_searchnull34 function gas_regnum_search(const s: string): Tregister;
gas_regnamenull35 function gas_regname(r: Tregister): string;
36 
37 
38 implementation
39 
40 uses
41   cutils, verbose;
42 
43 const
44   gas_regname_table: array[tregisterindex] of string[7] = (
45         {$i rmipsgas.inc}
46     );
47 
48   gas_regname_index: array[tregisterindex] of tregisterindex = (
49         {$i rmipssri.inc}
50     );
51 
52 
findreg_by_gasnamenull53 function findreg_by_gasname(const s: string): tregisterindex;
54 var
55   p: tregisterindex;
56 begin
57   for p := low(tregisterindex) to high(tregisterindex) do
58   begin
59     if gas_regname_table[gas_regname_index[p]] = s then
60     begin
61       findreg_by_gasname := gas_regname_index[p];
62       exit
63     end;
64   end;
65   findreg_by_gasname := 0;
66 end;
67 
68 
gas_regnum_searchnull69 function gas_regnum_search(const s: string): Tregister;
70 begin
71   Result := regnumber_table[findreg_by_gasname(s)];
72 end;
73 
74 
gas_regnamenull75 function gas_regname(r: Tregister): string;
76 var
77   hr: tregister;
78   p:  longint;
79 begin
80   { Double uses the same table as single }
81   hr := r;
82   case getsubreg(hr) of
83     R_SUBFD:
84       setsubreg(hr, R_SUBFS);
85     R_SUBL, R_SUBW, R_SUBD, R_SUBQ:
86       setsubreg(hr, R_SUBD);
87   end;
88   p := findreg_by_number(hr);
89   if p <> 0 then
90     Result := gas_regname_table[p]
91   else
92     Result := generic_regname(r);
93 end;
94 
95 end.
96 
97