home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sa104os2.zip / SATHR104.ZIP / SATHER / SYSTEM / MACROS < prev    next >
Text File  |  1995-01-16  |  10KB  |  220 lines

  1. -- Routines the compiler knows to emit special code for.
  2. --
  3. -- The first column is the routine signature to replace.  The second
  4. -- column is what to use instead, with #num indicating a particular
  5. -- argument.  The third column is what to use if arith checking is on.  If it
  6. -- contains "same" then it is interpreted identically whether checking is
  7. -- on or off.
  8. --
  9. -- New addition by Matt Kennel, UCSD.  If the third column is "nomacro"
  10. -- then the routine will NOT be macroized when bounds checking or
  11. -- arithmetic checking is on.  Of course this means that you must have
  12. -- a version of the routine with real Sather source code.  The intended
  13. -- goal is for matrix and array access "aset" and "aget" routines to
  14. -- be macroized during optimized compilation, but when bounds checking is
  15. -- on we need the compiler to generate the real code so that its bounds
  16. -- checking logic gets emitted there.
  17. --
  18. -- A leading '@' is a signal to the compiler that there may be special
  19. -- handling.
  20.  
  21. "INT::plus(INT):INT"    "#1+#2"             "c_INT_plus_INT_INT_chk(#1,#2)"
  22. "INT::minus(INT):INT"    "#1-#2"               "c_INT_minus_INT_INT_chk(#1,#2)"
  23. "INT::times(INT):INT"    "#1*#2"                 "c_INT_times_INT_INT_chk(#1,#2)"
  24.  
  25. -- div and mod are special because they cannot just use the C / and %
  26. -- operators which _may_ do the wrong things for negative arguments.
  27. "INT::div(INT):INT"    "c_INT_div_INT_INT_chk(#1,#2)"  "same"
  28. "INT::mod(INT):INT"    "c_INT_mod_INT_INT_chk(#1,#2)"  "same"
  29.  
  30. "INT::uplus(INT):INT"    "((unsigned)#1)+((unsigned)#2)"    "c_INT_uplus_INT_INT_chk(#1,#2)"
  31. "INT::uminus(INT):INT"    "((unsigned)#1)-((unsigned)#2)"    "c_INT_uminus_INT_INT_chk(#1,#2)"
  32. "INT::utimes(INT):INT"    "((unsigned)#1)*((unsigned)#2)"    "c_INT_utimes_INT_INT_chk(#1,#2)"
  33. "INT::udiv(INT):INT"    "((unsigned)#1)/((unsigned)#2)"    "c_INT_udiv_INT_INT_chk(#1,#2)"
  34. "INT::umod(INT):INT"    "((unsigned)#1)%((unsigned)#2)"    "c_INT_umod_INT_INT_chk(#1,#2)"
  35. "INT::mplus(INT):INT"    "((unsigned)#1)+((unsigned)#2)" "same"
  36. "INT::mminus(INT):INT"    "((unsigned)#1)-((unsigned)#2)" "same"
  37. "INT::mtimes(INT):INT"    "((unsigned)#1)*((unsigned)#2)" "same"
  38. "INT::mnegate:INT"    "-#1"                           "same"
  39. "INT::is_lt(INT):BOOL"    "#1<#2"                "same"
  40. "INT::is_gt(INT):BOOL"    "#1>#2"                "same"
  41. "INT::is_leq(INT):BOOL"    "#1<=#2"            "same"
  42. "INT::is_geq(INT):BOOL"    "#1>=#2"            "same"
  43. "INT::flt:FLT"        "(FLT)#1"            "same"
  44. "INT::fltd:FLTD"    "(FLTD)#1"            "same"
  45. "INT::flte:FLTE"    "(FLTE)#1"            "same"
  46. "INT::fltde:FLTDE"    "(FLTDE)#1"            "same"
  47. "INT::int:INT"        "(INT)#1"            "same"
  48. "INT::char:CHAR"    "(CHAR)#1"            "same"
  49. "INT::bnot:INT"        "~#1"                "same"
  50. "INT::band(INT):INT"    "#1"                "same"
  51. "INT::bor(INT):INT"    "#1|#2"                "same"
  52. "INT::bxor(INT):INT"    "#1^#2"                "same"
  53. "INT::lshift(INT):INT"    "#1<<#2"            "same"
  54. "INT::rshift(INT):INT"    "c_INT_rshift_INT_INT(#1,#2)"    "same"
  55. "INT::urshift(INT):INT"    "((unsigned)#1)>>((unsigned)#2)" "same"
  56. "INT::is_eq(INT):BOOL"    "#1==#2"            "same"
  57. "INT::is_neq(INT):BOOL"    "#1!=#2"            "same"
  58. "INT::aset(INT,BOOL):INT" "(#1&(~(1<<#2)))|(#3<<#2)"    "same"
  59. "INT::aget(INT):BOOL"   "(CHAR)((#1&(1<<#2))!=0)"    "same"
  60. "INT::maxint:INT"    "SINT_MAX"            "same"
  61. "INT::minint:INT"    "SINT_MIN"            "same"
  62.  
  63. "BOOL::not:BOOL"    "!(#1)"                "same"
  64. "BOOL::is_eq(BOOL):BOOL" "(#1)==(#2)"            "same"
  65. "BOOL::is_neq(BOOL):BOOL" "(#1)!=(#2)"            "same"
  66.  
  67. "SYS::destroy($OB)"    "c_SYS_destroy_OB(#1,#2)"    "same"
  68. "SYS::id($OB):INT"    "c_SYS_id_OB_INT(#1,#2)"    "same"
  69. "SYS::tp($OB):INT"    "c_SYS_tp_OB_INT(#1,#2)"    "same"
  70. "SYS::str_for_tp(INT):STR" "c_SYS_str_for_tp_INT_STR(#1,#2)" "same"
  71. "SYS::ob_eq($OB,$OB):BOOL" "@1c_SYS_ob_eq_OB_OB_BOOL(#2,#3)" "same"
  72. "SYS::ext_ob_for($OB):EXT_OB" "#2"            "same"
  73.  
  74. "FILE::stdin_macro:EXT_OB"    "stdin"            "same"
  75. "FILE::stdout_macro:EXT_OB"    "stdout"        "same"
  76. "FILE::stderr_macro:EXT_OB"    "stderr"        "same"
  77.  
  78. "CHAR::is_eq(CHAR):BOOL" "#1==#2"            "same"
  79. "CHAR::is_neq(CHAR):BOOL" "#1!=#2"            "same"
  80. "CHAR::int:INT"        "(INT)#1"            "same"
  81. "CHAR::aset(INT,BOOL):CHAR" "(CHAR)((#1&(~(1<<#2)))|(#3<<#2))" "same"
  82. "CHAR::aget(INT):BOOL"   "(CHAR)((#1&(1<<#2))!=0)"    "same"
  83.  
  84. "FLT::plus(FLT):FLT"    "#1+#2"                "same"
  85. "FLT::minus(FLT):FLT"     "#1-#2"                "same"
  86. "FLT::times(FLT):FLT"     "#1*#2"                "same"
  87. "FLT::div(FLT):FLT"    "#1/#2"                "same"
  88. "FLT::negate:FLT"    "-(#1)"                "same"
  89. "FLT::is_eq(FLT):BOOL"     "#1==#2"            "same"
  90. "FLT::is_neq(FLT):BOOL" "#1!=#2"            "same"
  91. "FLT::is_lt(FLT):BOOL"  "#1<#2"                "same"
  92. "FLT::is_leq(FLT):BOOL" "#1<=#2"            "same"
  93. "FLT::is_gt(FLT):BOOL"  "#1>#2"                "same"
  94. "FLT::is_geq(FLT):BOOL" "#1>=#2"            "same"
  95. "FLT::fltd:FLTD"        "(FLTD)#1"            "same"
  96. "FLT::fltx:FLTX"        "(FLTX)#1"            "same"
  97. "FLT::fltdx:FLTDX"      "(FLTDX)#1"            "same"
  98. "FLT::aset(INT,BOOL):FLT" "c_flt_aset(#1,#2,#3)"    "same"
  99. "FLT::aget(INT):BOOL"    "c_flt_aget(#1,#2)"        "same"
  100.  
  101. "FLTD::plus(FLTD):FLTD"     "#1+#2"            "same"
  102. "FLTD::minus(FLTD):FLTD" "#1-#2"            "same"
  103. "FLTD::times(FLTD):FLTD" "#1*#2"            "same"
  104. "FLTD::div(FLTD):FLTD"     "#1/#2"            "same"
  105. "FLTD::negate:FLTD"     "-(#1)"            "same"
  106. "FLTD::is_eq(FLTD):BOOL" "#1==#2"            "same"
  107. "FLTD::is_neq(FLTD):BOOL" "#1!=#2"            "same"
  108. "FLTD::is_lt(FLTD):BOOL"  "#1<#2"            "same"
  109. "FLTD::is_leq(FLTD):BOOL" "#1<=#2"            "same"
  110. "FLTD::is_gt(FLTD):BOOL"  "#1>#2"            "same"
  111. "FLTD::is_geq(FLTD):BOOL" "#1>=#2"            "same"
  112. "FLTD::flt:FLT"            "(FLT)#1"            "same"
  113. "FLTD::fltx:FLTX"          "(FLTX)#1"            "same"
  114. "FLTD::fltdx:FLTDX"        "(FLTDX)#1"            "same"
  115. "FLTD::pi:FLTD"           "M_PI"            "same"
  116. "FLTD::e:FLTD"           "M_E"            "same"
  117. "FLTD::sqrt_2:FLTD"       "M_SQRT2"            "same"
  118. "FLTD::log_2:FLTD"       "M_LN2"            "same"
  119. "FLTD::log2_e:FLTD"       "M_LOG2E"            "same"
  120. "FLTD::log10_e:FLTD"       "M_LOG10E"            "same"
  121. "FLTD::log_10:FLTD"       "M_LN10"            "same"
  122. "FLTD::half_pi:FLTD"       "M_PI_2"            "same"
  123. "FLTD::quarter_pi:FLTD"       "M_PI_4"            "same"
  124. "FLTD::inv_sqrt_2:FLTD"       "M_SQRT1_2"            "same"
  125. "FLTD::inv_pi:FLTD"       "M_1_PI"            "same"
  126. "FLTD::double_inv_pi:FLTD" "M_2_PI"            "same"
  127. "FLTD::double_sqrt_pi:FLTD" "M_2_SQRTPI"        "same"
  128. "FLTD::aset(INT,BOOL):FLTD" "c_fltd_aset(#1,#2,#3)"    "same"
  129. "FLTD::aget(INT):BOOL"       "c_fltd_aget(#1,#2)"        "same"
  130.  
  131. -- System or architecture specific things go here.
  132. --#ifdef ALPHA 
  133. --    "INT::asize:INT" "64" "same"
  134. --#endif
  135.  
  136.  
  137.  
  138. -- Everything from here on after was added by MBK
  139. "FILE::plus(STR)" "fwrite(#2->arr_part,#2->asize,1,#1->fp)" "same"
  140.  
  141. "STR::acopyn(FSTR,INT)"        "memcpy(#1->arr_part,#2->arr_part,#3)" "same"
  142. "FSTR::acopyn(STR,INT)"        "memcpy(#1->arr_part,#2->arr_part,#3)" "same"
  143. "STR::acopyn(STR,INT)"        "memcpy(#1->arr_part,#2->arr_part,#3)" "same"
  144. "FSTR::acopyn(FSTR,INT)"    "memcpy(#1->arr_part,#2->arr_part,#3)" "same"
  145.  
  146.  
  147. "STR::acopy(STR)"        "memcpy(#1->arr_part,#2->arr_part,(#1->asize) > (#2->asize) ? #2->asize:#1->asize)" "same"
  148. "STR::acopy(INT,STR)"        "memcpy(#1->arr_part+#2,#3->arr_part,(#1->asize)-#2 > #3->asize ? #3->asize:(#1->asize)-#2)" "same"
  149.  
  150. "FSTR::acopy(FSTR)"        "memcpy(#1->arr_part,#2->arr_part,(#1->asize) > (#2->asize) ? #2->asize:#1->asize)" "same"
  151. "FSTR::acopy(STR)"        "memcpy(#1->arr_part,#2->arr_part,(#1->asize) > (#2->asize) ? #2->asize:#1->asize)" "same"
  152. "FSTR::acopy(INT,STR)"        "memcpy(#1->arr_part+#2,#3->arr_part,(#1->asize)-#2 > #3->asize ? #3->asize:(#1->asize)-#2)" "same"
  153.  
  154. "STR::is_eq_helper(STR,INT):BOOL"    "(memcmp(#1->arr_part,#2->arr_part,#3)==0 ? TRUE : FALSE)" "same"
  155. "FSTR::is_eq_helper(FSTR,INT):BOOL"    "(memcmp(#1->arr_part,#2->arr_part,#3)==0 ? TRUE : FALSE)" "same"
  156. "FSTR::is_eq_helper(STR,INT):BOOL"    "(memcmp(#1->arr_part,#2->arr_part,#3)==0 ? TRUE : FALSE)" "same"
  157.  
  158. "STR::aset(INT,CHAR)"         "#1->arr_part[#2]=#3"    "nomacro"
  159. "FSTR::aset(INT,CHAR)"         "#1->arr_part[#2]=#3"    "nomacro"
  160. "STR::aget(INT):CHAR"        "#1->arr_part[#2]"    "nomacro"
  161. "FSTR::aget(INT):CHAR"        "#1->arr_part[#2]"    "nomacro"
  162.  
  163. -- 1-d aget of 1d structures
  164. "ARRAY{INT}::aget(INT):INT"    "#1->arr_part[#2]"    "nomacro"
  165. "ARRAY{FLT}::aget(INT):FLT"    "#1->arr_part[#2]"    "nomacro"
  166. "ARRAY{FLTD}::aget(INT):FLTD"    "#1->arr_part[#2]"    "nomacro"
  167. "VEC::aget(INT):FLT"        "#1->arr_part[#2]"    "nomacro"
  168.  
  169. "AREF{INT}::aget(INT):INT"    "#1->arr_part[#2]"    "nomacro"
  170. "AREF{FLT}::aget(INT):FLT"    "#1->arr_part[#2]"    "nomacro"
  171. "AREF{FLTD}::aget(INT):FLTD"    "#1->arr_part[#2]"    "nomacro"
  172.  
  173. -- 1d getting of 2-d structures
  174. "ARRAY2{INT}::aget(INT):INT"    "#1->arr_part[#2]"    "nomacro"
  175. "ARRAY2{FLT}::aget(INT):FLT"    "#1->arr_part[#2]"    "nomacro"
  176. "ARRAY2{FLTD}::aget(INT):FLTD"    "#1->arr_part[#2]"    "nomacro"
  177. "MAT::aget(INT):FLT"        "#1->arr_part[#2]"    "nomacro"
  178. "FORTMAT::aget(INT):FLT"    "#1->arr_part[#2]"    "nomacro"
  179.  
  180. -- 2d getting of 2d structures
  181. "MAT::aget(INT,INT):FLT"        "#1->arr_part[#2 *#1->asize2 + #3]"     "nomacro"
  182. "ARRAY2{INT}::aget(INT,INT):INT"    "#1->arr_part[#2*#1->asize2 + #3]"     "nomacro"
  183. "ARRAY2{FLT}::aget(INT,INT):FLT"    "#1->arr_part[#2*#1->asize2 + #3]"     "nomacro"
  184. "ARRAY2{FLTD}::aget(INT,INT):FLTD"    "#1->arr_part[#2*#1->asize2 + #3]"     "nomacro"
  185.  
  186. -- notice this one works the other way around, because of Fortran
  187. -- storage order
  188. "FORTMAT::aget(INT,INT):FLT"    "#1->arr_part[#3 *#1->asize1 + #2]"    "nomacro"
  189.  
  190. -- 1-d setting of 1-d structures
  191. "ARRAY{INT}::aset(INT,INT)"        "#1->arr_part[#2]=#3"    "nomacro"
  192. "ARRAY{FLT}::aset(INT,FLT)"        "#1->arr_part[#2]=#3"    "nomacro"
  193. "ARRAY{FLTD}::aset(INT,FLTD)"        "#1->arr_part[#2]=#3"    "nomacro"
  194.  
  195. "AREF{INT}::aset(INT,INT)"         "#1->arr_part[#2]=#3"    "nomacro"
  196. "AREF{FLT}::aset(INT,FLT)"         "#1->arr_part[#2]=#3"    "nomacro"
  197. "AREF{FLTD}::aset(INT,FLTD)"         "#1->arr_part[#2]=#3"    "nomacro"
  198.  
  199.  
  200. -- 1d setting of 2-d structures
  201.  
  202. "ARRAY2{INT}::aset(INT,INT)"         "#1->arr_part[#2]=#3"    "nomacro"
  203. "ARRAY2{FLT}::aset(INT,FLT)"         "#1->arr_part[#2]=#3"    "nomacro"
  204. "ARRAY2{FLTD}::aset(INT,FLTD)"         "#1->arr_part[#2]=#3"    "nomacro"
  205.  
  206. "MAT::aset(INT,FLT)"             "#1->arr_part[#2]=#3"    "nomacro"
  207. "FORTMAT::aset(INT,FLT)"         "#1->arr_part[#2]=#3"    "nomacro"
  208. "VEC::aset(INT,FLT)"             "#1->arr_part[#2]=#3"    "nomacro"
  209.  
  210. -- 2d setting of 2-d structures
  211. -- notice that the compiler had to be patched to allow macro arguments
  212. -- #4 and #5
  213. "MAT::aset(INT,INT,FLT)"        "#1->arr_part[#2*#1->asize2+#3]=#4"    "nomacro"
  214. "ARRAY2{INT}::aset(INT,INT,INT)"    "#1->arr_part[#2*#1->asize2+#3]=#4"    "nomacro"
  215. "ARRAY2{FLT}::aset(INT,INT,FLT)"    "#1->arr_part[#2*#1->asize2+#3]=#4"      "nomacro"
  216. "ARRAY2{FLTD}::aset(INT,INT,FLTD)"    "#1->arr_part[#2*#1->asize2+#3]=#4"      "nomacro"
  217.  
  218. -- again, backwards from MAT
  219. "FORTMAT::aset(INT,INT,FLT)"        "#1->arr_part[#3*#1->asize1+#2]=#4"    "nomacro"
  220.