summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/llvm/instructions.h
blob: c6e77710ea0ed8f20f159053ac48f42a2b4d4271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef INSTRUCTIONS_H
#define INSTRUCTIONS_H

#include <llvm/BasicBlock.h>
#include <llvm/Module.h>
#include <llvm/Value.h>

namespace llvm {
   class VectorType;
}

class Instructions
{
public:
   Instructions(llvm::Module *mod, llvm::BasicBlock *block);

   llvm::Value *add(llvm::Value *in1, llvm::Value *in2);
   llvm::Value *dp3(llvm::Value *in1, llvm::Value *in2);
   llvm::Value *lit(llvm::Value *in1);
   llvm::Value *madd(llvm::Value *in1, llvm::Value *in2,
                     llvm::Value *in2);
   llvm::Value *mul(llvm::Value *in1, llvm::Value *in2);
   llvm::Value *rsq(llvm::Value *in1);
private:
   const char *name(const char *prefix);

   llvm::Value *callFSqrt(llvm::Value *val);
   llvm::Value *callFAbs(llvm::Value *val);

   llvm::Value *vectorFromVals(llvm::Value *x, llvm::Value *y,
                               llvm::Value *z, llvm::Value *w=0);
private:
   llvm::Module *m_mod;
   char        m_name[32];
   llvm::BasicBlock *m_block;
   int               m_idx;
   llvm::Function   *m_llvmFSqrt;
   llvm::Function   *m_llvmFAbs;

   llvm::VectorType *m_floatVecType;
};

#endif