OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [a29khif/] [sys/] [intrinsi.h] - Blame information for rev 357

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
; @(#)intrinsi.h        1.4 90/10/14 20:56:06, Copyright 1988, 1989, 1990 AMD
2
; start of file intrinsi.h
3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4
; Copyright 1990 Advanced Micro Devices, Inc.
5
;
6
; This software is the property of Advanced Micro Devices, Inc  (AMD)  which
7
; specifically  grants the user the right to modify, use and distribute this
8
; software provided this notice is not removed or altered.  All other rights
9
; are reserved by AMD.
10
;
11
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
12
; SOFTWARE.  IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
13
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
14
; USE OF THIS SOFTWARE.
15
;
16
; So that all may benefit from your experience, please report  any  problems
17
; or  suggestions about this software to the 29K Technical Support Center at
18
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131  in  the  UK,  or
19
; 0031-11-1129 in Japan, toll free.  The direct dial number is 512-462-4118.
20
;
21
; Advanced Micro Devices, Inc.
22
; 29K Support Products
23
; Mail Stop 573
24
; 5900 E. Ben White Blvd.
25
; Austin, TX 78741
26
; 800-292-9263
27
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28
;
29
;
30
  .title "QTC Intrinsics Header file"
31
;
32
;    Floating point library package for AMD 29000 family
33
;
34
;    Copyright 1988 Advanced Micro Devices, Inc.
35
;
36
;    All rights reserved
37
;
38
;    Developed for AMD by Quantitative Technology Corporation
39
;                         8700 SW Creekside Place Suite D
40
;                         Beaverton OR 97005
41
;                         (503) 626-3081
42
;
43
;    Version information :
44
;
45
; Revision 1.6  89/06/29  16:08:51  jimh
46
; Fixed two bugs regarding compatiblility with the fpsymbol file.  The
47
; definitions of ROUND_TO_PLUS/MINUS_INFINITY were reversed.  Set_Rounding
48
; _Mode was fixed to set the local copy (29000 resident) of rounding mode
49
; in 29027 mode.
50
;
51
;
52
; Revision 1.5  89/04/17  11:20:49  jim
53
; replaced emfsr and emtsr macro calls with mfsr and mtsr instructions.
54
;
55
; Revision 1.4  89/02/24  15:18:04  jimh
56
; Added the definitions of FP_ENV_MODE_1_DEFAULT, FP_ENV_MODE_2_DEFAULT,
57
; FP_FLAGS_DEFAULT.
58
; Added macro clear_Flags.
59
; Changed the operation of set_Invalid_Op_flag, set_Reserved_Op_flag.
60
;
61
; Revision 1.3  89/02/01  18:30:12  jimh
62
; Changed the way set_Rounding_Mode, extract_Rounding_Mode, set_Invalid_Op_flag
63
; and set_Reserved_Op_flag are done.  Changed save_FP_regs.
64
;
65
; Revision 1.2  89/01/31  10:01:54  jimh
66
; Updated to the new standard.  This includes moving in register
67
; definitions, changing old symbols to reflect those in fpsymbol.h,
68
; and changing the include file to smartmac.h.
69
;
70
;
71
 .include "../traps/fpenv.h"                            ; RPD 8/21/89
72
 .include "sys/smartmac.h"
73
 
74
  .equ DOUBLE_EXP_WIDTH, 11
75
  .equ DOUBLE_EXTENDED_WIDTH, 56
76
 
77
 .equ SIGNED, 0
78
 .equ UNSIGNED, 1
79
 
80
  .equ ROUND_TO_NEAREST,        0
81
  .equ ROUND_TO_MINUS_INFINITY, 1
82
  .equ ROUND_TO_PLUS_INFINITY,  2
83
  .equ ROUND_TO_ZERO,           3
84
  .equ ROUNDING_MODE_POSITION, 14
85
 
86
 .equ FORMAT_INTEGER, 0
87
 .equ FORMAT_SINGLE,  1
88
 .equ FORMAT_DOUBLE,  2
89
 
90
 .equ DOUBLE_MSB_MASK,0x00080000
91
;
92
; The following are definitions used in the smart macro package, defining
93
; the 29000 shadow registers for the floating-point register file, and
94
; some temporary registers used during the library routines
95
;
96
 .reg FP0,  gr96
97
 .reg FP1,  gr98
98
 .reg FP2,  gr100
99
 .reg FP3,  gr102
100
 .reg FP4,  gr104
101
 .reg FP5,  gr106
102
 .reg FP6,  gr108
103
 .reg FP7,  gr110
104
;
105
; GR60 through GR6F are used to return the value of a function
106
;
107
 .reg rtn0,  gr96
108
 .reg rtn1,  gr97
109
 .reg rtn2,  gr98
110
 .reg rtn3,  gr99
111
 .reg rtn4,  gr100
112
 .reg rtn5,  gr101
113
 .reg rtn6,  gr102
114
 .reg rtn7,  gr103
115
 .reg rtn8,  gr104
116
 .reg rtn9,  gr105
117
 .reg rtn10, gr106
118
 .reg rtn11, gr107
119
 .reg rtn12, gr108
120
 .reg rtn13, gr109
121
 .reg rtn14, gr110
122
 .reg rtn15, gr111
123
;
124
; GR74..GR78 (116-120)    -  temporaries
125
;
126
 .reg t0, gr116
127
 .reg t1, gr117
128
 .reg t2, gr118
129
 .reg t3, gr119
130
 .reg t4, gr120
131
;
132
; FP_ENV_MODE_1 and FP_ENV_MODE_2 are based on 64-bit 29027 Mode register,
133
; and thus the fpsymbol.h CP_ constants may be used directly.
134
;
135
; FP_ENV_MODE_1 (Bits 0-31)
136
;
137
;      0-3   - floating-point format select, always 0
138
;      4     - Saturate enable
139
;      5     - IEEE Affine/Projective mode (ignored by traps code)
140
;      6     - IEEE Trap enable
141
;      7     - IEEE Sudden underflow / FP Environment Fast Float Select
142
;      8-10  - ignored
143
;      11    - Integer multiplication signed/unsigned select
144
;      12-13 - Integer multiplication format adjust
145
;      14-16 - Rounding mode select
146
;      17-19 - ignored
147
;      20    - Pipeline mode select
148
;      21    - ignored
149
;      22    - Invalid operation mask bit
150
;      23    - Reserved operand mask bit
151
;      24    - Overflow mask bit
152
;      25    - Underflow mask bit
153
;      26    - Inexact result mask bit
154
;      27    - Zero mask bit
155
;      28-31 - ignored
156
;
157
; FP_ENV_MODE_2 (Bits 32-63) [Hardware configuration register, rarely modified]
158
;
159
;      32-35 - Pipeline timer count
160
;      36-39 - Timer count for multiply-accumulate operation
161
;      40-43 - Timer count for save state transaction request
162
;      44-63 - ignored
163
;
164
; FP_ENV_MODE_1 definitions
165
;
166
    .set  FP_ENV_MODE_1_DEFAULT,                      CP_PFF_EQ_IEEE
167
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_AFF_EQ_IEEE
168
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_AFFINE_MODE
169
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_IEEE_TRAPS_DISABLED
170
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_IEEE_GRADUAL_UFLOW_MODE
171
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_UNSIGNED_INT_MPY_MODE
172
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_MF_EQ_LSBS
173
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_RMS_EQ_NEAREST
174
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_FLOWTHROUGH_MODE
175
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_INVALID_OP_EXCP_MASK
176
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_RESERVED_OP_EXCP_MASK
177
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_OVERFLOW_EXCP_MASK
178
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_UNDERFLOW_EXCP_MASK
179
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_INEXACT_EXCP_MASK
180
    .set  FP_ENV_MODE_1_DEFAULT,FP_ENV_MODE_1_DEFAULT|CP_ZERO_EXCP_MASK
181
;
182
; FP_ENV_MODE_2 definitions
183
;
184
    .set  FP_ENV_MODE_2_DEFAULT,                      CP_PLTC_EQ_6
185
    .set  FP_ENV_MODE_2_DEFAULT,FP_ENV_MODE_2_DEFAULT|CP_MATC_EQ_9
186
    .set  FP_ENV_MODE_2_DEFAULT,FP_ENV_MODE_2_DEFAULT|CP_MVTC_EQ_3
187
    .set  FP_ENV_MODE_2_DEFAULT,FP_ENV_MODE_2_DEFAULT|CP_NORMAL_DRDY_MODE
188
    .set  FP_ENV_MODE_2_DEFAULT,FP_ENV_MODE_2_DEFAULT|CP_HALT_ON_ERROR_DISABLED
189
    .set  FP_ENV_MODE_2_DEFAULT,FP_ENV_MODE_2_DEFAULT|CP_EXCP_DISABLED
190
;
191
; FP_FLAGS_DEFAULT definitions
192
;
193
    .equ  FP_FLAGS_DEFAULT,         0x00000000 ; No flags set
194
;
195
;  The following macros are used by transcendentals to access the environment.
196
;
197
;  MACRO NAME: clear_Flags
198
;
199
;  FUNCTION:  to clear the flags on entry to a transcendental routine.
200
;
201
;  INPUT PARAMETERS: reg  - temporary working register
202
;                    reg2 - temporary working register
203
;
204
 .macro clear_Flags,reg,reg2
205
 .endm
206
;
207
;  MACRO NAME: set_Invalid_Op_flag
208
;
209
;  FUNCTION:  to set the Invalid operation flag in the floating-point status
210
;             register
211
;
212
;  INPUT PARAMETERS: reg  - temporary working register
213
;                    reg2 - 2nd temporary working register
214
;
215
 .macro set_Invalid_Op_flag,reg,reg2
216
 .endm
217
 
218
;
219
;  MACRO NAME: set_Reserved_Op_flag
220
;
221
;  FUNCTION:  to set the Reserved Op flag in the floating-point status register
222
;
223
;  INPUT PARAMETERS: reg - temporary working register
224
;                    reg2 - 2nd temporary working register
225
;
226
 .macro set_Reserved_Op_flag,reg,reg2
227
 .endm
228
 
229
;
230
;  MACRO NAME: extract_Rounding_Mode
231
;
232
;  FUNCTION: to extract the Rounding Mode portion of the floating-point
233
;            invironment mode register, shift the value to the range of
234
;            0-7, and leave it in a register
235
;
236
;  INPUT PARAMETERS: reg - destination for the mode
237
;
238
 .macro extract_Rounding_Mode,reg
239
  .ifdef _29027_MODE
240
  .extern __29027Mode
241
    const reg,__29027Mode
242
    consth reg,__29027Mode
243
    load 0,0,reg,reg
244
    srl reg,reg,CP_RMS_POSITION
245
    and reg,reg,CP_RMS_MASK >> CP_RMS_POSITION
246
  .else
247
    mfsr reg,FPE
248
    and reg,reg,FPE_FPRND_MASK
249
    srl reg,reg,FPE_FPRND_POSITION
250
  .endif
251
 .endm
252
 
253
;
254
;  MACRO NAME: set_Rounding_Mode
255
;
256
;  FUNCTION:  to set the 29027 Rounding Mode to a given value
257
;
258
;  INPUT PARAMETERS: reg  - working register
259
;                    reg2 - second working register
260
;                    rounding_mode - value of the rounding mode
261
;                      0 - round to nearest
262
;                      1 - round to minus infinity
263
;                      2 - round to plus infinity
264
;                      3 - round to zero
265
;
266
;  NOTES: rounding_mode value is not checked
267
;         29027 Mode register is NOT written by this macro
268
;
269
 .macro set_Rounding_Mode,reg,reg2,mode
270
  .ifdef _29027_MODE
271
  .extern __29027Mode
272
    const reg2,__29027Mode
273
    consth reg2,__29027Mode
274
    load 0,0,reg,reg2
275
    const reg2,CP_RMS_MASK
276
    consth reg2,CP_RMS_MASK
277
    andn reg,reg,reg2
278
    const reg2,mode
279
    sll reg2,reg2,CP_RMS_POSITION
280
    or reg,reg,reg2
281
    const reg2,__29027Mode
282
    consth reg2,__29027Mode
283
    store 0,0,reg,reg2
284
    add reg2,reg2,4
285
    load 0,0,reg2,reg2
286
    cp_write_mode reg2,reg
287
  .else
288
    mfsr reg,FPE
289
    andn reg,reg,FPE_FPRND_MASK
290
    const reg2,mode
291
    sll reg2,reg2,FPE_FPRND_POSITION
292
    or reg,reg,reg2
293
    mtsr FPE,reg
294
  .endif
295
 .endm
296
;
297
;
298
;  NOTE:  The 29027 is the floating point coprocessor for the 29000.
299
;         It contains 8 floating point registers FP0 to FP7.  Three of
300
;         these, FP0, FP1, and FP2, are currently designated as scratch,
301
;         that is, they will not be preserved across calls.  The other
302
;         five contain values that must be saved whenever they are used
303
;         in code, and restored before the exit of the routine.  The 29027
304
;         registers are tagged with a single bit indicating the precision
305
;         of the current value.   When numbers are read into the 29027,
306
;         they are always stored in double precision, so that single
307
;         precision values are converted on input.  Only the MOVE instruction
308
;         fails to do this automatic widening.  If the result from calculations
309
;         in the 29027 ALU (determined by the result precision bit in the
310
;         instruction word) is to be single precision and the result saved in
311
;         an FP reg, the result precision bit from the instruction gets copied
312
;         into the precision bit for the register.  If a single precision
313
;         SNaN is saved from the 29027, it will be converted to a double
314
;         precision QNaN.  Along the way it will cause an unmasked exception
315
;         when read off the chip and cause changes to the status register.
316
;         So the preservation routine will need to modify the mode register to
317
;         mask off the exceptions, save the state of the status register before
318
;         saving the FP regs, and restore the status and mode registers to their
319
;         original settings when the save is complete.
320
;
321
;  REFERENCE:  The instructions to drive the Am29027 are described in the
322
;         Am29027 manual beginning on page 17.  Table 4 describes the
323
;         operation codes and table 3 the multiplexer codes.  Communication
324
;         with the 29000 is described on pages 11 and 12 of the Am29027
325
;         manual and chapters 6 and 8 of the Am29000 User's Manual
326
;
327
;  MACRO NAME:  save_FP_regs
328
;
329
;  FUNCTION:    to save the AMD 29027 floating point register values in the
330
;               29000 general purpose registers
331
;
332
;  INPUT PARAMETERS:  fp_register, one of the 29027 registers FP3 - FP7
333
;
334
;  REGISTER USAGE:  the following registers are used in save_FP_regs
335
;
336
;         rtn0    this register is used in setting the mode and status registers
337
;         rtn1    this register is used in setting the mode and status registers
338
;         rtn6    this register is used to store the MSW when FP3 is saved
339
;         rtn7    this register is used to store the LSW when FP3 is saved
340
;         rtn8    this register is used to store the MSW when FP4 is saved
341
;         rtn9    this register is used to store the LSW when FP4 is saved
342
;
343
 
344
 .macro save_FP_regs,fp_register
345
  .ifdef _29027_MODE
346
    ;
347
    ; For 29027 mode, expand the macro into 29027 code to preserve FP register
348
    ;
349
    .ifeqs "@fp_register@","FP3"
350
       const rtn6,__29027Mode                  ; Load the address of FP mode
351
       consth rtn6,__29027Mode
352
       load 0,0,rtn0,rtn6                      ; Load MSW of FP mode into rtn0
353
       add rtn6,rtn6,4                         ; Increment rtn6  + 4
354
       load 0,0,rtn1,rtn6                      ; Load LSW of FP mode into rtn1
355
       const rtn6,CP_RESERVED_OP_EXCP_MASK     ; Load mask to disable exception
356
       consth rtn6,CP_RESERVED_OP_EXCP_MASK
357
       or rtn0,rtn0,rtn6                       ; OR in disable of exception mask
358
       cp_write_mode rtn1, rtn0                ; Reset mode w/exception disabled
359
       cp_read_status rtn0                     ; Read status and save in rtn1
360
       const  rtn6,CP_PASS_P | CP_P_EQ_RF3     ; Instruction is PASS_P from RF3
361
       consth rtn6,CP_PASS_P | CP_P_EQ_RF3
362
                                               ; Load & execute the instruction
363
                                               ;
364
       store  1,CP_WRITE_INST | CP_START,rtn6,rtn6
365
       load   1,CP_READ_MSBS,rtn6,rtn6         ; Read the MSW to first register
366
       load   1,CP_READ_LSBS,rtn7,rtn7         ; Read the LSW to second register
367
       cp_write_status rtn0                    ; Restore the original status
368
       const rtn1,__29027Mode                  ; Load the address of FP mode
369
       consth rtn1,__29027Mode
370
       load 0,0,rtn0,rtn1                      ; Load MSW of FP mode into rtn0
371
       add rtn1,rtn1,4                         ; Increment rtn6 to __29027Mode+4
372
       load 0,0,rtn1,rtn1                      ; Load LSW of FP mode into rtn1
373
       cp_write_mode rtn1, rtn0                ; Restore the original write mode
374
    .endif
375
    .ifeqs "@fp_register@","FP4"
376
       const rtn8,__29027Mode                  ; Load the address of FP mode
377
       consth rtn8,__29027Mode
378
       load 0,0,rtn0,rtn8                      ; Load MSW of FP mode into rtn0
379
       add rtn8,rtn8,4                         ; Increment rtn6 + 4
380
       load 0,0,rtn1,rtn8                      ; Load LSW of FP mode into rtn1
381
       const rtn8,CP_RESERVED_OP_EXCP_MASK     ; Load mask to disable exception
382
       consth rtn8,CP_RESERVED_OP_EXCP_MASK
383
       or rtn0,rtn0,rtn8                       ; OR in disable of exception mask
384
       cp_write_mode rtn1, rtn0                ; Reset mode w/exception disabled
385
       cp_read_status rtn0                     ; Read status and save in rtn1
386
       const  rtn8,CP_PASS_P | CP_P_EQ_RF4     ; Instruction is PASS_P from RF4
387
       consth rtn8,CP_PASS_P | CP_P_EQ_RF4
388
                                               ; Load & execute the instruction
389
                                               ;
390
       store  1,CP_WRITE_INST | CP_START,rtn8,rtn8
391
       load   1,CP_READ_MSBS,rtn8,rtn8         ; Read the MSW to first register
392
       load   1,CP_READ_LSBS,rtn9,rtn9         ; Read the LSW to second register
393
       cp_write_status rtn0                    ; Restore the original status
394
       const rtn1,__29027Mode                  ; Load the address of FP mode
395
       consth rtn1,__29027Mode
396
       load 0,0,rtn0,rtn1                      ; Load MSW of FP mode into rtn0
397
       add rtn1,rtn1,4                         ; Increment rtn6 + 4
398
       load 0,0,rtn1,rtn1                      ; Load LSW of FP mode into rtn1
399
       cp_write_mode rtn1, rtn0                ; Restore the original write mode
400
    .endif
401
  .else
402
    ;
403
    ; For 29000 mode, do nothing
404
    ;
405
  .endif
406
 .endm
407
;
408
;  MACRO NAME:  restore_FP_regs
409
;
410
;  FUNCTION:    to restore the AMD 29027 floating point register values from the
411
;               29000 general purpose registers
412
;
413
;  INPUT PARAMETERS:  fp_register, one of the 29027 registers FP3 - FP7
414
;
415
;  REGISTER USAGE:  the following registers are used in restore_FP_regs
416
;
417
;         rtn0    this register is used in setting the mode and status registers
418
;         rtn6    the value in this register is stored as the MSW of FP3
419
;         rtn7    the value in this register is stored as the LSW of FP3
420
;         rtn8    the value in this register is stored as the MSW of FP4
421
;         rtn9    the value in this register is stored as the LSW of FP4
422
;
423
 .macro restore_FP_regs,fp_register
424
  .ifdef _29027_MODE
425
    ;
426
    ; For 29027 mode, move data from return registers to the correct FP register
427
    ;
428
    .ifeqs "@fp_register@","FP3"
429
       store  1,CP_WRITE_R ,rtn6,rtn7          ; Move the data to the R register
430
                                               ; Then create the instruction
431
                                               ;
432
       const   rtn0,CP_MOVE_P|CP_D_D|CP_P_EQ_R|CP_DEST_EQ_RF3
433
       consth  rtn0,CP_MOVE_P|CP_D_D|CP_P_EQ_R|CP_DEST_EQ_RF3
434
                                               ;
435
                                               ; Perform the write
436
                                               ;
437
       store  1,(CP_WRITE_INST | CP_START),rtn0,0
438
    .endif
439
    .ifeqs "@fp_register@","FP4"
440
       store  1,CP_WRITE_R ,rtn8,rtn9          ; Move the data to the R register
441
                                               ; Then create the instruction
442
                                               ;
443
       const   rtn0,CP_MOVE_P|CP_D_D|CP_P_EQ_R|CP_DEST_EQ_RF4
444
       consth  rtn0,CP_MOVE_P|CP_D_D|CP_P_EQ_R|CP_DEST_EQ_RF4
445
                                               ;
446
                                               ; Perform the write
447
                                               ;
448
       store  1,(CP_WRITE_INST | CP_START),rtn0,0
449
    .endif
450
  .else
451
    ;
452
    ; For 29000 mode, do nothing.
453
    ;
454
  .endif
455
 .endm
456
;
457
; end of file intrinsi.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.