~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/compiler/sparc/aasmcpu.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
    Copyright (c) 1999-2002 by Mazen Neifer
 
3
 
 
4
    Contains the assembler object for the SPARC
 
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 aasmcpu;
 
23
 
 
24
{$i fpcdefs.inc}
 
25
 
 
26
interface
 
27
 
 
28
uses
 
29
  cclasses,
 
30
  globtype,globals,verbose,
 
31
  aasmbase,aasmtai,aasmdata,aasmsym,
 
32
  cgbase,cgutils,cpubase,cpuinfo;
 
33
 
 
34
    const
 
35
      { "mov reg,reg" source operand number }
 
36
      O_MOV_SOURCE = 0;
 
37
      { "mov reg,reg" source operand number }
 
38
      O_MOV_DEST = 1;
 
39
 
 
40
    type
 
41
      taicpu = class(tai_cpu_abstract_sym)
 
42
         delayslot_annulled : boolean;   { conditinal opcode with ,a }
 
43
         constructor op_none(op : tasmop);
 
44
 
 
45
         constructor op_reg(op : tasmop;_op1 : tregister);
 
46
         constructor op_const(op : tasmop;_op1 : LongInt);
 
47
         constructor op_ref(op : tasmop;const _op1 : treference);
 
48
 
 
49
         constructor op_reg_reg(op : tasmop;_op1,_op2 : tregister);
 
50
         constructor op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
 
51
         constructor op_reg_const(op:tasmop; _op1: tregister; _op2: LongInt);
 
52
         constructor op_const_reg(op:tasmop; _op1: LongInt; _op2: tregister);
 
53
         constructor op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
 
54
 
 
55
         constructor op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
 
56
         constructor op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
 
57
         constructor op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aint;_op3:tregister);
 
58
 
 
59
         { this is for Jmp instructions }
 
60
         constructor op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
 
61
         constructor op_sym(op : tasmop;_op1 : tasmsymbol);
 
62
         constructor op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
 
63
         procedure loadbool(opidx:longint;_b:boolean);
 
64
         { register allocation }
 
65
         function is_same_reg_move(regtype: Tregistertype):boolean; override;
 
66
 
 
67
         { register spilling code }
 
68
         function spilling_get_operation_type(opnr: longint): topertype;override;
 
69
      end;
 
70
 
 
71
      tai_align = class(tai_align_abstract)
 
72
        { nothing to add }
 
73
      end;
 
74
 
 
75
    procedure InitAsm;
 
76
    procedure DoneAsm;
 
77
 
 
78
    function spilling_create_load(const ref:treference;r:tregister): tai;
 
79
    function spilling_create_store(r:tregister; const ref:treference): tai;
 
80
 
 
81
implementation
 
82
 
 
83
{*****************************************************************************
 
84
                                 taicpu Constructors
 
85
*****************************************************************************}
 
86
 
 
87
    procedure taicpu.loadbool(opidx:longint;_b:boolean);
 
88
      begin
 
89
        if opidx>=ops then
 
90
         ops:=opidx+1;
 
91
        with oper[opidx]^ do
 
92
         begin
 
93
           if typ=top_ref then
 
94
            dispose(ref);
 
95
           b:=_b;
 
96
           typ:=top_bool;
 
97
         end;
 
98
      end;
 
99
 
 
100
 
 
101
    constructor taicpu.op_none(op : tasmop);
 
102
      begin
 
103
         inherited create(op);
 
104
      end;
 
105
 
 
106
 
 
107
    constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
 
108
      begin
 
109
         inherited create(op);
 
110
         ops:=1;
 
111
         loadreg(0,_op1);
 
112
      end;
 
113
 
 
114
 
 
115
    constructor taicpu.op_ref(op : tasmop;const _op1 : treference);
 
116
      begin
 
117
         inherited create(op);
 
118
         ops:=1;
 
119
         loadref(0,_op1);
 
120
      end;
 
121
 
 
122
 
 
123
    constructor taicpu.op_const(op : tasmop;_op1 : LongInt);
 
124
      begin
 
125
         inherited create(op);
 
126
         ops:=1;
 
127
         loadconst(0,_op1);
 
128
      end;
 
129
 
 
130
 
 
131
    constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
 
132
      begin
 
133
         inherited create(op);
 
134
         ops:=2;
 
135
         loadreg(0,_op1);
 
136
         loadreg(1,_op2);
 
137
      end;
 
138
 
 
139
    constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: LongInt);
 
140
      begin
 
141
         inherited create(op);
 
142
         ops:=2;
 
143
         loadreg(0,_op1);
 
144
         loadconst(1,_op2);
 
145
      end;
 
146
 
 
147
     constructor taicpu.op_const_reg(op:tasmop; _op1: LongInt; _op2: tregister);
 
148
      begin
 
149
         inherited create(op);
 
150
         ops:=2;
 
151
         loadconst(0,_op1);
 
152
         loadreg(1,_op2);
 
153
      end;
 
154
 
 
155
 
 
156
    constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
 
157
      begin
 
158
         inherited create(op);
 
159
         ops:=2;
 
160
         loadreg(0,_op1);
 
161
         loadref(1,_op2);
 
162
      end;
 
163
 
 
164
 
 
165
    constructor taicpu.op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
 
166
      begin
 
167
         inherited create(op);
 
168
         ops:=2;
 
169
         loadref(0,_op1);
 
170
         loadreg(1,_op2);
 
171
      end;
 
172
 
 
173
 
 
174
    constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
 
175
      begin
 
176
         inherited create(op);
 
177
         ops:=3;
 
178
         loadreg(0,_op1);
 
179
         loadreg(1,_op2);
 
180
         loadreg(2,_op3);
 
181
      end;
 
182
 
 
183
 
 
184
    constructor taicpu.op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
 
185
      begin
 
186
         inherited create(op);
 
187
         { only allowed to load the address }
 
188
         if not(_op2.refaddr in [addr_lo,addr_hi]) then
 
189
           internalerror(200305311);
 
190
         ops:=3;
 
191
         loadreg(0,_op1);
 
192
         loadref(1,_op2);
 
193
         loadreg(2,_op3);
 
194
      end;
 
195
 
 
196
 
 
197
    constructor taicpu.op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aint;_op3:tregister);
 
198
      begin
 
199
         inherited create(op);
 
200
         ops:=3;
 
201
         loadreg(0,_op1);
 
202
         loadconst(1,_op2);
 
203
         loadreg(2,_op3);
 
204
      end;
 
205
 
 
206
 
 
207
    constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
 
208
      begin
 
209
         inherited create(op);
 
210
         is_jmp:=op in [A_BA,A_Bxx];
 
211
         condition:=cond;
 
212
         ops:=1;
 
213
         loadsymbol(0,_op1,0);
 
214
      end;
 
215
 
 
216
 
 
217
    constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
 
218
      begin
 
219
         inherited create(op);
 
220
         is_jmp:=op in [A_BA,A_Bxx];
 
221
         ops:=1;
 
222
         loadsymbol(0,_op1,0);
 
223
      end;
 
224
 
 
225
 
 
226
    constructor taicpu.op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
 
227
      begin
 
228
         inherited create(op);
 
229
         ops:=1;
 
230
         loadsymbol(0,_op1,_op1ofs);
 
231
      end;
 
232
 
 
233
 
 
234
    function taicpu.is_same_reg_move(regtype: Tregistertype):boolean;
 
235
      begin
 
236
        result:=(
 
237
                 ((opcode=A_MOV) and (regtype = R_INTREGISTER)) or
 
238
                 ((regtype = R_FPUREGISTER) and (opcode in [A_FMOVS,A_FMOVD]))
 
239
                ) and
 
240
                (ops=2) and
 
241
                (oper[0]^.typ=top_reg) and
 
242
                (oper[1]^.typ=top_reg) and
 
243
                (oper[0]^.reg=oper[1]^.reg);
 
244
      end;
 
245
 
 
246
 
 
247
    function taicpu.spilling_get_operation_type(opnr: longint): topertype;
 
248
      begin
 
249
        result := operand_read;
 
250
        case opcode of
 
251
          A_FCMPs,A_FCMPd,A_FCMPq :
 
252
            ;
 
253
          else
 
254
            begin
 
255
              if opnr=ops-1 then
 
256
                result := operand_write;
 
257
            end;
 
258
        end;
 
259
      end;
 
260
 
 
261
 
 
262
    function spilling_create_load(const ref:treference;r:tregister): tai;
 
263
      begin
 
264
        case getregtype(r) of
 
265
          R_INTREGISTER :
 
266
            result:=taicpu.op_ref_reg(A_LD,ref,r);
 
267
          R_FPUREGISTER :
 
268
            begin
 
269
              case getsubreg(r) of
 
270
                R_SUBFS :
 
271
                  result:=taicpu.op_ref_reg(A_LDF,ref,r);
 
272
                R_SUBFD :
 
273
                  result:=taicpu.op_ref_reg(A_LDD,ref,r);
 
274
                else
 
275
                  internalerror(200401042);
 
276
              end;
 
277
            end
 
278
          else
 
279
            internalerror(200401041);
 
280
        end;
 
281
      end;
 
282
 
 
283
 
 
284
    function spilling_create_store(r:tregister; const ref:treference): tai;
 
285
      begin
 
286
        case getregtype(r) of
 
287
          R_INTREGISTER :
 
288
            result:=taicpu.op_reg_ref(A_ST,r,ref);
 
289
          R_FPUREGISTER :
 
290
            begin
 
291
              case getsubreg(r) of
 
292
                R_SUBFS :
 
293
                  result:=taicpu.op_reg_ref(A_STF,r,ref);
 
294
                R_SUBFD :
 
295
                  result:=taicpu.op_reg_ref(A_STD,r,ref);
 
296
                else
 
297
                  internalerror(200401042);
 
298
              end;
 
299
            end
 
300
          else
 
301
            internalerror(200401041);
 
302
        end;
 
303
      end;
 
304
 
 
305
 
 
306
    procedure InitAsm;
 
307
      begin
 
308
      end;
 
309
 
 
310
 
 
311
    procedure DoneAsm;
 
312
      begin
 
313
      end;
 
314
 
 
315
begin
 
316
  cai_cpu:=taicpu;
 
317
  cai_align:=tai_align;
 
318
end.