switch_csky_gcc.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifdef SLP_EVAL
  2. #define STACK_MAGIC 0
  3. #define REG_FP "r8"
  4. #ifdef __CSKYABIV2__
  5. #define REGS_TO_SAVE_GENERAL "r4", "r5", "r6", "r7", "r9", "r10", "r11", "r15",\
  6. "r16", "r17", "r18", "r19", "r20", "r21", "r22",\
  7. "r23", "r24", "r25"
  8. #if defined (__CSKY_HARD_FLOAT__) || (__CSKY_VDSP__)
  9. #define REGS_TO_SAVE REGS_TO_SAVE_GENERAL, "vr8", "vr9", "vr10", "vr11", "vr12",\
  10. "vr13", "vr14", "vr15"
  11. #else
  12. #define REGS_TO_SAVE REGS_TO_SAVE_GENERAL
  13. #endif
  14. #else
  15. #define REGS_TO_SAVE "r9", "r10", "r11", "r12", "r13", "r15"
  16. #endif
  17. static int
  18. #ifdef __GNUC__
  19. __attribute__((optimize("no-omit-frame-pointer")))
  20. #endif
  21. slp_switch(void)
  22. {
  23. register int *stackref, stsizediff;
  24. int result;
  25. __asm__ volatile ("" : : : REGS_TO_SAVE);
  26. __asm__ ("mov %0, sp" : "=r" (stackref));
  27. {
  28. SLP_SAVE_STATE(stackref, stsizediff);
  29. __asm__ volatile (
  30. "addu sp,%0\n"
  31. "addu "REG_FP",%0\n"
  32. :
  33. : "r" (stsizediff)
  34. );
  35. SLP_RESTORE_STATE();
  36. }
  37. __asm__ volatile ("movi %0, 0" : "=r" (result));
  38. __asm__ volatile ("" : : : REGS_TO_SAVE);
  39. return result;
  40. }
  41. #endif