ashldi3.c 466 B

1234567891011121314151617181920212223242526
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include "libgcc.h"
  3. DWtype
  4. __ashldi3(DWtype u, word_type b)
  5. {
  6. const DWunion uu = {.ll = u};
  7. const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
  8. DWunion w;
  9. if (b == 0)
  10. return u;
  11. if (bm <= 0) {
  12. w.s.low = 0;
  13. w.s.high = (UWtype) uu.s.low << -bm;
  14. } else {
  15. const UWtype carries = (UWtype) uu.s.low >> bm;
  16. w.s.low = (UWtype) uu.s.low << b;
  17. w.s.high = ((UWtype) uu.s.high << b) | carries;
  18. }
  19. return w.ll;
  20. }