xref: /aosp_15_r20/external/mesa3d/src/intel/compiler/elk/elk_eu_util.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
3  Intel funded Tungsten Graphics to
4  develop this 3D driver.
5 
6  Permission is hereby granted, free of charge, to any person obtaining
7  a 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, sublicense, 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
16  portions of the Software.
17 
18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 
26  **********************************************************************/
27  /*
28   * Authors:
29   *   Keith Whitwell <[email protected]>
30   */
31 
32 
33 #include "elk_eu_defines.h"
34 #include "elk_eu.h"
35 
36 
elk_math_invert(struct elk_codegen * p,struct elk_reg dst,struct elk_reg src)37 void elk_math_invert( struct elk_codegen *p,
38 			     struct elk_reg dst,
39 			     struct elk_reg src)
40 {
41    elk_gfx4_math(p,
42 	     dst,
43 	     ELK_MATH_FUNCTION_INV,
44 	     0,
45 	     src,
46 	     ELK_MATH_PRECISION_FULL);
47 }
48 
49 
50 
elk_copy4(struct elk_codegen * p,struct elk_reg dst,struct elk_reg src,unsigned count)51 void elk_copy4(struct elk_codegen *p,
52 	       struct elk_reg dst,
53 	       struct elk_reg src,
54 	       unsigned count)
55 {
56    unsigned i;
57 
58    dst = vec4(dst);
59    src = vec4(src);
60 
61    for (i = 0; i < count; i++)
62    {
63       unsigned delta = i*32;
64       elk_MOV(p, byte_offset(dst, delta),    byte_offset(src, delta));
65       elk_MOV(p, byte_offset(dst, delta+16), byte_offset(src, delta+16));
66    }
67 }
68 
69 
elk_copy8(struct elk_codegen * p,struct elk_reg dst,struct elk_reg src,unsigned count)70 void elk_copy8(struct elk_codegen *p,
71 	       struct elk_reg dst,
72 	       struct elk_reg src,
73 	       unsigned count)
74 {
75    unsigned i;
76 
77    dst = vec8(dst);
78    src = vec8(src);
79 
80    for (i = 0; i < count; i++)
81    {
82       unsigned delta = i*32;
83       elk_MOV(p, byte_offset(dst, delta),    byte_offset(src, delta));
84    }
85 }
86 
87 
elk_copy_indirect_to_indirect(struct elk_codegen * p,struct elk_indirect dst_ptr,struct elk_indirect src_ptr,unsigned count)88 void elk_copy_indirect_to_indirect(struct elk_codegen *p,
89 				   struct elk_indirect dst_ptr,
90 				   struct elk_indirect src_ptr,
91 				   unsigned count)
92 {
93    unsigned i;
94 
95    for (i = 0; i < count; i++)
96    {
97       unsigned delta = i*32;
98       elk_MOV(p, deref_4f(dst_ptr, delta),    deref_4f(src_ptr, delta));
99       elk_MOV(p, deref_4f(dst_ptr, delta+16), deref_4f(src_ptr, delta+16));
100    }
101 }
102 
103 
elk_copy_from_indirect(struct elk_codegen * p,struct elk_reg dst,struct elk_indirect ptr,unsigned count)104 void elk_copy_from_indirect(struct elk_codegen *p,
105 			    struct elk_reg dst,
106 			    struct elk_indirect ptr,
107 			    unsigned count)
108 {
109    unsigned i;
110 
111    dst = vec4(dst);
112 
113    for (i = 0; i < count; i++)
114    {
115       unsigned delta = i*32;
116       elk_MOV(p, byte_offset(dst, delta),    deref_4f(ptr, delta));
117       elk_MOV(p, byte_offset(dst, delta+16), deref_4f(ptr, delta+16));
118    }
119 }
120