1 #ifndef __MIPS_CODEGEN_H__
2 #define __MIPS_CODEGEN_H__
3 /*
4  * Copyright (c) 2004 Novell, Inc
5  * Author: Paolo Molaro (lupus@ximian.com)
6  *
7  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
8  */
9 
10 /* registers */
11 enum {
12 	mips_zero,
13 	mips_at, /* assembler temp */
14 	mips_v0, /* return values */
15 	mips_v1,
16 	mips_a0, /* 4 - func arguments */
17 	mips_a1,
18 	mips_a2,
19 	mips_a3,
20 #if _MIPS_SIM == _ABIO32
21 	mips_t0, /* 8 temporaries */
22 	mips_t1,
23 	mips_t2,
24 	mips_t3,
25 	mips_t4,
26 	mips_t5,
27 	mips_t6,
28 	mips_t7,
29 #elif _MIPS_SIM == _ABIN32
30 	mips_a4, /* 4 more argument registers */
31 	mips_a5,
32 	mips_a6,
33 	mips_a7,
34 	mips_t0, /* 4 temporaries */
35 	mips_t1,
36 	mips_t2,
37 	mips_t3,
38 #endif
39 	mips_s0, /* 16 calle saved */
40 	mips_s1,
41 	mips_s2,
42 	mips_s3,
43 	mips_s4,
44 	mips_s5,
45 	mips_s6,
46 	mips_s7,
47 	mips_t8, /* 24 temps */
48 	mips_t9, /* 25 temp / pic call-through register */
49 	mips_k0, /* 26 kernel-reserved */
50 	mips_k1,
51 	mips_gp, /* 28 */
52 	mips_sp, /* stack pointer */
53 	mips_fp, /* frame pointer */
54 	mips_ra /* return address */
55 };
56 
57 /* we treat the register file as containing just doubles... */
58 enum {
59 	mips_f0, /* return regs */
60 	mips_f1,
61 	mips_f2,
62 	mips_f3,
63 	mips_f4, /* temps */
64 	mips_f5,
65 	mips_f6,
66 	mips_f7,
67 	mips_f8,
68 	mips_f9,
69 	mips_f10,
70 	mips_f11,
71 	mips_f12, /* first arg */
72 	mips_f13,
73 	mips_f14, /* second arg */
74 	mips_f15,
75 	mips_f16, /* temps */
76 	mips_f17,
77 	mips_f18,
78 	mips_f19,
79 	mips_f20, /* callee saved */
80 	mips_f21,
81 	mips_f22,
82 	mips_f23,
83 	mips_f24,
84 	mips_f25,
85 	mips_f26,
86 	mips_f27,
87 	mips_f28,
88 	mips_f29,
89 	mips_f30,
90 	mips_f31
91 };
92 
93 /* prefetch hints */
94 enum {
95 	MIPS_FOR_LOAD,
96 	MIPS_FOR_STORE,
97 	MIPS_FOR_LOAD_STREAMED = 4,
98 	MIPS_FOR_STORE_STREAMED,
99 	MIPS_FOR_LOAD_RETAINED,
100 	MIPS_FOR_STORE_RETAINED
101 };
102 
103 /* coprocessors */
104 enum {
105 	MIPS_COP0,
106 	MIPS_COP1,
107 	MIPS_COP2,
108 	MIPS_COP3
109 };
110 
111 enum {
112 	MIPS_FMT_SINGLE = 16,
113 	MIPS_FMT_DOUBLE = 17,
114 	MIPS_FMT_WORD = 20,
115 	MIPS_FMT_LONG = 21,
116 	MIPS_FMT3_SINGLE = 0,
117 	MIPS_FMT3_DOUBLE = 1
118 };
119 
120 /* fpu rounding mode */
121 enum {
122 	MIPS_ROUND_TO_NEAREST,
123 	MIPS_ROUND_TO_ZERO,
124 	MIPS_ROUND_TO_POSINF,
125 	MIPS_ROUND_TO_NEGINF,
126 	MIPS_ROUND_MASK = 3
127 };
128 
129 /* fpu enable/cause flags, cc */
130 enum {
131 	MIPS_FPU_C_MASK = 1 << 23,
132 	MIPS_INEXACT = 1,
133 	MIPS_UNDERFLOW = 2,
134 	MIPS_OVERFLOW = 4,
135 	MIPS_DIVZERO = 8,
136 	MIPS_INVALID = 16,
137 	MIPS_NOTIMPL = 32,
138 	MIPS_FPU_FLAGS_OFFSET = 2,
139 	MIPS_FPU_ENABLES_OFFSET = 7,
140 	MIPS_FPU_CAUSES_OFFSET = 12
141 };
142 
143 /* fpu condition values - see manual entry for C.cond.fmt instructions */
144 enum {
145 	MIPS_FPU_F,
146 	MIPS_FPU_UN,
147 	MIPS_FPU_EQ,
148 	MIPS_FPU_UEQ,
149 	MIPS_FPU_OLT,
150 	MIPS_FPU_ULT,
151 	MIPS_FPU_OLE,
152 	MIPS_FPU_ULE,
153 	MIPS_FPU_SF,
154 	MIPS_FPU_NGLE,
155 	MIPS_FPU_SEQ,
156 	MIPS_FPU_NGL,
157 	MIPS_FPU_LT,
158 	MIPS_FPU_NGE,
159 	MIPS_FPU_LE,
160 	MIPS_FPU_NGT
161 };
162 
163 #if SIZEOF_REGISTER == 4
164 
165 #define MIPS_SW		mips_sw
166 #define MIPS_LW		mips_lw
167 #define MIPS_ADDU	mips_addu
168 #define MIPS_ADDIU	mips_addiu
169 #define MIPS_SWC1	mips_swc1
170 #define MIPS_LWC1	mips_lwc1
171 #define MIPS_MOVE	mips_move
172 
173 #elif SIZEOF_REGISTER == 8
174 
175 #define MIPS_SW		mips_sd
176 #define MIPS_LW		mips_ld
177 #define MIPS_ADDU	mips_daddu
178 #define MIPS_ADDIU	mips_daddiu
179 #define MIPS_SWC1	mips_sdc1
180 #define MIPS_LWC1	mips_ldc1
181 #define MIPS_MOVE	mips_dmove
182 
183 #else
184 #error Unknown SIZEOF_REGISTER
185 #endif
186 
187 #define mips_emit32(c,x) do {				\
188 		*((guint32 *) (void *)(c)) = x;				\
189 		(c) = (typeof(c))(((guint32 *)(void *)(c)) + 1);	\
190 	} while (0)
191 
192 #define mips_format_i(code,op,rs,rt,imm) mips_emit32 ((code), (((op)<<26)|((rs)<<21)|((rt)<<16)|((imm)&0xffff)))
193 #define mips_format_j(code,op,imm) mips_emit32 ((code), (((op)<<26)|((imm)&0x03ffffff)))
194 #define mips_format_r(code,op,rs,rt,rd,sa,func) mips_emit32 ((code), (((op)<<26)|((rs)<<21)|((rt)<<16)|((rd)<<11)|((sa)<<6)|(func)))
195 #define mips_format_divmul(code,op,src1,src2,fun) mips_emit32 ((code), (((op)<<26)|((src1)<<21)|((src2)<<16)|(fun)))
196 
197 #define mips_is_imm16(val) ((gint)(gshort)(gint)(val) == (gint)(val))
198 
199 /* Load always using lui/addiu pair (for later patching) */
200 #define mips_load(c,D,v) do {	\
201 		if (((guint32)(v)) & (1 << 15)) {								\
202 			mips_lui ((c), (D), mips_zero, (((guint32)(v))>>16)+1);		\
203 		}																\
204 		else {															\
205 			mips_lui ((c), (D), mips_zero, (((guint32)(v))>>16));		\
206 		}																\
207 		mips_addiu ((c), (D), (D), ((guint32)(v)) & 0xffff);			\
208 	} while (0)
209 
210 /* load constant - no patch-up */
211 #define mips_load_const(c,D,v) do {	\
212 		if (!mips_is_imm16 ((v)))	{	\
213 			if (((guint32)(v)) & (1 << 15)) {		\
214 				mips_lui ((c), (D), mips_zero, (((guint32)(v))>>16)+1); \
215 			} \
216 			else {			\
217 				mips_lui ((c), (D), mips_zero, (((guint32)(v))>>16)); \
218 			}						\
219 			if (((guint32)(v)) & 0xffff) \
220 				mips_addiu ((c), (D), (D), ((guint32)(v)) & 0xffff); \
221 		}							\
222 		else							\
223 			mips_addiu ((c), (D), mips_zero, ((guint32)(v)) & 0xffff); \
224 	} while (0)
225 
226 /* arithmetric ops */
227 #define mips_add(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,32)
228 #define mips_addi(c,dest,src1,imm) mips_format_i(c,8,src1,dest,imm)
229 #define mips_addu(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,33)
230 #define mips_addiu(c,dest,src1,imm) mips_format_i(c,9,src1,dest,imm)
231 #define mips_dadd(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,44)
232 #define mips_daddi(c,dest,src1,imm) mips_format_i(c,24,src1,dest,imm)
233 #define mips_daddu(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,45)
234 #define mips_daddiu(c,dest,src1,imm) mips_format_i(c,25,src1,dest,imm)
235 #define mips_dsub(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,46)
236 #define mips_dsubu(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,47)
237 #define mips_mul(c,dest,src1,src2) mips_format_r(c,28,src1,src2,dest,0,2)
238 #define mips_sub(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,34)
239 #define mips_subu(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,35)
240 
241 /* div and mul ops */
242 #define mips_ddiv(c,src1,src2) mips_format_divmul(c,0,src1,src2,30)
243 #define mips_ddivu(c,src1,src2) mips_format_divmul(c,0,src1,src2,31)
244 #define mips_div(c,src1,src2) mips_format_divmul(c,0,src1,src2,26)
245 #define mips_divu(c,src1,src2) mips_format_divmul(c,0,src1,src2,27)
246 #define mips_dmult(c,src1,src2) mips_format_divmul(c,0,src1,src2,28)
247 #define mips_dmultu(c,src1,src2) mips_format_divmul(c,0,src1,src2,29)
248 #define mips_mult(c,src1,src2) mips_format_divmul(c,0,src1,src2,24)
249 #define mips_multu(c,src1,src2) mips_format_divmul(c,0,src1,src2,25)
250 
251 /* shift ops */
252 #define mips_dsll(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,56)
253 #define mips_dsll32(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,60)
254 #define mips_dsllv(c,dest,src1,src2) mips_format_r(c,0,src2,src1,dest,0,20)
255 #define mips_dsra(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,59)
256 #define mips_dsra32(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,63)
257 #define mips_dsrav(c,dest,src1,src2) mips_format_r(c,0,src2,src1,dest,0,23)
258 #define mips_dsrl(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,58)
259 #define mips_dsrl32(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,62)
260 #define mips_dsrlv(c,dest,src1,src2) mips_format_r(c,0,src2,src1,dest,0,22)
261 #define mips_sll(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,0)
262 #define mips_sllv(c,dest,src1,src2) mips_format_r(c,0,src2,src1,dest,0,4)
263 #define mips_sra(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,3)
264 #define mips_srav(c,dest,src1,src2) mips_format_r(c,0,src2,src1,dest,0,7)
265 #define mips_srl(c,dest,src1,imm) mips_format_r(c,0,0,src1,dest,imm,2)
266 #define mips_srlv(c,dest,src1,src2) mips_format_r(c,0,src2,src1,dest,0,6)
267 
268 /* logical ops */
269 #define mips_and(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,36)
270 #define mips_andi(c,dest,src1,imm) mips_format_i(c,12,src1,dest,imm)
271 #define mips_nor(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,39)
272 #define mips_or(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,37)
273 #define mips_ori(c,dest,src1,uimm) mips_format_i(c,13,src1,dest,uimm)
274 #define mips_xor(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,38)
275 #define mips_xori(c,dest,src1,uimm) mips_format_i(c,14,src1,dest,uimm)
276 
277 /* compares */
278 #define mips_slt(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,42)
279 #define mips_slti(c,dest,src1,imm) mips_format_i(c,10,src1,dest,imm)
280 #define mips_sltiu(c,dest,src1,imm) mips_format_i(c,11,src1,dest,imm)
281 #define mips_sltu(c,dest,src1,src2) mips_format_r(c,0,src1,src2,dest,0,43)
282 /* missing traps: teq, teqi, tge, tgei, tgeiu, tgeu, tlt, tlti, tltiu, tltu, tne, tnei, */
283 
284 /* conditional branches */
285 #define mips_beq(c,src1,src2,offset) mips_format_i(c,4,src1,src2,offset)
286 #define mips_beql(c,src1,src2,offset) mips_format_i(c,20,src1,src2,offset)
287 #define mips_bgez(c,src1,offset) mips_format_i(c,1,src1,1,offset)
288 #define mips_bgezal(c,src1,offset) mips_format_i(c,1,src1,17,offset)
289 #define mips_bgezall(c,src1,offset) mips_format_i(c,1,src1,19,offset)
290 #define mips_bgezl(c,src1,offset) mips_format_i(c,1,src1,3,offset)
291 #define mips_bgtz(c,src1,offset) mips_format_i(c,7,src1,0,offset)
292 #define mips_bgtzl(c,src1,offset) mips_format_i(c,23,src1,0,offset)
293 #define mips_blez(c,src1,offset) mips_format_i(c,6,src1,0,offset)
294 #define mips_blezl(c,src1,offset) mips_format_i(c,22,src1,0,offset)
295 #define mips_bltz(c,src1,offset) mips_format_i(c,1,src1,0,offset)
296 #define mips_bltzal(c,src1,offset) mips_format_i(c,1,src1,16,offset)
297 #define mips_bltzall(c,src1,offset) mips_format_i(c,1,src1,18,offset)
298 #define mips_bltzl(c,src1,offset) mips_format_i(c,1,src1,2,offset)
299 #define mips_bne(c,src1,src2,offset) mips_format_i(c,5,src1,src2,offset)
300 #define mips_bnel(c,src1,src2,offset) mips_format_i(c,21,src1,src2,offset)
301 
302 /* uncond branches and calls */
303 #define mips_jump(c,target) mips_format_j(c,2,target)
304 #define mips_jumpl(c,target) mips_format_j(c,3,target)
305 #define mips_jalr(c,src1,retreg) mips_format_r(c,0,src1,0,retreg,0,9)
306 #define mips_jr(c,src1) mips_emit32(c,((src1)<<21)|8)
307 
308 /* loads and stores */
309 #define mips_lb(c,dest,base,offset) mips_format_i(c,32,base,dest,offset)
310 #define mips_lbu(c,dest,base,offset) mips_format_i(c,36,base,dest,offset)
311 #define mips_ld(c,dest,base,offset) mips_format_i(c,55,base,dest,offset)
312 #define mips_ldl(c,dest,base,offset) mips_format_i(c,26,base,dest,offset)
313 #define mips_ldr(c,dest,base,offset) mips_format_i(c,27,base,dest,offset)
314 #define mips_lh(c,dest,base,offset) mips_format_i(c,33,base,dest,offset)
315 #define mips_lhu(c,dest,base,offset) mips_format_i(c,37,base,dest,offset)
316 #define mips_ll(c,dest,base,offset) mips_format_i(c,48,base,dest,offset)
317 #define mips_lld(c,dest,base,offset) mips_format_i(c,52,base,dest,offset)
318 #define mips_lui(c,dest,base,uimm) mips_format_i(c,15,base,dest,uimm)
319 #define mips_lw(c,dest,base,offset) mips_format_i(c,35,base,dest,offset)
320 #define mips_lwl(c,dest,base,offset) mips_format_i(c,34,base,dest,offset)
321 #define mips_lwr(c,dest,base,offset) mips_format_i(c,38,base,dest,offset)
322 #define mips_lwu(c,dest,base,offset) mips_format_i(c,39,base,dest,offset)
323 
324 #define mips_sb(c,src,base,offset) mips_format_i(c,40,base,src,offset)
325 #define mips_sc(c,src,base,offset) mips_format_i(c,56,base,src,offset)
326 #define mips_scd(c,src,base,offset) mips_format_i(c,60,base,src,offset)
327 #define mips_sd(c,src,base,offset) mips_format_i(c,63,base,src,offset)
328 #define mips_sdl(c,src,base,offset) mips_format_i(c,44,base,src,offset)
329 #define mips_sdr(c,src,base,offset) mips_format_i(c,45,base,src,offset)
330 #define mips_sh(c,src,base,offset) mips_format_i(c,41,base,src,offset)
331 #define mips_sw(c,src,base,offset) mips_format_i(c,43,base,src,offset)
332 #define mips_swl(c,src,base,offset) mips_format_i(c,50,base,src,offset)
333 #define mips_swr(c,src,base,offset) mips_format_i(c,54,base,src,offset)
334 
335 /* misc and coprocessor ops */
336 #define mips_move(c,dest,src) mips_addu(c,dest,src,mips_zero)
337 #define mips_dmove(c,dest,src) mips_daddu(c,dest,src,mips_zero)
338 #define mips_nop(c) mips_or(c,mips_at,mips_at,0)
339 #define mips_break(c,code) mips_emit32(c, ((code)<<6)|13)
340 #define mips_mfhi(c,dest) mips_format_r(c,0,0,0,dest,0,16)
341 #define mips_mflo(c,dest) mips_format_r(c,0,0,0,dest,0,18)
342 #define mips_mthi(c,src) mips_format_r(c,0,src,0,0,0,17)
343 #define mips_mtlo(c,src) mips_format_r(c,0,src,0,0,0,19)
344 #define mips_movn(c,dest,src,test) mips_format_r(c,0,src,test,dest,0,11)
345 #define mips_movz(c,dest,src,test) mips_format_r(c,0,src,test,dest,0,10)
346 #define mips_pref(c,hint,base,offset) mips_format_i(c,51,base,hint,offset)
347 #define mips_prefidx(c,hint,base,idx) mips_format_r(c,19,base,idx,hint,0,15)
348 #define mips_sync(c,stype) mips_emit32(c, ((stype)<<6)|15)
349 #define mips_syscall(c,code) mips_emit32(c, ((code)<<6)|12)
350 
351 #define mips_cop(c,cop,fun) mips_emit32(c, ((16|(cop))<<26)|(fun))
352 #define mips_ldc(c,cop,dest,base,offset) mips_format_i(c,(52|(cop)),base,dest,offset)
353 #define mips_lwc(c,cop,dest,base,offset) mips_format_i(c,(48|(cop)),base,dest,offset)
354 #define mips_sdc(c,cop,src,base,offset) mips_format_i(c,(60|(cop)),base,src,offset)
355 #define mips_swc(c,cop,src,base,offset) mips_format_i(c,(56|(cop)),base,src,offset)
356 #define mips_cfc1(c,dest,src) mips_format_r(c,17,2,dest,src,0,0)
357 #define mips_ctc1(c,dest,src) mips_format_r(c,17,6,dest,src,0,0)
358 
359 /* fpu ops */
360 #define mips_fabss(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,5)
361 #define mips_fabsd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,5)
362 #define mips_fadds(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_SINGLE,src2,src1,dest,0)
363 #define mips_faddd(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_DOUBLE,src2,src1,dest,0)
364 #define mips_fdivs(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_SINGLE,src2,src1,dest,3)
365 #define mips_fdivd(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_DOUBLE,src2,src1,dest,3)
366 #define mips_fmuls(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_SINGLE,src2,src1,dest,2)
367 #define mips_fmuld(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_DOUBLE,src2,src1,dest,2)
368 #define mips_fnegs(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,7)
369 #define mips_fnegd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,7)
370 #define mips_fsqrts(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,4)
371 #define mips_fsqrtd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,4)
372 #define mips_fsubs(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_SINGLE,src2,src1,dest,1)
373 #define mips_fsubd(c,dest,src1,src2) mips_format_r(c,17,MIPS_FMT_DOUBLE,src2,src1,dest,1)
374 #define mips_madds(c,dest,src1,src2,srcadd) mips_format_r(c,19,srcadd,src2,src1,dest,32|MIPS_FMT_SINGLE)
375 #define mips_maddd(c,dest,src1,src2,srcadd) mips_format_r(c,19,srcadd,src2,src1,dest,32|MIPS_FMT_DOUBLE)
376 #define mips_nmadds(c,dest,src1,src2,srcadd) mips_format_r(c,19,srcadd,src2,src1,dest,48|MIPS_FMT_SINGLE)
377 #define mips_nmaddd(c,dest,src1,src2,srcadd) mips_format_r(c,19,srcadd,src2,src1,dest,48|MIPS_FMT_DOUBLE)
378 #define mips_msubs(c,dest,src1,src2,srcsub) mips_format_r(c,19,srcsub,src2,src1,dest,40|MIPS_FMT_SINGLE)
379 #define mips_msubd(c,dest,src1,src2,srcsub) mips_format_r(c,19,srcsub,src2,src1,dest,40|MIPS_FMT_DOUBLE)
380 #define mips_nmsubs(c,dest,src1,src2,srcsub) mips_format_r(c,19,srcsub,src2,src1,dest,56|MIPS_FMT_SINGLE)
381 #define mips_nmsubd(c,dest,src1,src2,srcsub) mips_format_r(c,19,srcsub,src2,src1,dest,56|MIPS_FMT_DOUBLE)
382 
383 /* fp compare and branch */
384 #define mips_fcmps(c,cond,src1,src2) mips_format_r(c,17,MIPS_FMT_SINGLE,src2,src1,0,(3<<4)|(cond))
385 #define mips_fcmpd(c,cond,src1,src2) mips_format_r(c,17,MIPS_FMT_DOUBLE,src2,src1,0,(3<<4)|(cond))
386 #define mips_fbfalse(c,offset) mips_format_i(c,17,8,0,offset)
387 #define mips_fbfalsel(c,offset) mips_format_i(c,17,8,2,offset)
388 #define mips_fbtrue(c,offset) mips_format_i(c,17,8,1,offset)
389 #define mips_fbtruel(c,offset) mips_format_i(c,17,8,3,offset)
390 
391 /* fp convert */
392 #define mips_ceills(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,10)
393 #define mips_ceilld(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,10)
394 #define mips_ceilws(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,14)
395 #define mips_ceilwd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,14)
396 #define mips_cvtds(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,33)
397 #define mips_cvtdw(c,dest,src) mips_format_r(c,17,MIPS_FMT_WORD,0,src,dest,33)
398 #define mips_cvtdl(c,dest,src) mips_format_r(c,17,MIPS_FMT_LONG,0,src,dest,33)
399 #define mips_cvtls(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,37)
400 #define mips_cvtld(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,37)
401 #define mips_cvtsd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,32)
402 #define mips_cvtsw(c,dest,src) mips_format_r(c,17,MIPS_FMT_WORD,0,src,dest,32)
403 #define mips_cvtsl(c,dest,src) mips_format_r(c,17,MIPS_FMT_LONG,0,src,dest,32)
404 #define mips_cvtws(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,36)
405 #define mips_cvtwd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,36)
406 #define mips_floorls(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,11)
407 #define mips_floorld(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,11)
408 #define mips_floorws(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,15)
409 #define mips_floorwd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,15)
410 #define mips_roundls(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,8)
411 #define mips_roundld(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,8)
412 #define mips_roundws(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,12)
413 #define mips_roundwd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,12)
414 #define mips_truncls(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,9)
415 #define mips_truncld(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,9)
416 #define mips_truncws(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,13)
417 #define mips_truncwd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,13)
418 
419 /* fp moves, loads */
420 #define mips_fmovs(c,dest,src) mips_format_r(c,17,MIPS_FMT_SINGLE,0,src,dest,6)
421 #define mips_fmovd(c,dest,src) mips_format_r(c,17,MIPS_FMT_DOUBLE,0,src,dest,6)
422 #define mips_mfc1(c,dest,src) mips_format_r(c,17,0,dest,src,0,0)
423 #define mips_mtc1(c,dest,src) mips_format_r(c,17,4,src,dest,0,0)
424 #define mips_dmfc1(c,dest,src) mips_format_r(c,17,1,0,dest,src,0)
425 #define mips_dmtc1(c,dest,src) mips_format_r(c,17,1,0,src,dest,0)
426 #define mips_ldc1(c,dest,base,offset) mips_ldc(c,1,dest,base,offset)
427 #define mips_ldxc1(c,dest,base,idx) mips_format_r(c,19,base,idx,0,dest,1)
428 #define mips_lwc1(c,dest,base,offset) mips_lwc(c,1,dest,base,offset)
429 #define mips_lwxc1(c,dest,base,idx) mips_format_r(c,19,base,idx,0,dest,0)
430 #define mips_sdc1(c,src,base,offset) mips_sdc(c,1,src,base,offset)
431 #define mips_sdxc1(c,src,base,idx) mips_format_r(c,19,base,idx,src,0,9)
432 #define mips_swc1(c,src,base,offset) mips_swc(c,1,src,base,offset)
433 #define mips_swxc1(c,src,base,idx) mips_format_r(c,19,base,idx,src,0,8)
434 
435 #endif /* __MIPS_CODEGEN_H__ */
436 
437