Code reorganization: placeholder for state-trackers.
[mesa.git] / src / gallium / aux / llvm / gallivm_p.h
1 #ifndef GALLIVM_P_H
2 #define GALLIVM_P_H
3
4 #ifdef MESA_LLVM
5
6 #include "gallivm.h"
7 #include "pipe/p_shader_tokens.h"
8 #include "pipe/p_compiler.h"
9
10 namespace llvm {
11 class Module;
12 }
13
14 #if defined __cplusplus
15 extern "C" {
16 #endif
17
18 enum gallivm_shader_type;
19 enum gallivm_vector_layout;
20
21 struct gallivm_interpolate {
22 int attrib;
23 int chan;
24 int type;
25 };
26
27 struct gallivm_ir {
28 llvm::Module *module;
29 int id;
30 enum gallivm_shader_type type;
31 enum gallivm_vector_layout layout;
32 int num_components;
33 int num_consts;
34
35 //FIXME: this might not be enough for some shaders
36 struct gallivm_interpolate interpolators[32*4];
37 int num_interp;
38 };
39
40 struct gallivm_prog {
41 llvm::Module *module;
42 void *function;
43
44 int id;
45 enum gallivm_shader_type type;
46
47 int num_consts;
48
49 //FIXME: this might not be enough for some shaders
50 struct gallivm_interpolate interpolators[32*4];
51 int num_interp;
52 };
53
54 static INLINE void gallivm_swizzle_components(int swizzle,
55 int *xc, int *yc,
56 int *zc, int *wc)
57 {
58 int x = swizzle / 1000; swizzle -= x * 1000;
59 int y = swizzle / 100; swizzle -= y * 100;
60 int z = swizzle / 10; swizzle -= z * 10;
61 int w = swizzle;
62
63 if (xc) *xc = x;
64 if (yc) *yc = y;
65 if (zc) *zc = z;
66 if (wc) *wc = w;
67 }
68
69 static INLINE boolean gallivm_is_swizzle(int swizzle)
70 {
71 const int NO_SWIZZLE = TGSI_SWIZZLE_X * 1000 + TGSI_SWIZZLE_Y * 100 +
72 TGSI_SWIZZLE_Z * 10 + TGSI_SWIZZLE_W;
73 return swizzle != NO_SWIZZLE;
74 }
75
76 static INLINE int gallivm_x_swizzle(int swizzle)
77 {
78 int x;
79 gallivm_swizzle_components(swizzle, &x, 0, 0, 0);
80 return x;
81 }
82
83 static INLINE int gallivm_y_swizzle(int swizzle)
84 {
85 int y;
86 gallivm_swizzle_components(swizzle, 0, &y, 0, 0);
87 return y;
88 }
89
90 static INLINE int gallivm_z_swizzle(int swizzle)
91 {
92 int z;
93 gallivm_swizzle_components(swizzle, 0, 0, &z, 0);
94 return z;
95 }
96
97 static INLINE int gallivm_w_swizzle(int swizzle)
98 {
99 int w;
100 gallivm_swizzle_components(swizzle, 0, 0, 0, &w);
101 return w;
102 }
103
104 #endif /* MESA_LLVM */
105
106 #if defined __cplusplus
107 } // extern "C"
108 #endif
109
110 #endif