gallium: call tgsi_set_exec_mask() and use exec mask in SSE ARL code
[mesa.git] / src / gallium / auxiliary / gallivm / storagesoa.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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 #ifndef STORAGESOA_H
29 #define STORAGESOA_H
30
31 #include <pipe/p_shader_tokens.h>
32
33 #include <vector>
34 #include <list>
35 #include <map>
36
37 namespace llvm {
38 class BasicBlock;
39 class Constant;
40 class ConstantInt;
41 class GlobalVariable;
42 class LoadInst;
43 class Value;
44 class VectorType;
45 class Module;
46 }
47
48 class StorageSoa
49 {
50 public:
51 StorageSoa(llvm::BasicBlock *block,
52 llvm::Value *input,
53 llvm::Value *output,
54 llvm::Value *consts,
55 llvm::Value *temps);
56
57
58 std::vector<llvm::Value*> load(enum tgsi_file_type type, int idx, int swizzle,
59 llvm::Value *indIdx =0);
60 void store(enum tgsi_file_type type, int idx, const std::vector<llvm::Value*> &val,
61 int mask);
62
63 void addImmediate(float *vec);
64 void declareImmediates();
65
66 void addAddress(int idx);
67
68 llvm::Value * addrElement(int idx) const;
69
70 llvm::ConstantInt *constantInt(int) const;
71 private:
72 llvm::Value *elementPointer(llvm::Value *ptr, llvm::Value *indIdx,
73 int channel) const;
74 llvm::Value *element(llvm::Value *ptr, llvm::Value *idx,
75 int channel) const;
76 const char *name(const char *prefix) const;
77 llvm::Value *alignedArrayLoad(llvm::Value *val);
78 llvm::Module *currentModule() const;
79 llvm::Constant *createConstGlobalVector(const std::vector<float> &vec);
80
81 std::vector<llvm::Value*> inputElement(llvm::Value *indIdx);
82 std::vector<llvm::Value*> constElement(llvm::Value *indIdx);
83 std::vector<llvm::Value*> outputElement(llvm::Value *indIdx);
84 std::vector<llvm::Value*> tempElement(llvm::Value *indIdx);
85 std::vector<llvm::Value*> immediateElement(llvm::Value *indIdx);
86 private:
87 llvm::BasicBlock *m_block;
88
89 llvm::Value *m_input;
90 llvm::Value *m_output;
91 llvm::Value *m_consts;
92 llvm::Value *m_temps;
93 llvm::GlobalVariable *m_immediates;
94
95 std::map<int, llvm::Value*> m_addresses;
96
97 std::vector<std::vector<float> > m_immediatesToFlush;
98
99 mutable std::map<int, llvm::ConstantInt*> m_constInts;
100 mutable char m_name[32];
101 mutable int m_idx;
102 };
103
104 #endif