t-avr 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. LIB1ASMSRC = avr/lib1funcs.S
  2. LIB1ASMFUNCS = \
  3. _mulqi3 \
  4. _mulhi3 \
  5. _mulqihi3 _umulqihi3 \
  6. _mulpsi3 \
  7. _mulsi3 \
  8. _udivmodqi4 \
  9. _divmodqi4 \
  10. _udivmodhi4 \
  11. _divmodhi4 \
  12. _divmodpsi4 _udivmodpsi4 \
  13. _udivmodsi4 \
  14. _divmodsi4 \
  15. _negsi2 \
  16. _exit \
  17. _cleanup \
  18. _tablejump2 \
  19. _copy_data \
  20. _clear_bss \
  21. _ctors \
  22. _dtors \
  23. _ffssi2 \
  24. _ffshi2 \
  25. _loop_ffsqi2 \
  26. _ctzsi2 \
  27. _ctzhi2 \
  28. _clzsi2 \
  29. _clzhi2 \
  30. _paritysi2 \
  31. _parityhi2 \
  32. _popcounthi2 \
  33. _popcountsi2 \
  34. _popcountqi2 \
  35. _bswapsi2 \
  36. _fmul _fmuls _fmulsu
  37. # The below functions either use registers that are not present
  38. # in tiny core, or use a different register conventions (don't save
  39. # callee saved regs, for example)
  40. # _mulhisi3 and variations - clobber R18, R19
  41. # All *di funcs - use regs < R16 or expect args in regs < R20
  42. # _prologue and _epilogue save registers < R16
  43. # _load ad _xload variations - expect lpm and elpm support
  44. # _movmemx - expects elpm/lpm
  45. ifneq ($(MULTIFLAGS),-mmcu=avrtiny)
  46. LIB1ASMFUNCS += \
  47. _mulsqipsi3 \
  48. _mulhisi3 \
  49. _umulhisi3 \
  50. _usmulhisi3 \
  51. _muluhisi3 \
  52. _mulshisi3 \
  53. _muldi3 _muldi3_6 \
  54. _mulsidi3 _umulsidi3 \
  55. _divdi3 _udivdi3 \
  56. _udivmod64 \
  57. _negdi2 \
  58. _prologue \
  59. _epilogue \
  60. _load_3 _load_4 \
  61. _xload_1 _xload_2 _xload_3 _xload_4 \
  62. _movmemx \
  63. _clzdi2 \
  64. _paritydi2 \
  65. _popcountdi2 \
  66. _bswapdi2 \
  67. _ashldi3 _ashrdi3 _lshrdi3 _rotldi3 \
  68. _adddi3 _adddi3_s8 _subdi3 \
  69. _cmpdi2 _cmpdi2_s8
  70. endif
  71. # Fixed point routines in avr/lib1funcs-fixed.S
  72. ifneq ($(MULTIFLAGS),-mmcu=avrtiny)
  73. LIB1ASMFUNCS += \
  74. _fractqqsf _fractuqqsf \
  75. _fracthqsf _fractuhqsf _fracthasf _fractuhasf \
  76. _fractsasf _fractusasf _fractsqsf _fractusqsf \
  77. \
  78. _fractsfqq _fractsfuqq \
  79. _fractsfhq _fractsfuhq _fractsfha _fractsfuha \
  80. _fractsfsq _fractsfusq _fractsfsa _fractsfusa \
  81. _mulqq3 \
  82. _mulhq3 _muluhq3 \
  83. _mulha3 _muluha3 _muluha3_round \
  84. _mulsa3 _mulusa3 \
  85. _usmuluha3 _ssmulha3 \
  86. _usmulusa3 _ssmulsa3 \
  87. _divqq3 _udivuqq3 _divqq_helper \
  88. _divhq3 _udivuhq3 \
  89. _divha3 _udivuha3 \
  90. _divsa3 _udivusa3 \
  91. _clr_8 \
  92. _ssneg_2 _ssneg_4 _ssneg_8 \
  93. _ssabs_1 _ssabs_2 _ssabs_4 _ssabs_8 \
  94. _ssadd_8 _sssub_8 \
  95. _usadd_8 _ussub_8 \
  96. _mask1 _ret \
  97. _roundqq3 _rounduqq3 \
  98. _round_s2 _round_u2 _round_2_const _addmask_2 \
  99. _round_s4 _round_u4 _round_4_const _addmask_4 \
  100. _round_x8 \
  101. _rounddq3 _roundudq3 \
  102. _roundda3 _rounduda3 \
  103. _roundta3 _rounduta3
  104. endif
  105. LIB2FUNCS_EXCLUDE = \
  106. _moddi3 _umoddi3 \
  107. _clz \
  108. _clrsbdi2 \
  109. ifeq ($(long_double_type_size),32)
  110. # We do not have the DFtype.
  111. HOST_LIBGCC2_CFLAGS += -DDF=SF
  112. endif
  113. # Most of the C functions in libgcc2 use almost all registers,
  114. # so use -mcall-prologues for smaller code size.
  115. HOST_LIBGCC2_CFLAGS += -Dinhibit_libc -mcall-prologues -Os
  116. # Extra 16-bit integer functions.
  117. intfuncs16 = _absvXX2 _addvXX3 _subvXX3 _mulvXX3 _negvXX2 _clrsbXX2
  118. hiintfuncs16 = $(subst XX,hi,$(intfuncs16))
  119. siintfuncs16 = $(subst XX,si,$(intfuncs16))
  120. iter-items := $(hiintfuncs16)
  121. iter-labels := $(siintfuncs16)
  122. iter-sizes := $(patsubst %,2,$(siintfuncs16)) $(patsubst %,2,$(hiintfuncs16))
  123. -include $(patsubst %,$(srcdir)/siditi-object.mk,$(iter-items))
  124. libgcc-objects += $(patsubst %,%$(objext),$(hiintfuncs16))
  125. ifeq ($(enable_shared),yes)
  126. libgcc-s-objects += $(patsubst %,%_s$(objext),$(hiintfuncs16))
  127. endif
  128. ###
  129. conv_XY=$(conv)$(mode1)$(mode2)
  130. func_X=$(func)$(mode)
  131. # Compile C functions from lib2funcs.c and add them to libgcc.a.
  132. #
  133. # Some functions which are not performance.critical are more convenient
  134. # to implement in C than in assembler. Most of them serve as implementation
  135. # for AVR-specific builtins in the case where the address of a builtin
  136. # function is taken or if there is no insn that implements the builtin.
  137. #
  138. # We don't use LIB2ADD because we want to iterate over the source for
  139. # different modes, fixed-point suffixes, etc. See iter-labels and L_LABEL.
  140. # iter-label will get one more underscore in order to avoid too short
  141. # labels like -DLk and we use -DL_k instead.
  142. # Build roundFX functions from lib2funcs.c
  143. round_suffix := hr r lr uhr ur ulr \
  144. hk k uhk uk
  145. round_funcs := $(foreach func,_round,\
  146. $(foreach mode,$(round_suffix),$(func_X)))
  147. iter-items := $(round_funcs)
  148. iter-labels := $(round_suffix)
  149. iter-flags := $(patsubst %,-DL_round,$(iter-items))
  150. -include $(patsubst %,$(srcdir)/config/avr/lib2-object.mk,$(iter-items))
  151. libgcc-objects += $(patsubst %,%$(objext),$(round_funcs))
  152. # Build clrsbXX functions from lib2funcs.c
  153. clrsb_modes := qi di
  154. clrsb_funcs := $(foreach func,_clrsb,\
  155. $(foreach mode,$(clrsb_modes),$(func_X)))
  156. iter-items := $(clrsb_funcs)
  157. iter-labels := $(clrsb_funcs)
  158. iter-flags := $(patsubst %,-DL_clrsb,$(iter-items))
  159. -include $(patsubst %,$(srcdir)/config/avr/lib2-object.mk,$(iter-items))
  160. libgcc-objects += $(patsubst %,%$(objext),$(clrsb_funcs))
  161. # Build signed countlsFX functions from lib2funcs.c
  162. countls_modes := qi hi si di
  163. countls_funcs := $(foreach func,_countls,\
  164. $(foreach mode,$(countls_modes),$(func_X)))
  165. iter-items := $(countls_funcs)
  166. iter-labels := $(countls_modes)
  167. iter-flags := $(patsubst %,-DL_countls,$(iter-items))
  168. -include $(patsubst %,$(srcdir)/config/avr/lib2-object.mk,$(iter-items))
  169. libgcc-objects += $(patsubst %,%$(objext),$(countls_funcs))
  170. # Build unsigned countlsFX functions from lib2funcs.c
  171. countlsu_modes := qi hi si di
  172. countlsu_funcs := $(foreach func,_countlsu,\
  173. $(foreach mode,$(countlsu_modes),$(func_X)))
  174. iter-items := $(countlsu_funcs)
  175. iter-labels := $(countlsu_modes)
  176. iter-flags := $(patsubst %,-DL_countlsu,$(iter-items))
  177. -include $(patsubst %,$(srcdir)/config/avr/lib2-object.mk,$(iter-items))
  178. libgcc-objects += $(patsubst %,%$(objext),$(countlsu_funcs))
  179. # Filter out supported conversions from fixed-bit.c
  180. # Also filter out TQ and UTQ.
  181. # Conversions supported by the compiler
  182. convf_modes = QI UQI QQ UQQ \
  183. HI UHI HQ UHQ HA UHA \
  184. SI USI SQ USQ SA USA \
  185. DI UDI DQ UDQ DA UDA \
  186. TI UTI TQ UTQ TA UTA
  187. LIB2FUNCS_EXCLUDE += \
  188. $(foreach conv,_fract _fractuns,\
  189. $(foreach mode1,$(convf_modes),\
  190. $(foreach mode2,$(convf_modes),$(conv_XY))))
  191. # Conversions supported by lib1funcs-fixed.S
  192. conv_to_sf_modes = QQ UQQ HQ UHQ HA UHA SQ USQ SA USA
  193. conv_from_sf_modes = QQ UQQ HQ UHQ HA UHA SA USA
  194. LIB2FUNCS_EXCLUDE += \
  195. $(foreach conv,_fract, \
  196. $(foreach mode1,$(conv_to_sf_modes), \
  197. $(foreach mode2,SF,$(conv_XY))))
  198. LIB2FUNCS_EXCLUDE += \
  199. $(foreach conv,_fract,\
  200. $(foreach mode1,SF,\
  201. $(foreach mode2,$(conv_from_sf_modes),$(conv_XY))))
  202. # Arithmetik supported by the compiler
  203. allfix_modes = QQ UQQ HQ UHQ HA UHA SQ USQ SA USA DA UDA DQ UDQ TQ UTQ TA UTA
  204. LIB2FUNCS_EXCLUDE += \
  205. $(foreach func,_add _sub,\
  206. $(foreach mode,$(allfix_modes),$(func_X)))
  207. LIB2FUNCS_EXCLUDE += \
  208. $(foreach func,_lshr _ashl _ashr _cmp,\
  209. $(foreach mode,$(allfix_modes),$(func_X)))
  210. usat_modes = UQQ UHQ UHA USQ USA UDQ UDA UTQ UTA
  211. ssat_modes = QQ HQ HA SQ SA DQ DA TQ TA
  212. LIB2FUNCS_EXCLUDE += \
  213. $(foreach func,_ssadd _sssub _ssneg _ssabs,\
  214. $(foreach mode,$(ssat_modes),$(func_X)))
  215. LIB2FUNCS_EXCLUDE += \
  216. $(foreach func,_usadd _ussub _usneg,\
  217. $(foreach mode,$(usat_modes),$(func_X)))
  218. smul_modes = QQ HQ HA SA
  219. umul_modes = UQQ UHQ UHA USA
  220. sdiv_modes = QQ HQ HA SA
  221. udiv_modes = UQQ UHQ UHA USA
  222. LIB2FUNCS_EXCLUDE += \
  223. $(foreach func,_mul,\
  224. $(foreach mode,$(smul_modes) $(umul_modes),$(func_X)))
  225. LIB2FUNCS_EXCLUDE += \
  226. $(foreach func,_div,\
  227. $(foreach mode,$(sdiv_modes) $(udiv_modes),$(func_X)))
  228. ssmul_modes = HA SA
  229. usmul_modes = UHA USA
  230. LIB2FUNCS_EXCLUDE += \
  231. $(foreach func,_usmul,\
  232. $(foreach mode,$(usmul_modes),$(func_X)))
  233. LIB2FUNCS_EXCLUDE += \
  234. $(foreach func,_ssmul,\
  235. $(foreach mode,$(ssmul_modes),$(func_X)))