2
$Id: aasmcpu.pas,v 1.3 2005/03/24 13:30:17 florian Exp $
3
Copyright (c) 2003 by Florian Klaempfl
5
Contains the assembler object for MIPS
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
****************************************************************************
31
aasmbase,globtype,globals,verbose,
32
cpubase,cpuinfo,cgbase,cgutils;
35
{ "mov reg,reg" source operand number }
37
{ "mov reg,reg" source operand number }
41
taicpu = class(tai_cpu_abstract)
42
constructor op_none(op : tasmop);
44
constructor op_reg(op : tasmop;_op1 : tregister);
45
constructor op_const(op : tasmop;_op1 : longint);
47
constructor op_reg_reg(op : tasmop;_op1,_op2 : tregister);
48
constructor op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
49
constructor op_reg_const(op:tasmop; _op1: tregister; _op2: aint);
51
constructor op_ref_regset(op:tasmop; _op1: treference; _op2: tcpuregisterset);
53
constructor op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
54
constructor op_reg_reg_const(op : tasmop;_op1,_op2 : tregister; _op3: aint);
55
constructor op_reg_reg_sym_ofs(op : tasmop;_op1,_op2 : tregister; _op3: tasmsymbol;_op3ofs: longint);
56
constructor op_reg_reg_ref(op : tasmop;_op1,_op2 : tregister; const _op3: treference);
58
constructor op_reg_const_ref(op : tasmop;_op1 : tregister;_op2 : aint;_op3 : treference);
60
{ this is for Jmp instructions }
61
constructor op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
63
constructor op_sym(op : tasmop;_op1 : tasmsymbol);
64
constructor op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
65
constructor op_reg_sym_ofs(op : tasmop;_op1 : tregister;_op2:tasmsymbol;_op2ofs : longint);
66
constructor op_sym_ofs_ref(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
68
function is_same_reg_move(regtype: Tregistertype):boolean; override;
70
function spilling_get_operation_type(opnr: longint): topertype;override;
72
tai_align = class(tai_align_abstract)
76
function spilling_create_load(const ref:treference;r:tregister): tai;
77
function spilling_create_store(r:tregister; const ref:treference): tai;
86
cutils,rgobj,itcpugas;
89
{*****************************************************************************
91
*****************************************************************************}
93
constructor taicpu.op_none(op : tasmop);
99
constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
101
inherited create(op);
107
constructor taicpu.op_const(op : tasmop;_op1 : longint);
109
inherited create(op);
111
loadconst(0,aint(_op1));
115
constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
117
inherited create(op);
124
constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: aint);
126
inherited create(op);
129
loadconst(1,aint(_op2));
133
constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
135
inherited create(op);
142
constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
144
inherited create(op);
152
constructor taicpu.op_reg_reg_const(op : tasmop;_op1,_op2 : tregister; _op3: aint);
154
inherited create(op);
158
loadconst(2,aint(_op3));
162
constructor taicpu.op_reg_const_ref(op : tasmop;_op1 : tregister;_op2 : aint;_op3 : treference);
164
inherited create(op);
172
constructor taicpu.op_reg_reg_sym_ofs(op : tasmop;_op1,_op2 : tregister; _op3: tasmsymbol;_op3ofs: longint);
174
inherited create(op);
178
loadsymbol(0,_op3,_op3ofs);
182
constructor taicpu.op_reg_reg_ref(op : tasmop;_op1,_op2 : tregister; const _op3: treference);
184
inherited create(op);
192
constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
194
inherited create(op);
197
loadsymbol(0,_op1,0);
201
constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
203
inherited create(op);
205
loadsymbol(0,_op1,0);
209
constructor taicpu.op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
211
inherited create(op);
213
loadsymbol(0,_op1,_op1ofs);
217
constructor taicpu.op_reg_sym_ofs(op : tasmop;_op1 : tregister;_op2:tasmsymbol;_op2ofs : longint);
219
inherited create(op);
222
loadsymbol(1,_op2,_op2ofs);
226
constructor taicpu.op_sym_ofs_ref(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
228
inherited create(op);
230
loadsymbol(0,_op1,_op1ofs);
235
{ ****************************** newra stuff *************************** }
237
function taicpu.is_same_reg_move(regtype: Tregistertype):boolean;
239
{ allow the register allocator to remove unnecessary moves }
240
result:=(((opcode=A_MOVE) and (regtype = R_INTREGISTER)) or
241
((opcode=A_MOVF) and (regtype = R_FPUREGISTER))
243
(condition=C_None) and
245
(oper[0]^.typ=top_reg) and
246
(oper[1]^.typ=top_reg) and
247
(oper[0]^.reg=oper[1]^.reg);
251
function spilling_create_load(const ref:treference;r:tregister): tai;
253
case getregtype(r) of
255
result:=taicpu.op_reg_ref(A_LDR,r,ref);
257
{ use lfm because we don't know the current internal format
260
result:=taicpu.op_reg_const_ref(A_LFM,r,1,ref);
262
internalerror(200401041);
267
function spilling_create_store(r:tregister; const ref:treference): tai;
269
case getregtype(r) of
271
result:=taicpu.op_reg_ref(A_STR,r,ref);
273
{ use sfm because we don't know the current internal format
276
result:=taicpu.op_reg_const_ref(A_SFM,r,1,ref);
278
internalerror(200401041);
283
function taicpu.spilling_get_operation_type(opnr: longint): topertype;
288
A_LDR,A_LDRB,A_LDRD,A_LDRBT,A_LDRH,A_LDRSB,
290
A_MOV,A_MVN,A_MLA,A_MUL,
291
A_ORR,A_RSB,A_RSC,A_SBC,A_SUB,
294
A_ADF,A_DVF,A_FDV,A_FML,
296
A_RMF,A_RPW,A_RSF,A_SUF,A_ABS,A_ACS,A_ASN,A_ATN,A_COS,
297
A_EXP,A_LOG,A_LGN,A_MVF,A_MNF,A_FRD,A_MUF,A_POL,A_RND,A_SIN,A_SQT,A_TAN,
300
result:=operand_write
302
result:=operand_read;
303
A_BIC,A_BKPT,A_B,A_BL,A_BLX,A_BX,
304
A_CMN,A_CMP,A_TEQ,A_TST,
305
A_CMF,A_CMFE,A_WFS,A_CNF:
306
result:=operand_read;
308
if opnr in [0,1] then
309
result:=operand_readwrite
311
result:=operand_read;
313
if opnr in [0,1] then
314
result:=operand_write
316
result:=operand_read;
317
A_STR,A_STRB,A_STRBT,A_STRD,
318
A_STRH,A_STRT,A_STF,A_SFM:
319
{ important is what happens with the involved registers }
321
result := operand_read
323
{ check for pre/post indexed }
324
result := operand_read;
326
internalerror(200403151);
342
$Log: aasmcpu.pas,v $
343
Revision 1.3 2005/03/24 13:30:17 florian
344
* small compilation fix
346
Revision 1.2 2005/02/14 17:13:10 peter
349
Revision 1.1 2005/02/13 18:56:44 florian