1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
|
/* auto-generated: cd cryptoint; ./autogen */
/* cryptoint 20250414 */
#ifndef crypto_int8_h
#define crypto_int8_h
#include <inttypes.h>
#define crypto_int8 int8_t
#define crypto_int8_unsigned uint8_t
#define crypto_int8_optblocker tinyssh_int8_optblocker
extern volatile crypto_int8 crypto_int8_optblocker;
__attribute__((unused))
static inline
crypto_int8 crypto_int8_load(const unsigned char *crypto_int8_s) {
crypto_int8 crypto_int8_z = 0;
crypto_int8_z |= ((crypto_int8) (*crypto_int8_s++)) << 0;
return crypto_int8_z;
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_load_bigendian(const unsigned char *crypto_int8_s) {
crypto_int8 crypto_int8_z = 0;
crypto_int8_z |= ((crypto_int8) (*crypto_int8_s++)) << 0;
return crypto_int8_z;
}
__attribute__((unused))
static inline
void crypto_int8_store(unsigned char *crypto_int8_s,crypto_int8 crypto_int8_x) {
*crypto_int8_s++ = crypto_int8_x >> 0;
}
__attribute__((unused))
static inline
void crypto_int8_store_bigendian(unsigned char *crypto_int8_s,crypto_int8 crypto_int8_x) {
*crypto_int8_s++ = crypto_int8_x >> 0;
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_negative_mask(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
__asm__ ("sarb $7,%0" : "+r"(crypto_int8_x) : : "cc");
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_y;
__asm__ ("sbfx %w0,%w1,7,1" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
crypto_int8 crypto_int8_y;
__asm__ ("sxtb %0,%1\n asr %0,%0,#31" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_y;
__asm__ ("sll %1,24,%0\n sra %0,31,%0" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#else
crypto_int8_x >>= 8-6;
crypto_int8_x += crypto_int8_optblocker;
crypto_int8_x >>= 5;
return crypto_int8_x;
#endif
}
__attribute__((unused))
static inline
crypto_int8_unsigned crypto_int8_unsigned_topbit_01(crypto_int8_unsigned crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
__asm__ ("shrb $7,%0" : "+r"(crypto_int8_x) : : "cc");
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8_unsigned crypto_int8_y;
__asm__ ("ubfx %w0,%w1,7,1" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
crypto_int8 crypto_int8_y;
__asm__ ("uxtb %0,%1\n lsr %0,%0,#7" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8_unsigned crypto_int8_y;
__asm__ ("and %1,255,%0\n srl %0,7,%0" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#else
crypto_int8_x >>= 8-6;
crypto_int8_x += crypto_int8_optblocker;
crypto_int8_x >>= 5;
return crypto_int8_x;
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_negative_01(crypto_int8 crypto_int8_x) {
return crypto_int8_unsigned_topbit_01(crypto_int8_x);
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_topbit_mask(crypto_int8 crypto_int8_x) {
return crypto_int8_negative_mask(crypto_int8_x);
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_topbit_01(crypto_int8 crypto_int8_x) {
return crypto_int8_unsigned_topbit_01(crypto_int8_x);
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_bottombit_mask(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
__asm__ ("andb $1,%0" : "+r"(crypto_int8_x) : : "cc");
return -crypto_int8_x;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_y;
__asm__ ("sbfx %w0,%w1,0,1" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
crypto_int8 crypto_int8_y;
__asm__ ("and %0,%1,#1\n neg %0,%0" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_y;
__asm__ ("and %1,1,%0\n neg %0,%0" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#else
crypto_int8_x &= 1 + crypto_int8_optblocker;
return -crypto_int8_x;
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_bottombit_01(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
__asm__ ("andb $1,%0" : "+r"(crypto_int8_x) : : "cc");
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_y;
__asm__ ("ubfx %w0,%w1,0,1" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
crypto_int8 crypto_int8_y;
__asm__ ("and %0,%1,#1" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_y;
__asm__ ("and %1,1,%0" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#else
crypto_int8_x &= 1 + crypto_int8_optblocker;
return crypto_int8_x;
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_bitinrangepublicpos_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_s) {
#if defined(__GNUC__) && defined(__x86_64__)
__asm__ ("sarb %%cl,%0" : "+r"(crypto_int8_x) : "c"(crypto_int8_s) : "cc");
#elif defined(__GNUC__) && defined(__aarch64__)
__asm__ ("sxtb %w0,%w0\n asr %w0,%w0,%w1" : "+&r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
__asm__ ("and %0,%0,#7\n sxtb %1,%1\n asr %1,%1,%0" : "+&r"(crypto_int8_s), "+r"(crypto_int8_x) : : );
#elif defined(__GNUC__) && defined(__sparc_v8__)
__asm__ ("and %0,7,%0\n sra %1,%0,%1" : "+&r"(crypto_int8_s), "+r"(crypto_int8_x) : : );
#else
crypto_int8_x >>= crypto_int8_s ^ crypto_int8_optblocker;
#endif
return crypto_int8_bottombit_mask(crypto_int8_x);
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_bitinrangepublicpos_01(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_s) {
#if defined(__GNUC__) && defined(__x86_64__)
__asm__ ("sarb %%cl,%0" : "+r"(crypto_int8_x) : "c"(crypto_int8_s) : "cc");
#elif defined(__GNUC__) && defined(__aarch64__)
__asm__ ("sxtb %w0,%w0\n asr %w0,%w0,%w1" : "+&r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
__asm__ ("and %0,%0,#7\n sxtb %1,%1\n asr %1,%1,%0" : "+&r"(crypto_int8_s), "+r"(crypto_int8_x) : : );
#elif defined(__GNUC__) && defined(__sparc_v8__)
__asm__ ("and %0,7,%0\n sra %1,%0,%1" : "+&r"(crypto_int8_s), "+r"(crypto_int8_x) : : );
#else
crypto_int8_x >>= crypto_int8_s ^ crypto_int8_optblocker;
#endif
return crypto_int8_bottombit_01(crypto_int8_x);
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_shlmod(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_s) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8_s &= 7;
__asm__ ("shlb %%cl,%0" : "+r"(crypto_int8_x) : "c"(crypto_int8_s) : "cc");
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8_s &= 7;
__asm__ ("and %w0,%w0,255\n lsl %w0,%w0,%w1" : "+&r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
crypto_int8_s &= 7;
__asm__ ("lsl %0,%0,%1\n sxtb %0,%0" : "+r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8_s &= 7; crypto_int8_s += 24;
__asm__ ("sll %0,%1,%0\n sra %0,24,%0" : "+r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#else
int crypto_int8_k, crypto_int8_l;
for (crypto_int8_l = 0,crypto_int8_k = 1;crypto_int8_k < 8;++crypto_int8_l,crypto_int8_k *= 2)
crypto_int8_x ^= (crypto_int8_x ^ (crypto_int8_x << crypto_int8_k)) & crypto_int8_bitinrangepublicpos_mask(crypto_int8_s,crypto_int8_l);
#endif
return crypto_int8_x;
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_shrmod(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_s) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8_s &= 7;
__asm__ ("sarb %%cl,%0" : "+r"(crypto_int8_x) : "c"(crypto_int8_s) : "cc");
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8_s &= 7;
__asm__ ("sxtb %w0,%w0\n asr %w0,%w0,%w1" : "+&r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
crypto_int8_s &= 7;
__asm__ ("sxtb %0,%0\n asr %0,%0,%1" : "+&r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8_s &= 7;
__asm__ ("sra %0,%1,%0" : "+r"(crypto_int8_x) : "r"(crypto_int8_s) : );
#else
int crypto_int8_k, crypto_int8_l;
for (crypto_int8_l = 0,crypto_int8_k = 1;crypto_int8_k < 8;++crypto_int8_l,crypto_int8_k *= 2)
crypto_int8_x ^= (crypto_int8_x ^ (crypto_int8_x >> crypto_int8_k)) & crypto_int8_bitinrangepublicpos_mask(crypto_int8_s,crypto_int8_l);
#endif
return crypto_int8_x;
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_bitmod_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_s) {
crypto_int8_x = crypto_int8_shrmod(crypto_int8_x,crypto_int8_s);
return crypto_int8_bottombit_mask(crypto_int8_x);
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_bitmod_01(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_s) {
crypto_int8_x = crypto_int8_shrmod(crypto_int8_x,crypto_int8_s);
return crypto_int8_bottombit_01(crypto_int8_x);
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_nonzero_mask(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $-1,%1\n testb %b2,%b2\n cmovnel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("tst %w1,255\n csetm %w0,ne" : "=r"(crypto_int8_z) : "r"(crypto_int8_x) : "cc");
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
__asm__ ("uxtb %0,%0\n cmp %0,#0\n movne %0,#-1" : "+r"(crypto_int8_x) : : "cc");
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_z;
__asm__ ("and %0,255,%0\n cmp %%g0,%0\n subx %%g0,0,%1" : "+r"(crypto_int8_x), "=r"(crypto_int8_z) : : "cc");
return crypto_int8_z;
#else
crypto_int8_x |= -crypto_int8_x;
return crypto_int8_negative_mask(crypto_int8_x);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_nonzero_01(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $1,%1\n testb %b2,%b2\n cmovnel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("tst %w1,255\n cset %w0,ne" : "=r"(crypto_int8_z) : "r"(crypto_int8_x) : "cc");
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__)
__asm__ ("uxtb %0,%0\n cmp %0,#0\n movne %0,#1" : "+r"(crypto_int8_x) : : "cc");
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_z;
__asm__ ("and %0,255,%0\n cmp %%g0,%0\n addx %%g0,0,%1" : "+r"(crypto_int8_x), "=r"(crypto_int8_z) : : "cc");
return crypto_int8_z;
#else
crypto_int8_x |= -crypto_int8_x;
return crypto_int8_unsigned_topbit_01(crypto_int8_x);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_positive_mask(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $-1,%1\n testb %b2,%b2\n cmovgl %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("sxtb %w0,%w1\n cmp %w0,0\n csetm %w0,gt" : "=r"(crypto_int8_z) : "r"(crypto_int8_x) : "cc");
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_z;
__asm__ ("sll %1,24,%0\n sra %0,31,%0\n sub %0,%1,%0\n sra %0,31,%0" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x) : );
return crypto_int8_z;
#else
crypto_int8 crypto_int8_z = -crypto_int8_x;
crypto_int8_z ^= crypto_int8_x & crypto_int8_z;
return crypto_int8_negative_mask(crypto_int8_z);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_positive_01(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $1,%1\n testb %b2,%b2\n cmovgl %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("sxtb %w0,%w1\n cmp %w0,0\n cset %w0,gt" : "=r"(crypto_int8_z) : "r"(crypto_int8_x) : "cc");
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_z;
__asm__ ("sll %1,24,%0\n sra %0,31,%0\n sub %0,%1,%0\n srl %0,31,%0" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x) : );
return crypto_int8_z;
#else
crypto_int8 crypto_int8_z = -crypto_int8_x;
crypto_int8_z ^= crypto_int8_x & crypto_int8_z;
return crypto_int8_unsigned_topbit_01(crypto_int8_z);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_zero_mask(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $-1,%1\n testb %b2,%b2\n cmovel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("tst %w1,255\n csetm %w0,eq" : "=r"(crypto_int8_z) : "r"(crypto_int8_x) : "cc");
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_z;
__asm__ ("and %0,255,%0\n cmp %%g0,%0\n addx %%g0,-1,%1" : "+r"(crypto_int8_x), "=r"(crypto_int8_z) : : "cc");
return crypto_int8_z;
#else
return ~crypto_int8_nonzero_mask(crypto_int8_x);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_zero_01(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $1,%1\n testb %b2,%b2\n cmovel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("tst %w1,255\n cset %w0,eq" : "=r"(crypto_int8_z) : "r"(crypto_int8_x) : "cc");
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__sparc_v8__)
crypto_int8 crypto_int8_z;
__asm__ ("and %0,255,%0\n cmp %%g0,%0\n subx %%g0,-1,%1" : "+r"(crypto_int8_x), "=r"(crypto_int8_z) : : "cc");
return crypto_int8_z;
#else
return 1-crypto_int8_nonzero_01(crypto_int8_x);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_unequal_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $-1,%1\n cmpb %b3,%b2\n cmovnel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("and %w0,%w1,255\n cmp %w0,%w2,uxtb\n csetm %w0,ne" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
return crypto_int8_nonzero_mask(crypto_int8_x ^ crypto_int8_y);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_unequal_01(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $1,%1\n cmpb %b3,%b2\n cmovnel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("and %w0,%w1,255\n cmp %w0,%w2,uxtb\n cset %w0,ne" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
return crypto_int8_nonzero_01(crypto_int8_x ^ crypto_int8_y);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_equal_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $-1,%1\n cmpb %b3,%b2\n cmovel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("and %w0,%w1,255\n cmp %w0,%w2,uxtb\n csetm %w0,eq" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
return crypto_int8_zero_mask(crypto_int8_x ^ crypto_int8_y);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_equal_01(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $1,%1\n cmpb %b3,%b2\n cmovel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("and %w0,%w1,255\n cmp %w0,%w2,uxtb\n cset %w0,eq" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
return crypto_int8_zero_01(crypto_int8_x ^ crypto_int8_y);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_min(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y;
__asm__ ("cmpb %b1,%b0\n cmovgl %1,%0" : "+q"(crypto_int8_x32) : "q"(crypto_int8_y32) : "cc");
crypto_int8_x = crypto_int8_x32;
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__aarch64__)
__asm__ ("sxtb %w0,%w0\n cmp %w0,%w1,sxtb\n csel %w0,%w0,%w1,lt" : "+&r"(crypto_int8_x) : "r"(crypto_int8_y) : "cc");
return crypto_int8_x;
#else
crypto_int8 crypto_int8_r = crypto_int8_y ^ crypto_int8_x;
crypto_int8 crypto_int8_z = crypto_int8_y - crypto_int8_x;
crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_y);
crypto_int8_z = crypto_int8_negative_mask(crypto_int8_z);
crypto_int8_z &= crypto_int8_r;
return crypto_int8_x ^ crypto_int8_z;
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_max(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y;
__asm__ ("cmpb %b1,%b0\n cmovll %1,%0" : "+q"(crypto_int8_x32) : "q"(crypto_int8_y32) : "cc");
crypto_int8_x = crypto_int8_x32;
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__aarch64__)
__asm__ ("sxtb %w0,%w0\n cmp %w0,%w1,sxtb\n csel %w0,%w1,%w0,lt" : "+&r"(crypto_int8_x) : "r"(crypto_int8_y) : "cc");
return crypto_int8_x;
#else
crypto_int8 crypto_int8_r = crypto_int8_y ^ crypto_int8_x;
crypto_int8 crypto_int8_z = crypto_int8_y - crypto_int8_x;
crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_y);
crypto_int8_z = crypto_int8_negative_mask(crypto_int8_z);
crypto_int8_z &= crypto_int8_r;
return crypto_int8_y ^ crypto_int8_z;
#endif
}
__attribute__((unused))
static inline
void crypto_int8_minmax(crypto_int8 *crypto_int8_p,crypto_int8 *crypto_int8_q) {
crypto_int8 crypto_int8_x = *crypto_int8_p;
crypto_int8 crypto_int8_y = *crypto_int8_q;
#if defined(__GNUC__) && defined(__x86_64__)
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_z32;
__asm__ ("cmpb %b2,%b1\n movl %1,%0\n cmovgl %2,%1\n cmovgl %0,%2" : "=&r"(crypto_int8_z32), "+&q"(crypto_int8_x32), "+q"(crypto_int8_y32) : : "cc");
crypto_int8_x = crypto_int8_x32; crypto_int8_y = crypto_int8_y32;
*crypto_int8_p = crypto_int8_x;
*crypto_int8_q = crypto_int8_y;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_r, crypto_int8_s;
__asm__ ("sxtb %w0,%w0\n cmp %w0,%w3,sxtb\n csel %w1,%w0,%w3,lt\n csel %w2,%w3,%w0,lt" : "+&r"(crypto_int8_x), "=&r"(crypto_int8_r), "=r"(crypto_int8_s) : "r"(crypto_int8_y) : "cc");
*crypto_int8_p = crypto_int8_r;
*crypto_int8_q = crypto_int8_s;
#else
crypto_int8 crypto_int8_r = crypto_int8_y ^ crypto_int8_x;
crypto_int8 crypto_int8_z = crypto_int8_y - crypto_int8_x;
crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_y);
crypto_int8_z = crypto_int8_negative_mask(crypto_int8_z);
crypto_int8_z &= crypto_int8_r;
crypto_int8_x ^= crypto_int8_z;
crypto_int8_y ^= crypto_int8_z;
*crypto_int8_p = crypto_int8_x;
*crypto_int8_q = crypto_int8_y;
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_smaller_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $-1,%1\n cmpb %b3,%b2\n cmovll %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("sxtb %w0,%w1\n cmp %w0,%w2,sxtb\n csetm %w0,lt" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
crypto_int8 crypto_int8_r = crypto_int8_x ^ crypto_int8_y;
crypto_int8 crypto_int8_z = crypto_int8_x - crypto_int8_y;
crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_x);
return crypto_int8_negative_mask(crypto_int8_z);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_smaller_01(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $1,%1\n cmpb %b3,%b2\n cmovll %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("sxtb %w0,%w1\n cmp %w0,%w2,sxtb\n cset %w0,lt" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
crypto_int8 crypto_int8_r = crypto_int8_x ^ crypto_int8_y;
crypto_int8 crypto_int8_z = crypto_int8_x - crypto_int8_y;
crypto_int8_z ^= crypto_int8_r & (crypto_int8_z ^ crypto_int8_x);
return crypto_int8_unsigned_topbit_01(crypto_int8_z);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_leq_mask(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $-1,%1\n cmpb %b3,%b2\n cmovlel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("sxtb %w0,%w1\n cmp %w0,%w2,sxtb\n csetm %w0,le" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
return ~crypto_int8_smaller_mask(crypto_int8_y,crypto_int8_x);
#endif
}
__attribute__((unused))
static inline
crypto_int8 crypto_int8_leq_01(crypto_int8 crypto_int8_x,crypto_int8 crypto_int8_y) {
#if defined(__GNUC__) && defined(__x86_64__)
crypto_int8 crypto_int8_z;
int32_t crypto_int8_x32 = crypto_int8_x,crypto_int8_y32 = crypto_int8_y,crypto_int8_q32,crypto_int8_z32;
__asm__ ("xorl %0,%0\n movl $1,%1\n cmpb %b3,%b2\n cmovlel %1,%0" : "=&r"(crypto_int8_z32), "=&r"(crypto_int8_q32) : "q"(crypto_int8_x32), "q"(crypto_int8_y32) : "cc");
crypto_int8_z = crypto_int8_z32;
return crypto_int8_z;
#elif defined(__GNUC__) && defined(__aarch64__)
crypto_int8 crypto_int8_z;
__asm__ ("sxtb %w0,%w1\n cmp %w0,%w2,sxtb\n cset %w0,le" : "=&r"(crypto_int8_z) : "r"(crypto_int8_x), "r"(crypto_int8_y) : "cc");
return crypto_int8_z;
#else
return 1-crypto_int8_smaller_01(crypto_int8_y,crypto_int8_x);
#endif
}
__attribute__((unused))
static inline
int crypto_int8_ones_num(crypto_int8 crypto_int8_x) {
crypto_int8_unsigned crypto_int8_y = crypto_int8_x;
const crypto_int8 C0 = 0x55;
const crypto_int8 C1 = 0x33;
const crypto_int8 C2 = 0x0f;
crypto_int8_y -= ((crypto_int8_y >> 1) & C0);
crypto_int8_y = (crypto_int8_y & C1) + ((crypto_int8_y >> 2) & C1);
crypto_int8_y = (crypto_int8_y + (crypto_int8_y >> 4)) & C2;
return crypto_int8_y;
}
__attribute__((unused))
static inline
int crypto_int8_bottomzeros_num(crypto_int8 crypto_int8_x) {
#if defined(__GNUC__) && defined(__x86_64__)
int32_t fallback = 8;
int32_t crypto_int8_x32 = crypto_int8_x;
__asm__ ("bsfl %0,%0\n cmovel %1,%0" : "+&r"(crypto_int8_x32) : "r"(fallback) : "cc");
crypto_int8_x = crypto_int8_x32;
return crypto_int8_x;
#elif defined(__GNUC__) && defined(__aarch64__)
int64_t crypto_int8_y;
__asm__ ("orr %w0,%w1,-256\n rbit %w0,%w0\n clz %w0,%w0" : "=r"(crypto_int8_y) : "r"(crypto_int8_x) : );
return crypto_int8_y;
#else
crypto_int8 crypto_int8_y = crypto_int8_x ^ (crypto_int8_x-1);
crypto_int8_y = ((crypto_int8) crypto_int8_y) >> 1;
crypto_int8_y &= ~(crypto_int8_x & (((crypto_int8) 1) << (8-1)));
return crypto_int8_ones_num(crypto_int8_y);
#endif
}
#endif
|