Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/include/architecture/ppc/pseudo_inst.h

Source at commit 1129 created 12 years 11 months ago.
By meklort, Change options.o so that it reloads the system config as well. Also change it so that it uses that config for variables (NOTE: if the calue exists in chameleonConfig, it's used instead.
1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
24 *
25 *File:architecture/ppc/pseudo_inst.h
26 *Author:Mike DeMoney
27 *
28 *This header file defines assembler pseudo-instruction macros for
29 *for the ppc.
30 *
31 *NOTE: This is obviously only useful to include in assembly
32 *code source.
33 *
34 *ALSO NOTE: These macros don't attempt to be 64-bit compatable
35 *
36 * HISTORY
37 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
38 *Ported from m98k.
39 * 05-Nov-92 Mike DeMoney (mike@next.com)
40 *Created.
41 */
42
43#ifndef_ARCH_PPC_PSEUDO_INST_H_
44#define_ARCH_PPC_PSEUDO_INST_H_
45
46#include <architecture/ppc/reg_help.h>
47#include <architecture/ppc/asm_help.h>
48
49#ifdef__ASSEMBLER__
50
51/*
52 * Pseudo instruction definitions
53 */
54
55/*
56 * Macro package initialization
57 */
58.set__no_at,0/* allow at by default */
59
60/*
61 * .at_off -- disable use of at by macros
62 * .at_on -- enable use of at by macros
63 */
64.macro.at_off
65.set__no_at,1
66.endmacro
67
68.macro.at_on
69.set__no_at,0
70.endmacro
71
72/*
73 * li32rD,IMMED
74 *
75 * Load 32-bit immediate into rD
76 * FIXME: Need a way to undefine built-in macro for this.
77 */
78.macroli32// li32rD,immed
79.if$n != 2
80.abort"invalid operands of li32"
81.endif
82.abs__is_abs,$1
83.if!__is_abs
84addis$0,0,hi16($1)
85ori$0,$0,lo16($1)
86.elseif$1 == 0
87addi$0,0,0
88.elseif($1 & 0xffff) == 0
89addis$0,0,hi16($1)
90.elseif($1 & 0xffff8000) == 0
91addi$0,0,$1
92.elseif ($1 & 0xffff8000) == 0xffff8000
93addi$0,0,$1
94.else
95addis$0,0,hi16($1)
96ori$0,$0,lo16($1)
97.endif
98.endmacro
99
100
101/*
102 * andi32. rD,rS1,IMMED
103 *
104 * Perform "andi." with (possibly) 32-bit immediate
105 */
106.macroandi32.// andi32. rD,rS1,IMMED
107.if$n != 3
108.abort"invalid operands of andi."
109.endif
110.set__used_at,0
111.abs__is_abs,$2
112.if!__is_abs
113.set__used_at,1
114li32at,$2
115and.$0,$1,at
116.elseif($2 & 0xffff0000) == 0
117andi.$0,$1,$2
118.elseif($2 & 0xffff) == 0
119andis.$0,$1,hi16($2)
120.else
121.set__used_at,1
122li32at,$2
123and.$0,$1,at
124.endif
125.if__no_at & __used_at
126.abort"Macro uses at while .no_at in effect"
127.endif
128.endmacro
129
130/*
131 * ori32rD,rS1,IMMED
132 *
133 * Perform "ori" with (possibly) 32-bit immediate
134 */
135.macroori32// ori32rD,rS1,IMMED
136.if$n != 3
137.abort"invalid operands of ori"
138.endif
139.abs__is_abs,$2
140.if!__is_abs
141oris$0,$1,hi16($2)
142ori$0,$1,lo16($2)
143.elseif($2 & 0xffff0000) == 0
144ori$0,$1,$2
145.elseif($2 & 0xffff) == 0
146oris$0,$1,hi16($2)
147.else
148oris$0,$1,hi16($2)
149ori$0,$1,lo16($2)
150.endif
151.endmacro
152
153/*
154 * xori32rD,rS1,IMMED
155 *
156 * Perform "xor" with (possibly) 32-bit immediate
157 */
158.macroxori32// xori32rD,rS1,IMMED
159.if$n != 3
160.abort"invalid operands of xori"
161.endif
162.abs__is_abs,$2
163.if!__is_abs
164xoris$0,$1,hi16($2)
165xori$0,$1,lo16($2)
166.elseif($2 & 0xffff0000) == 0
167xori$0,$1,$2
168.elseif($2 & 0xffff) == 0
169xoris$0,$1,hi16($2)
170.else
171xoris$0,$1,hi16($2)
172xori$0,$1,lo16($2)
173.endif
174.endmacro
175
176
177/*
178 * MEMREF_INST -- macros to memory referencing instructions
179 * "capable" of dealing with 32 bit offsets.
180 *
181 * NOTE: Because the assembler doesn't have any mechanism for easily
182 * parsing the d(rS) syntax of register-displacement form instructions,
183 * these instructions do NOT mirror the normal memory reference
184 * instructions. The following "transformation" is used:
185 *lbzrD,d(rS)
186 * becomes:
187 *lbz32rD,rS,d
188 * I.e.: "32" is appended to the instruction name and the base register
189 * and displacement become the 2'nd and 3'rd comma-separated operands.
190 *
191 * The forms:
192 *lbz32rD,d
193 * and:
194 *lbz32rD,rS
195 * are also recognized and the missing operand is assumed 0.
196 *
197 * ALSO NOTE: r0 or zt should never be used as rS in these instructions.
198 * Use "0" as rS in this case.
199 */
200#defineMEMREF_INST(op)\
201.macroop ## 32@\
202.set__used_at,0@\
203.if$n == 3@\
204 .greg__is_greg,$1@\
205 .abs__is_abs,$2@\
206 .if__is_abs@\
207 .if($2 & 0xffff8000) == 0@\
208op$0,$2($1)@\
209 .elseif ($2 & 0xffff8000) == 0xffff8000@\
210op$0,$2($1)@\
211 .else@\
212 .if!__is_greg@\
213.set__used_at,1@\
214lisat,ha16($2)@\
215op$0,lo16($2)(at)@\
216 .else@\
217 .set__used_at,1@\
218lisat,ha16($2)@\
219addat,at,$1@\
220op$0,lo16($2)(at)@\
221 .endif@\
222 .endif@\
223 .else@\
224 .if!__is_greg@\
225.set__used_at,1@\
226lisat,ha16($2)@\
227op$0,lo16($2)(at)@\
228 .else@\
229 .set__used_at,1@\
230lisat,ha16($2)@\
231addat,at,$1@\
232op$0,lo16($2)(at)@\
233 .endif@\
234 .endif@\
235.elseif$n == 2@\
236 .greg__is_greg,$1@\
237 .if!__is_greg@\
238 .abs__is_abs,$1@\
239 .if__is_abs@\
240 .if($1 & 0xffff8000) == 0@\
241op$0,$1(0)@\
242 .elseif ($1 & 0xffff8000) == 0xffff8000@\
243op$0,$1(0)@\
244 .else@\
245.set__used_at,1@\
246lisat,ha16($1)@\
247op$0,lo16($1)(at)@\
248 .endif@\
249 .else@\
250.set__used_at,1@\
251lisat,ha16($1)@\
252op$0,lo16($1)(at)@\
253 .endif@\
254 .else@\
255op$0,0($1)@\
256 .endif@\
257.else@\
258.abort "Invalid operands of " #op "32"@\
259.endif@\
260.if__no_at & __used_at@\
261.abort"Macro uses at while .no_at in effect"@\
262.endif@\
263.endmacro
264
265MEMREF_INST(lbz)
266MEMREF_INST(lhz)
267MEMREF_INST(lha)
268MEMREF_INST(lwz)
269MEMREF_INST(lwa)
270MEMREF_INST(ld)
271
272MEMREF_INST(stb)
273MEMREF_INST(sth)
274MEMREF_INST(stw)
275MEMREF_INST(std)
276
277MEMREF_INST(lmw)
278MEMREF_INST(lmd)
279MEMREF_INST(stmw)
280MEMREF_INST(stmd)
281
282/*
283 * ARITH_INST -- define 32-bit immediate forms of arithmetic
284 * instructions
285 *
286 *E.g.addi32rD,rS,IMMED
287 */
288#defineARITH_INST(op, op3)\
289.macroop ## 32@\
290.if$n != 3@\
291.abort"invalid operands to " #op "32"@\
292.endif@\
293.abs__is_abs,$2@\
294.if__is_abs@\
295 .if($2 & 0xffff8000) == 0@\
296op$0,$1,$2@\
297 .elseif($2 & 0xffff8000) == 0xffff8000@\
298op$0,$1,$2@\
299 .elseif__no_at@\
300.abort"Macro uses at while .no_at in effect"@\
301 .else@\
302li32at,$2@\
303op3$0,$1,at@\
304 .endif@\
305.elseif__no_at@\
306.abort"Macro uses at while .no_at in effect"@\
307.else@\
308li32at,$2@\
309op3$0,$1,at@\
310.endif@\
311.endmacro
312
313ARITH_INST(addi, add)
314ARITH_INST(subi, sub)
315ARITH_INST(addic, addc)
316ARITH_INST(subic, subc)
317ARITH_INST(mulli, mull)
318
319/*
320 * COND_ARITH_INST -- define 32-bit immediate forms of arithmetic
321 * instructions that set bits in the condition register
322 *
323 *E.g.addic32.rD,rS,IMMED
324 */
325#defineCOND_ARITH_INST(name, op, op3)\
326.macroname@\
327.if$n != 3@\
328.abort"invalid operands to " #name@\
329.endif@\
330.abs__is_abs,$2@\
331.if__is_abs@\
332 .if($2 & 0xffff8000) == 0@\
333op$0,$1,$2@\
334 .elseif($2 & 0xffff8000) == 0xffff8000@\
335op$0,$1,$2@\
336 .elseif__no_at@\
337.abort"Macro uses at while .no_at in effect"@\
338 .else@\
339li32at,$2@\
340op3$0,$1,at@\
341 .endif@\
342.elseif__no_at@\
343.abort"Macro uses at while .no_at in effect"@\
344.else@\
345li32at,$2@\
346op3$0,$1,at@\
347.endif@\
348.endmacro
349
350COND_ARITH_INST(addic32., addic., addc.)
351COND_ARITH_INST(subic32., subic., subc.)
352
353/*
354 * CMPEX_INST -- define 32-bit immediate forms of extended compare
355 * instructions
356 *
357 *E.g.cmpwi32cr3,rS,IMMED
358 *cmpwi32rS,IMMED
359 */
360#defineCMPEX_INST(op, op3)\
361.macroop ## 32@\
362.if$n == 3@\
363 .abs__is_abs,$2@\
364 .if__is_abs@\
365 .if($2 & 0xffff8000) == 0@\
366op$0,$1,$2@\
367 .elseif($2 & 0xffff8000) == 0xffff8000@\
368op$0,$1,$2@\
369 .elseif__no_at@\
370.abort"Macro uses at while .no_at in effect"@\
371 .else@\
372li32at,$2@\
373op3$0,$1,at@\
374 .endif@\
375 .elseif__no_at@\
376.abort"Macro uses at while .no_at in effect"@\
377 .else@\
378li32at,$2@\
379op3$0,$1,at@\
380 .endif@\
381.elseif$n == 2@\
382 .abs__is_abs,$1@\
383 .if__is_abs@\
384 .if($1 & 0xffff8000) == 0@\
385op$0,$1@\
386 .elseif($1 & 0xffff8000) == 0xffff8000@\
387op$0,$1@\
388 .elseif__no_at@\
389.abort"Macro uses at while .no_at in effect"@\
390 .else@\
391li32at,$1@\
392op3$0,at@\
393 .endif@\
394 .elseif__no_at@\
395.abort"Macro uses at while .no_at in effect"@\
396 .else@\
397li32at,$1@\
398op3$0,at@\
399 .endif@\
400.else@\
401.abort"invalid operands to " #op "32"@\
402.endif@\
403.endmacro
404
405CMPEX_INST(cmpdi, cmpd)
406CMPEX_INST(cmpwi, cmpw)
407CMPEX_INST(cmpldi, cmpld)
408CMPEX_INST(cmplwi, cmplw)
409
410/*
411 * CMP_INST -- define 32-bit immediate forms of standard compare
412 * instructions
413 *
414 *E.g.cmpi32cr3,0,rS,IMMED
415 */
416#defineCMP_INST(op, op3)\
417.macroop ## 32@\
418.if$n == 4@\
419 .abs__is_abs,$3@\
420 .if__is_abs@\
421 .if($3 & 0xffff8000) == 0@\
422op$0,$1,$2,$3@\
423 .elseif($3 & 0xffff8000) == 0xffff8000@\
424op$0,$1,$2,$3@\
425 .elseif__no_at@\
426.abort"Macro uses at while .no_at in effect"@\
427 .else@\
428li32at,$3@\
429op3$0,$1,$2,at@\
430 .endif@\
431 .elseif__no_at@\
432.abort"Macro uses at while .no_at in effect"@\
433 .else@\
434li32at,$3@\
435op3$0,$1,$2,at@\
436 .endif@\
437.else@\
438.abort"invalid operands to " #op "32"@\
439.endif@\
440.endmacro
441
442CMP_INST(cmpi, cmp)
443CMP_INST(cmpli, cmpl)
444
445#endif/* __ASSEMBLER__ */
446
447#endif/* _ARCH_PPC_PSEUDO_INST_H_ */
448

Archive Download this file

Revision: 1129