Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lp_bld_arit.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**************************************************************************
  2. *
  3. * Copyright 2009 VMware, Inc.
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21. * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  22. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. /**
  28. * @file
  29. * Helper arithmetic functions.
  30. *
  31. * @author Jose Fonseca <jfonseca@vmware.com>
  32. */
  33. #ifndef LP_BLD_ARIT_H
  34. #define LP_BLD_ARIT_H
  35. #include <llvm-c/Core.h>
  36. struct lp_type;
  37. struct lp_build_context;
  38. /**
  39. * Complement, i.e., 1 - a.
  40. */
  41. LLVMValueRef
  42. lp_build_comp(struct lp_build_context *bld,
  43. LLVMValueRef a);
  44. LLVMValueRef
  45. lp_build_add(struct lp_build_context *bld,
  46. LLVMValueRef a,
  47. LLVMValueRef b);
  48. LLVMValueRef
  49. lp_build_sub(struct lp_build_context *bld,
  50. LLVMValueRef a,
  51. LLVMValueRef b);
  52. LLVMValueRef
  53. lp_build_mul(struct lp_build_context *bld,
  54. LLVMValueRef a,
  55. LLVMValueRef b);
  56. LLVMValueRef
  57. lp_build_mul_imm(struct lp_build_context *bld,
  58. LLVMValueRef a,
  59. int b);
  60. LLVMValueRef
  61. lp_build_div(struct lp_build_context *bld,
  62. LLVMValueRef a,
  63. LLVMValueRef b);
  64. LLVMValueRef
  65. lp_build_lerp(struct lp_build_context *bld,
  66. LLVMValueRef x,
  67. LLVMValueRef v0,
  68. LLVMValueRef v1);
  69. /**
  70. * Bilinear interpolation.
  71. *
  72. * Values indices are in v_{yx}.
  73. */
  74. LLVMValueRef
  75. lp_build_lerp_2d(struct lp_build_context *bld,
  76. LLVMValueRef x,
  77. LLVMValueRef y,
  78. LLVMValueRef v00,
  79. LLVMValueRef v01,
  80. LLVMValueRef v10,
  81. LLVMValueRef v11);
  82. LLVMValueRef
  83. lp_build_min(struct lp_build_context *bld,
  84. LLVMValueRef a,
  85. LLVMValueRef b);
  86. LLVMValueRef
  87. lp_build_max(struct lp_build_context *bld,
  88. LLVMValueRef a,
  89. LLVMValueRef b);
  90. LLVMValueRef
  91. lp_build_abs(struct lp_build_context *bld,
  92. LLVMValueRef a);
  93. LLVMValueRef
  94. lp_build_sgn(struct lp_build_context *bld,
  95. LLVMValueRef a);
  96. LLVMValueRef
  97. lp_build_round(struct lp_build_context *bld,
  98. LLVMValueRef a);
  99. LLVMValueRef
  100. lp_build_floor(struct lp_build_context *bld,
  101. LLVMValueRef a);
  102. LLVMValueRef
  103. lp_build_ceil(struct lp_build_context *bld,
  104. LLVMValueRef a);
  105. LLVMValueRef
  106. lp_build_trunc(struct lp_build_context *bld,
  107. LLVMValueRef a);
  108. LLVMValueRef
  109. lp_build_ifloor(struct lp_build_context *bld,
  110. LLVMValueRef a);
  111. LLVMValueRef
  112. lp_build_iceil(struct lp_build_context *bld,
  113. LLVMValueRef a);
  114. LLVMValueRef
  115. lp_build_iround(struct lp_build_context *bld,
  116. LLVMValueRef a);
  117. LLVMValueRef
  118. lp_build_itrunc(struct lp_build_context *bld,
  119. LLVMValueRef a);
  120. LLVMValueRef
  121. lp_build_sqrt(struct lp_build_context *bld,
  122. LLVMValueRef a);
  123. LLVMValueRef
  124. lp_build_rcp(struct lp_build_context *bld,
  125. LLVMValueRef a);
  126. LLVMValueRef
  127. lp_build_rsqrt(struct lp_build_context *bld,
  128. LLVMValueRef a);
  129. LLVMValueRef
  130. lp_build_cos(struct lp_build_context *bld,
  131. LLVMValueRef a);
  132. LLVMValueRef
  133. lp_build_sin(struct lp_build_context *bld,
  134. LLVMValueRef a);
  135. LLVMValueRef
  136. lp_build_pow(struct lp_build_context *bld,
  137. LLVMValueRef a,
  138. LLVMValueRef b);
  139. LLVMValueRef
  140. lp_build_exp(struct lp_build_context *bld,
  141. LLVMValueRef a);
  142. LLVMValueRef
  143. lp_build_log(struct lp_build_context *bld,
  144. LLVMValueRef a);
  145. LLVMValueRef
  146. lp_build_exp2(struct lp_build_context *bld,
  147. LLVMValueRef a);
  148. LLVMValueRef
  149. lp_build_log2(struct lp_build_context *bld,
  150. LLVMValueRef a);
  151. void
  152. lp_build_exp2_approx(struct lp_build_context *bld,
  153. LLVMValueRef x,
  154. LLVMValueRef *p_exp2_int_part,
  155. LLVMValueRef *p_frac_part,
  156. LLVMValueRef *p_exp2);
  157. void
  158. lp_build_log2_approx(struct lp_build_context *bld,
  159. LLVMValueRef x,
  160. LLVMValueRef *p_exp,
  161. LLVMValueRef *p_floor_log2,
  162. LLVMValueRef *p_log2);
  163. #endif /* !LP_BLD_ARIT_H */