asm.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390_ASM_H
  3. #define _ASM_S390_ASM_H
  4. #include <linux/stringify.h>
  5. /*
  6. * Helper macros to be used for flag output operand handling.
  7. * Inline assemblies must use four of the five supplied macros:
  8. *
  9. * Use CC_IPM(sym) at the end of the inline assembly; this extracts the
  10. * condition code and program mask with the ipm instruction and writes it to
  11. * the variable with symbolic name [sym] if the compiler has no support for
  12. * flag output operands. If the compiler has support for flag output operands
  13. * this generates no code.
  14. *
  15. * Use CC_OUT(sym, var) at the output operand list of an inline assembly. This
  16. * defines an output operand with symbolic name [sym] for the variable
  17. * [var]. [var] must be an int variable and [sym] must be identical with [sym]
  18. * used with CC_IPM().
  19. *
  20. * Use either CC_CLOBBER or CC_CLOBBER_LIST() for the clobber list. Use
  21. * CC_CLOBBER if the clobber list contains only "cc", otherwise use
  22. * CC_CLOBBER_LIST() and add all clobbers as argument to the macro.
  23. *
  24. * Use CC_TRANSFORM() to convert the variable [var] which contains the
  25. * extracted condition code. If the condition code is extracted with ipm, the
  26. * [var] also contains the program mask. CC_TRANSFORM() moves the condition
  27. * code to the two least significant bits and sets all other bits to zero.
  28. */
  29. #if defined(__GCC_ASM_FLAG_OUTPUTS__) && !(IS_ENABLED(CONFIG_CC_ASM_FLAG_OUTPUT_BROKEN))
  30. #define __HAVE_ASM_FLAG_OUTPUTS__ 1
  31. #define CC_IPM(sym)
  32. #define CC_OUT(sym, var) "=@cc" (var)
  33. #define CC_TRANSFORM(cc) ({ cc; })
  34. #define CC_CLOBBER
  35. #define CC_CLOBBER_LIST(...) __VA_ARGS__
  36. #else
  37. #define CC_IPM(sym) " ipm %[" __stringify(sym) "]\n"
  38. #define CC_OUT(sym, var) [sym] "=d" (var)
  39. #define CC_TRANSFORM(cc) ({ (cc) >> 28; })
  40. #define CC_CLOBBER "cc"
  41. #define CC_CLOBBER_LIST(...) "cc", __VA_ARGS__
  42. #endif
  43. #endif /* _ASM_S390_ASM_H */