Refactor the tgsi->llvm storage translator

This commit is contained in:
Zack Rusin 2007-10-17 11:28:26 -04:00
parent 3975f34fd3
commit b0f8069343
4 changed files with 71 additions and 42 deletions

View file

@ -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 <llvm/Bitcode/ReaderWriter.h>
#include <iostream>
#include "instructions.h"
using namespace llvm;
#include "llvm_base_shader.cpp"
#include "tgsillvmbuilder.cpp"
static inline void addPass(PassManager &PM, Pass *P) {

View file

@ -1,46 +1,16 @@
#include "storage.h"
#include <map>
#include <llvm/BasicBlock.h>
#include <llvm/Module.h>
#include <llvm/Value.h>
class Storage
{
typedef std::map<int, llvm::LoadInst*> LoadMap;
public:
Storage(llvm::BasicBlock *block,
llvm::Value *out,
llvm::Value *in, llvm::Value *consts);
#include <llvm/CallingConv.h>
#include <llvm/Constants.h>
#include <llvm/DerivedTypes.h>
#include <llvm/InstrTypes.h>
#include <llvm/Instructions.h>
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<int, llvm::ConstantInt*> m_constInts;
std::map<int, llvm::Constant*> m_intVecs;
std::vector<llvm::Value*> 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;
};
using namespace llvm;
Storage::Storage(llvm::BasicBlock *block, llvm::Value *out,
llvm::Value *in, llvm::Value *consts)

View file

@ -0,0 +1,57 @@
#ifndef STORAGE_H
#define STORAGE_H
#include <map>
#include <vector>
namespace llvm {
class BasicBlock;
class Constant;
class ConstantInt;
class LoadInst;
class Value;
class VectorType;
}
class Storage
{
typedef std::map<int, llvm::LoadInst*> 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<int, llvm::ConstantInt*> m_constInts;
std::map<int, llvm::Constant*> m_intVecs;
std::vector<llvm::Value*> 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

View file

@ -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