56
56
#define POLY 0x82f63b78
57
57
58
58
/* Block sizes for three-way parallel crc computation. LONG and SHORT must
59
- both be powers of two. The associated string constants must be set
60
- accordingly, for use in constructing the assembler instructions. */
59
+ both be powers of two. */
61
60
#define LONG 8192
62
- #define LONGx1 "8192"
63
- #define LONGx2 "16384"
64
61
#define SHORT 256
65
- #define SHORTx1 "256"
66
- #define SHORTx2 "512"
67
62
68
63
#ifndef GEN_CRC32C_TABLES
69
64
#include "crc32c-tables.c"
@@ -100,9 +95,9 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
100
95
/* compute the crc for up to seven leading bytes to bring the data pointer
101
96
to an eight-byte boundary */
102
97
while (len && ((uintptr_t )buf & 7 ) != 0 ) {
103
- __asm__("crc32b\t" "(%1) , %0"
98
+ __asm__("crc32b\t" "%1 , %0"
104
99
: "+r" (crc0 )
105
- : "r" ( buf ), " m" (* buf ));
100
+ : "m" (* buf ));
106
101
buf ++ ;
107
102
len -- ;
108
103
}
@@ -114,14 +109,13 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
114
109
uintptr_t crc2 = 0 ;
115
110
const char * end = buf + LONG ;
116
111
do {
117
- __asm__(CRC32_PTR "\t" "(%3) , %0\n\t"
118
- CRC32_PTR "\t" LONGx1 "(%3) , %1\n\t"
119
- CRC32_PTR "\t" LONGx2 "(%3) , %2"
112
+ __asm__(CRC32_PTR "\t%3 , %0\n\t"
113
+ CRC32_PTR "\t%4 , %1\n\t"
114
+ CRC32_PTR "\t%5 , %2"
120
115
: "+r" (crc0 ), "+r" (crc1 ), "+r" (crc2 )
121
- : "r" (buf ),
122
- "m" (* (const char (* )[sizeof (void * )]) & buf [0 ]),
123
- "m" (* (const char (* )[sizeof (void * )]) & buf [LONG ]),
124
- "m" (* (const char (* )[sizeof (void * )]) & buf [LONG * 2 ]));
116
+ : "m" (* (const uintptr_t * ) & buf [0 ]),
117
+ "m" (* (const uintptr_t * ) & buf [LONG ]),
118
+ "m" (* (const uintptr_t * ) & buf [LONG * 2 ]));
125
119
buf += sizeof (void * );
126
120
} while (buf < end );
127
121
crc0 = crc32c_shift (crc32c_long , crc0 ) ^ crc1 ;
@@ -137,14 +131,13 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
137
131
uintptr_t crc2 = 0 ;
138
132
const char * end = buf + SHORT ;
139
133
do {
140
- __asm__(CRC32_PTR "\t" "(%3) , %0\n\t"
141
- CRC32_PTR "\t" SHORTx1 "(%3) , %1\n\t"
142
- CRC32_PTR "\t" SHORTx2 "(%3) , %2"
134
+ __asm__(CRC32_PTR "\t%3 , %0\n\t"
135
+ CRC32_PTR "\t%4 , %1\n\t"
136
+ CRC32_PTR "\t%5 , %2"
143
137
: "+r" (crc0 ), "+r" (crc1 ), "+r" (crc2 )
144
- : "r" (buf ),
145
- "m" (* (const char (* )[sizeof (void * )]) & buf [0 ]),
146
- "m" (* (const char (* )[sizeof (void * )]) & buf [SHORT ]),
147
- "m" (* (const char (* )[sizeof (void * )]) & buf [SHORT * 2 ]));
138
+ : "m" (* (const uintptr_t * ) & buf [0 ]),
139
+ "m" (* (const uintptr_t * ) & buf [SHORT ]),
140
+ "m" (* (const uintptr_t * ) & buf [SHORT * 2 ]));
148
141
buf += sizeof (void * );
149
142
} while (buf < end );
150
143
crc0 = crc32c_shift (crc32c_short , crc0 ) ^ crc1 ;
@@ -157,18 +150,18 @@ static uint32_t crc32c_sse42(uint32_t crc, const char *buf, size_t len)
157
150
block */
158
151
const char * end = buf + (len - (len & 7 ));
159
152
while (buf < end ) {
160
- __asm__(CRC32_PTR "\t" "(%1) , %0"
153
+ __asm__(CRC32_PTR "\t" "%1 , %0"
161
154
: "+r" (crc0 )
162
- : "r" ( buf ), " m" (* (const char ( * )[ sizeof ( void * )] ) buf ));
155
+ : "m" (* (const uintptr_t * ) buf ));
163
156
buf += sizeof (void * );
164
157
}
165
158
len &= 7 ;
166
159
167
160
/* compute the crc for up to seven trailing bytes */
168
161
while (len ) {
169
- __asm__("crc32b\t" "(%1) , %0"
162
+ __asm__("crc32b\t" "%1 , %0"
170
163
: "+r" (crc0 )
171
- : "r" ( buf ), " m" (* buf ));
164
+ : "m" (* buf ));
172
165
buf ++ ;
173
166
len -- ;
174
167
}
0 commit comments