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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-alpha/] [unaligned.h] - Blame information for rev 1777

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

Line No. Rev Author Line
1 1632 jcastillo
#ifndef __ALPHA_UNALIGNED_H
2
#define __ALPHA_UNALIGNED_H
3
 
4
/*
5
 * The main single-value unaligned transfer routines.
6
 */
7
#define get_unaligned(ptr) \
8
        ((__typeof__(*(ptr)))__get_unaligned((ptr), sizeof(*(ptr))))
9
#define put_unaligned(x,ptr) \
10
        __put_unaligned((unsigned long)(x), (ptr), sizeof(*(ptr)))
11
 
12
/*
13
 * This is a silly but good way to make sure that
14
 * the get/put functions are indeed always optimized,
15
 * and that we use the correct sizes.
16
 */
17
extern void bad_unaligned_access_length(void);
18
 
19
/*
20
 * Elemental unaligned loads
21
 */
22
 
23
extern inline unsigned long __uldq(const unsigned long * r11)
24
{
25
        unsigned long r1,r2;
26
        __asm__("ldq_u %0,%3\n\t"
27
                "ldq_u %1,%4\n\t"
28
                "extql %0,%2,%0\n\t"
29
                "extqh %1,%2,%1"
30
                :"=&r" (r1), "=&r" (r2)
31
                :"r" (r11),
32
                 "m" (*r11),
33
                 "m" (*(const unsigned long *)(7+(char *) r11)));
34
        return r1 | r2;
35
}
36
 
37
extern inline unsigned long __uldl(const unsigned int * r11)
38
{
39
        unsigned long r1,r2;
40
        __asm__("ldq_u %0,%3\n\t"
41
                "ldq_u %1,%4\n\t"
42
                "extll %0,%2,%0\n\t"
43
                "extlh %1,%2,%1"
44
                :"=&r" (r1), "=&r" (r2)
45
                :"r" (r11),
46
                 "m" (*r11),
47
                 "m" (*(const unsigned long *)(3+(char *) r11)));
48
        return r1 | r2;
49
}
50
 
51
extern inline unsigned long __uldw(const unsigned short * r11)
52
{
53
        unsigned long r1,r2;
54
        __asm__("ldq_u %0,%3\n\t"
55
                "ldq_u %1,%4\n\t"
56
                "extwl %0,%2,%0\n\t"
57
                "extwh %1,%2,%1"
58
                :"=&r" (r1), "=&r" (r2)
59
                :"r" (r11),
60
                 "m" (*r11),
61
                 "m" (*(const unsigned long *)(1+(char *) r11)));
62
        return r1 | r2;
63
}
64
 
65
/*
66
 * Elemental unaligned stores
67
 */
68
 
69
extern inline void __ustq(unsigned long r5, unsigned long * r11)
70
{
71
        unsigned long r1,r2,r3,r4;
72
 
73
        __asm__("ldq_u %3,%1\n\t"
74
                "ldq_u %2,%0\n\t"
75
                "insqh %6,%7,%5\n\t"
76
                "insql %6,%7,%4\n\t"
77
                "mskqh %3,%7,%3\n\t"
78
                "mskql %2,%7,%2\n\t"
79
                "bis %3,%5,%3\n\t"
80
                "bis %2,%4,%2\n\t"
81
                "stq_u %3,%1\n\t"
82
                "stq_u %2,%0"
83
                :"=m" (*r11),
84
                 "=m" (*(unsigned long *)(7+(char *) r11)),
85
                 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
86
                :"r" (r5), "r" (r11));
87
}
88
 
89
extern inline void __ustl(unsigned long r5, unsigned int * r11)
90
{
91
        unsigned long r1,r2,r3,r4;
92
 
93
        __asm__("ldq_u %3,%1\n\t"
94
                "ldq_u %2,%0\n\t"
95
                "inslh %6,%7,%5\n\t"
96
                "insll %6,%7,%4\n\t"
97
                "msklh %3,%7,%3\n\t"
98
                "mskll %2,%7,%2\n\t"
99
                "bis %3,%5,%3\n\t"
100
                "bis %2,%4,%2\n\t"
101
                "stq_u %3,%1\n\t"
102
                "stq_u %2,%0"
103
                :"=m" (*r11),
104
                 "=m" (*(unsigned long *)(3+(char *) r11)),
105
                 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
106
                :"r" (r5), "r" (r11));
107
}
108
 
109
extern inline void __ustw(unsigned long r5, unsigned short * r11)
110
{
111
        unsigned long r1,r2,r3,r4;
112
 
113
        __asm__("ldq_u %3,%1\n\t"
114
                "ldq_u %2,%0\n\t"
115
                "inswh %6,%7,%5\n\t"
116
                "inswl %6,%7,%4\n\t"
117
                "mskwh %3,%7,%3\n\t"
118
                "mskwl %2,%7,%2\n\t"
119
                "bis %3,%5,%3\n\t"
120
                "bis %2,%4,%2\n\t"
121
                "stq_u %3,%1\n\t"
122
                "stq_u %2,%0"
123
                :"=m" (*r11),
124
                 "=m" (*(unsigned long *)(1+(char *) r11)),
125
                 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
126
                :"r" (r5), "r" (r11));
127
}
128
 
129
extern inline unsigned long __get_unaligned(const void *ptr, size_t size)
130
{
131
        unsigned long val;
132
        switch (size) {
133
              case 1:
134
                val = *(const unsigned char *)ptr;
135
                break;
136
              case 2:
137
                val = __uldw((const unsigned short *)ptr);
138
                break;
139
              case 4:
140
                val = __uldl((const unsigned int *)ptr);
141
                break;
142
              case 8:
143
                val = __uldq((const unsigned long *)ptr);
144
                break;
145
              default:
146
                bad_unaligned_access_length();
147
        }
148
        return val;
149
}
150
 
151
extern inline void __put_unaligned(unsigned long val, void *ptr, size_t size)
152
{
153
        switch (size) {
154
              case 1:
155
                *(unsigned char *)ptr = (val);
156
                break;
157
              case 2:
158
                __ustw(val, (unsigned short *)ptr);
159
                break;
160
              case 4:
161
                __ustl(val, (unsigned int *)ptr);
162
                break;
163
              case 8:
164
                __ustq(val, (unsigned long *)ptr);
165
                break;
166
              default:
167
                bad_unaligned_access_length();
168
        }
169
}
170
 
171
#endif

powered by: WebSVN 2.1.0

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