1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
31 #include <pipe/p_shader_tokens.h>
32 #include <llvm/Support/IRBuilder.h>
52 StorageSoa(llvm::BasicBlock
*block
,
58 std::vector
<llvm::Value
*> load(enum tgsi_file_type type
, int idx
, int swizzle
,
59 llvm::IRBuilder
<>* m_builder
, llvm::Value
*indIdx
=0);
60 void store(enum tgsi_file_type type
, int idx
, const std::vector
<llvm::Value
*> &val
,
61 int mask
, llvm::IRBuilder
<>* m_builder
);
63 void addImmediate(float *vec
);
64 void declareImmediates();
66 void addAddress(int idx
);
68 llvm::Value
* addrElement(int idx
) const;
70 llvm::ConstantInt
*constantInt(int) const;
72 llvm::Value
*elementPointer(llvm::Value
*ptr
, llvm::Value
*indIdx
,
74 llvm::Value
*element(llvm::Value
*ptr
, llvm::Value
*idx
,
76 const char *name(const char *prefix
) const;
77 llvm::Value
*alignedArrayLoad(llvm::Value
*val
);
78 llvm::Module
*currentModule() const;
79 llvm::Constant
*createConstGlobalFloat(const float val
);
80 llvm::Constant
*createConstGlobalVector(const std::vector
<float> &vec
);
82 std::vector
<llvm::Value
*> inputElement(llvm::Value
*indIdx
);
83 llvm::Value
* unpackConstElement(llvm::IRBuilder
<>* m_builder
, llvm::Value
*indIdx
, int cc
);
84 std::vector
<llvm::Value
*> constElement(llvm::IRBuilder
<>* m_builder
, llvm::Value
*indIdx
);
85 std::vector
<llvm::Value
*> outputElement(llvm::Value
*indIdx
);
86 std::vector
<llvm::Value
*> tempElement(llvm::IRBuilder
<>* m_builder
, int idx
);
87 std::vector
<llvm::Value
*> immediateElement(llvm::Value
*indIdx
);
89 llvm::BasicBlock
*m_block
;
92 llvm::Value
*m_output
;
93 llvm::Value
*m_consts
;
94 std::map
<int, llvm::Value
*> m_temps
;
95 llvm::GlobalVariable
*m_immediates
;
97 std::map
<int, llvm::Value
*> m_addresses
;
99 std::vector
<std::vector
<float> > m_immediatesToFlush
;
100 llvm::Value
* allocaTemp(llvm::IRBuilder
<>* m_builder
);
102 mutable std::map
<int, llvm::ConstantInt
*> m_constInts
;
103 mutable char m_name
[32];