storagesoa.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  *
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  *
00026  **************************************************************************/
00027 
00028 #ifndef STORAGESOA_H
00029 #define STORAGESOA_H
00030 
00031 #include <pipe/p_shader_tokens.h>
00032 
00033 #include <vector>
00034 #include <list>
00035 #include <map>
00036 
00037 namespace llvm {
00038    class BasicBlock;
00039    class Constant;
00040    class ConstantInt;
00041    class GlobalVariable;
00042    class LoadInst;
00043    class Value;
00044    class VectorType;
00045    class Module;
00046 }
00047 
00048 class StorageSoa
00049 {
00050 public:
00051    StorageSoa(llvm::BasicBlock *block,
00052               llvm::Value *input,
00053               llvm::Value *output,
00054               llvm::Value *consts,
00055               llvm::Value *temps);
00056 
00057 
00058    std::vector<llvm::Value*> load(enum tgsi_file_type type, int idx, int swizzle, 
00059                                   llvm::Value *indIdx =0);
00060    void store(enum tgsi_file_type type, int idx, const std::vector<llvm::Value*> &val,
00061               int mask);
00062 
00063    void addImmediate(float *vec);
00064    void declareImmediates();
00065 
00066    void addAddress(int idx);
00067 
00068    llvm::Value  * addrElement(int idx) const;
00069 
00070    llvm::ConstantInt *constantInt(int) const;
00071 private:
00072    llvm::Value *elementPointer(llvm::Value *ptr, llvm::Value *indIdx,
00073                                int channel) const;
00074    llvm::Value *element(llvm::Value *ptr, llvm::Value *idx,
00075                         int channel) const;
00076    const char *name(const char *prefix) const;
00077    llvm::Value  *alignedArrayLoad(llvm::Value *val);
00078    llvm::Module *currentModule() const;
00079    llvm::Constant  *createConstGlobalVector(const std::vector<float> &vec);
00080 
00081    std::vector<llvm::Value*> inputElement(llvm::Value *indIdx);
00082    std::vector<llvm::Value*> constElement(llvm::Value *indIdx);
00083    std::vector<llvm::Value*> outputElement(llvm::Value *indIdx);
00084    std::vector<llvm::Value*> tempElement(llvm::Value *indIdx);
00085    std::vector<llvm::Value*> immediateElement(llvm::Value *indIdx);
00086 private:
00087    llvm::BasicBlock *m_block;
00088 
00089    llvm::Value *m_input;
00090    llvm::Value *m_output;
00091    llvm::Value *m_consts;
00092    llvm::Value *m_temps;
00093    llvm::GlobalVariable *m_immediates;
00094 
00095    std::map<int, llvm::Value*> m_addresses;
00096 
00097    std::vector<std::vector<float> > m_immediatesToFlush;
00098 
00099    mutable std::map<int, llvm::ConstantInt*> m_constInts;
00100    mutable char        m_name[32];
00101    mutable int         m_idx;
00102 };
00103 
00104 #endif

Generated on Tue Sep 29 06:25:14 2009 for Gallium3D by  doxygen 1.5.4