~ubuntu-branches/ubuntu/vivid/gcl/vivid

« back to all changes in this revision

Viewing changes to h/sparc.h

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2002-03-04 14:29:59 UTC
  • Revision ID: james.westby@ubuntu.com-20020304142959-dey14w08kr7lldu3
Tags: upstream-2.5.0.cvs20020219
ImportĀ upstreamĀ versionĀ 2.5.0.cvs20020219

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
#ifdef __GNUC__
 
4
/* have assembler macros */
 
5
 
 
6
#define add_carry(x,y,h) \
 
7
({ ulong __res,__x =(x),__y=(y); \
 
8
  asm volatile(  \
 
9
"addcc %2,%3,%0
 
10
\taddx %1,%%g0,%1"\
 
11
 : "=r" (__res),"=r" (h) \
 
12
 : "r" (__x) , "rn" (__y),"1" (h) ); \
 
13
   __res;})
 
14
 
 
15
 
 
16
  /* SET_MACHINE_CARRY Set the machine carry flag
 
17
       if  overflow = 1 otherwise clear it.
 
18
   */
 
19
 
 
20
#define SET_MACHINE_CARRY(overflow) \
 
21
 asm volatile("subcc %%g0,%0,%%g0" \
 
22
              : :"r" (overflow))
 
23
 
 
24
  /* SET_OVERFLOW Set the overflow = the current carry code
 
25
     Note that machine loads and mov's should not affect
 
26
     the carry code. 
 
27
   */
 
28
 
 
29
#define SET_OVERFLOW \
 
30
  asm volatile("addx %%g0,%%g0,%0" \
 
31
  : "=r" (overflow))
 
32
 
 
33
#define ADDXCC(u,v) \
 
34
 ({ulong res;  asm("addxcc %1,%2,%0" \
 
35
  : "=r" (res): \
 
36
  "r" (u),"r" (v)); res;})
 
37
#define SUBXCC(u,v) \
 
38
 ({ulong res;  asm("subxcc %1,%2,%0" \
 
39
  : "=r" (res): \
 
40
  "r" (u),"r" (v)); res;})
 
41
 
 
42
/* get a copy of mulul3 included for when inlining not there */
 
43
#define NEED_MULUL3
 
44
 
 
45
#define mulul(a,b,__hi) \
 
46
({unsigned plong __x=(a),__y=(b); \
 
47
   asm(" 
 
48
        or      %0,%3,%%o4      
 
49
        mov     %0,%%y
 
50
        andncc  %%o4,0xfff,%%g0
 
51
        be      2f
 
52
        andcc   %%g0,%%g0,%%o4
 
53
        mulscc  %%o4,%3,%%o4
 
54
        mulscc  %%o4,%3,%%o4
 
55
        mulscc  %%o4,%3,%%o4
 
56
        mulscc  %%o4,%3,%%o4
 
57
        mulscc  %%o4,%3,%%o4
 
58
        mulscc  %%o4,%3,%%o4
 
59
        mulscc  %%o4,%3,%%o4
 
60
        mulscc  %%o4,%3,%%o4
 
61
        mulscc  %%o4,%3,%%o4
 
62
        mulscc  %%o4,%3,%%o4
 
63
        mulscc  %%o4,%3,%%o4
 
64
        mulscc  %%o4,%3,%%o4
 
65
        mulscc  %%o4,%3,%%o4
 
66
        mulscc  %%o4,%3,%%o4
 
67
        mulscc  %%o4,%3,%%o4
 
68
        mulscc  %%o4,%3,%%o4
 
69
        mulscc  %%o4,%3,%%o4
 
70
        mulscc  %%o4,%3,%%o4
 
71
        mulscc  %%o4,%3,%%o4
 
72
        mulscc  %%o4,%3,%%o4
 
73
        mulscc  %%o4,%3,%%o4
 
74
        mulscc  %%o4,%3,%%o4
 
75
        mulscc  %%o4,%3,%%o4
 
76
        mulscc  %%o4,%3,%%o4
 
77
        mulscc  %%o4,%3,%%o4
 
78
        mulscc  %%o4,%3,%%o4
 
79
        mulscc  %%o4,%3,%%o4
 
80
        mulscc  %%o4,%3,%%o4
 
81
        mulscc  %%o4,%3,%%o4
 
82
        mulscc  %%o4,%3,%%o4
 
83
        mulscc  %%o4,%3,%%o4
 
84
        mulscc  %%o4,%3,%%o4
 
85
        mulscc  %%o4,%%g0,%%o4
 
86
        tst     %3
 
87
        bl,a    1f
 
88
        add     %%o4,%0,%%o4
 
89
1:      mov     %%o4,%1
 
90
        b       3f 
 
91
        rd      %%y,%0
 
92
2:      clr     %1
 
93
        mulscc  %%o4,%3,%%o4
 
94
        mulscc  %%o4,%3,%%o4
 
95
        mulscc  %%o4,%3,%%o4
 
96
        mulscc  %%o4,%3,%%o4
 
97
        mulscc  %%o4,%3,%%o4
 
98
        mulscc  %%o4,%3,%%o4
 
99
        mulscc  %%o4,%3,%%o4
 
100
        mulscc  %%o4,%3,%%o4
 
101
        mulscc  %%o4,%3,%%o4
 
102
        mulscc  %%o4,%3,%%o4
 
103
        mulscc  %%o4,%3,%%o4
 
104
        mulscc  %%o4,%3,%%o4
 
105
        mulscc  %%o4,%%g0,%%o4
 
106
        rd      %%y,%%o5
 
107
        sll     %%o4,12,%%o4
 
108
        srl     %%o5,20,%%o5
 
109
        or      %%o5,%%o4,%0
 
110
3:       
 
111
"  \
 
112
  : "=r" (__x),"=&r" (__hi): \
 
113
    "0" (__x),"r" (__y): \
 
114
     "%o4","%o5"); __x;})    /* "y" should be hear in that it is munged */
 
115
/* the above '=&r' indicates that the register for _hi may NOT be the
 
116
same reg as used by __y.*/
 
117
 
 
118
 
 
119
 
 
120
#else  /* no __GNUC__ */
 
121
 
 
122
 
 
123
#endif
 
124