From b0f80693434cb203f63d8fbab56c1522000ed88f Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 17 Oct 2007 11:28:26 -0400 Subject: [PATCH] Refactor the tgsi->llvm storage translator --- src/mesa/pipe/llvm/llvmtgsi.cpp | 5 +- .../llvm/{tgsillvmbuilder.cpp => storage.cpp} | 50 ++++------------ src/mesa/pipe/llvm/storage.h | 57 +++++++++++++++++++ src/mesa/sources | 1 + 4 files changed, 71 insertions(+), 42 deletions(-) rename src/mesa/pipe/llvm/{tgsillvmbuilder.cpp => storage.cpp} (77%) create mode 100644 src/mesa/pipe/llvm/storage.h diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index 5cbd0ae89ff..c6cf2de4fc2 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -1,5 +1,8 @@ #include "llvmtgsi.h" +#include "instructions.h" +#include "storage.h" + #include "pipe/p_context.h" #include "pipe/tgsi/exec/tgsi_exec.h" #include "pipe/tgsi/exec/tgsi_token.h" @@ -30,10 +33,8 @@ #include #include -#include "instructions.h" using namespace llvm; #include "llvm_base_shader.cpp" -#include "tgsillvmbuilder.cpp" static inline void addPass(PassManager &PM, Pass *P) { diff --git a/src/mesa/pipe/llvm/tgsillvmbuilder.cpp b/src/mesa/pipe/llvm/storage.cpp similarity index 77% rename from src/mesa/pipe/llvm/tgsillvmbuilder.cpp rename to src/mesa/pipe/llvm/storage.cpp index ca70a46648c..c6e86ea4b43 100644 --- a/src/mesa/pipe/llvm/tgsillvmbuilder.cpp +++ b/src/mesa/pipe/llvm/storage.cpp @@ -1,46 +1,16 @@ +#include "storage.h" -#include +#include +#include +#include -class Storage -{ - typedef std::map LoadMap; -public: - Storage(llvm::BasicBlock *block, - llvm::Value *out, - llvm::Value *in, llvm::Value *consts); - - llvm::ConstantInt *constantInt(int); - llvm::Constant *shuffleMask(int vec); - llvm::Value *inputElement(int idx); - llvm::Value *constElement(int idx); - - llvm::Value *tempElement(int idx) const; - void setTempElement(int idx, llvm::Value *val); - - llvm::Value *shuffleVector(llvm::Value *vec, int shuffle); - - - void store(int dstIdx, llvm::Value *val); -private: - llvm::BasicBlock *m_block; - llvm::Value *m_OUT; - llvm::Value *m_IN; - llvm::Value *m_CONST; - - std::map m_constInts; - std::map m_intVecs; - std::vector m_temps; - LoadMap m_inputs; - LoadMap m_consts; - - llvm::VectorType *m_floatVecType; - llvm::VectorType *m_intVecType; - - llvm::Value *m_undefFloatVec; - llvm::Value *m_undefIntVec; +#include +#include +#include +#include +#include - int m_shuffleId; -}; +using namespace llvm; Storage::Storage(llvm::BasicBlock *block, llvm::Value *out, llvm::Value *in, llvm::Value *consts) diff --git a/src/mesa/pipe/llvm/storage.h b/src/mesa/pipe/llvm/storage.h new file mode 100644 index 00000000000..b69c8d614e9 --- /dev/null +++ b/src/mesa/pipe/llvm/storage.h @@ -0,0 +1,57 @@ +#ifndef STORAGE_H +#define STORAGE_H + +#include +#include + +namespace llvm { + class BasicBlock; + class Constant; + class ConstantInt; + class LoadInst; + class Value; + class VectorType; +} + +class Storage +{ + typedef std::map LoadMap; +public: + Storage(llvm::BasicBlock *block, + llvm::Value *out, + llvm::Value *in, llvm::Value *consts); + + llvm::ConstantInt *constantInt(int); + llvm::Constant *shuffleMask(int vec); + llvm::Value *inputElement(int idx); + llvm::Value *constElement(int idx); + + llvm::Value *tempElement(int idx) const; + void setTempElement(int idx, llvm::Value *val); + + llvm::Value *shuffleVector(llvm::Value *vec, int shuffle); + + + void store(int dstIdx, llvm::Value *val); +private: + llvm::BasicBlock *m_block; + llvm::Value *m_OUT; + llvm::Value *m_IN; + llvm::Value *m_CONST; + + std::map m_constInts; + std::map m_intVecs; + std::vector m_temps; + LoadMap m_inputs; + LoadMap m_consts; + + llvm::VectorType *m_floatVecType; + llvm::VectorType *m_intVecType; + + llvm::Value *m_undefFloatVec; + llvm::Value *m_undefIntVec; + + int m_shuffleId; +}; + +#endif diff --git a/src/mesa/sources b/src/mesa/sources index 7e1d909e286..1bc45c98132 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -192,6 +192,7 @@ TGSIMESA_SOURCES = \ ifeq ($(MESA_NO_LLVM),0) LLVMTGSI_SOURCES = \ pipe/llvm/llvmtgsi.cpp \ + pipe/llvm/storage.cpp \ pipe/llvm/instructions.cpp endif -- 2.30.2