sim_ac_option_bitsize.m4 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. dnl Copyright (C) 1997-2022 Free Software Foundation, Inc.
  2. dnl
  3. dnl This program is free software; you can redistribute it and/or modify
  4. dnl it under the terms of the GNU General Public License as published by
  5. dnl the Free Software Foundation; either version 3 of the License, or
  6. dnl (at your option) any later version.
  7. dnl
  8. dnl This program is distributed in the hope that it will be useful,
  9. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. dnl GNU General Public License for more details.
  12. dnl
  13. dnl You should have received a copy of the GNU General Public License
  14. dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. dnl
  16. dnl --enable-sim-bitsize is for developers of the simulator
  17. dnl It specifies the number of BITS in the target.
  18. dnl arg[1] is the number of bits in a word
  19. dnl arg[2] is the number assigned to the most significant bit
  20. dnl arg[3] is the number of bits in an address
  21. dnl arg[4] is the number of bits in an OpenFirmware cell.
  22. dnl FIXME: this information should be obtained from bfd/archure
  23. AC_DEFUN([SIM_AC_OPTION_BITSIZE],
  24. wire_word_bitsize="[$1]"
  25. wire_word_msb="[$2]"
  26. wire_address_bitsize="[$3]"
  27. wire_cell_bitsize="[$4]"
  28. [AC_ARG_ENABLE(sim-bitsize,
  29. [AS_HELP_STRING([--enable-sim-bitsize=N], [Specify target bitsize (32 or 64)])],
  30. [sim_bitsize=
  31. case "${enableval}" in
  32. 64,63 | 64,63,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63";;
  33. 32,31 | 32,31,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31";;
  34. 64,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
  35. 32,0 | 64,0,* ) sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0";;
  36. 32) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
  37. sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31"
  38. else
  39. sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=0"
  40. fi ;;
  41. 64) if test x"$wire_word_msb" != x -a x"$wire_word_msb" != x0; then
  42. sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63"
  43. else
  44. sim_bitsize="-DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=0"
  45. fi ;;
  46. *) AC_MSG_ERROR("--enable-sim-bitsize was given $enableval. Expected 32 or 64") ;;
  47. esac
  48. # address bitsize
  49. tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9]]*,*//"`
  50. case x"${tmp}" in
  51. x ) ;;
  52. x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=32" ;;
  53. x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_ADDRESS_BITSIZE=64" ;;
  54. * ) AC_MSG_ERROR("--enable-sim-bitsize was given address size $enableval. Expected 32 or 64") ;;
  55. esac
  56. # cell bitsize
  57. tmp=`echo "${enableval}" | sed -e "s/^[[0-9]]*,*[[0-9*]]*,*[[0-9]]*,*//"`
  58. case x"${tmp}" in
  59. x ) ;;
  60. x32 | x32,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=32" ;;
  61. x64 | x64,* ) sim_bitsize="${sim_bitsize} -DWITH_TARGET_CELL_BITSIZE=64" ;;
  62. * ) AC_MSG_ERROR("--enable-sim-bitsize was given cell size $enableval. Expected 32 or 64") ;;
  63. esac
  64. if test x"$silent" != x"yes" && test x"$sim_bitsize" != x""; then
  65. echo "Setting bitsize flags = $sim_bitsize" 6>&1
  66. fi],
  67. [sim_bitsize=""
  68. if test x"$wire_word_bitsize" != x; then
  69. sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_BITSIZE=$wire_word_bitsize"
  70. fi
  71. if test x"$wire_word_msb" != x; then
  72. sim_bitsize="$sim_bitsize -DWITH_TARGET_WORD_MSB=$wire_word_msb"
  73. fi
  74. if test x"$wire_address_bitsize" != x; then
  75. sim_bitsize="$sim_bitsize -DWITH_TARGET_ADDRESS_BITSIZE=$wire_address_bitsize"
  76. fi
  77. if test x"$wire_cell_bitsize" != x; then
  78. sim_bitsize="$sim_bitsize -DWITH_TARGET_CELL_BITSIZE=$wire_cell_bitsize"
  79. fi])dnl
  80. ])
  81. AC_SUBST(sim_bitsize)