source: icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h @ 4821

Last change on this file since 4821 was 4821, checked in by cameron, 4 years ago

Encapsulating all-zeroes and all-ones initializers within IDISA builder

File size: 2.9 KB
Line 
1#ifndef IDISA_BUILDER_H
2#define IDISA_BUILDER_H
3
4/*
5 *  Copyright (c) 2015 International Characters.
6 *  This software is licensed to the public under the Open Software License 3.0.
7 *  icgrep is a trademark of International Characters.
8 */
9#include <llvm/IR/Module.h>
10#include <llvm/IR/Constant.h>
11#include <llvm/IR/Type.h>
12#include <llvm/IR/Value.h>
13#include <llvm/IR/IRBuilder.h>
14
15using namespace llvm;
16
17namespace IDISA {
18
19class IDISA_Builder {
20public:
21
22    IDISA_Builder(Type * bitBlockType)
23    : mMod(nullptr)
24    , mLLVMBuilder(nullptr)
25    , mBitBlockType(bitBlockType)
26    , mBitBlockSize(bitBlockType->isIntegerTy() ? cast<IntegerType>(bitBlockType)->getIntegerBitWidth() : cast<VectorType>(bitBlockType)->getBitWidth())
27    , mZeroInitializer(Constant::getNullValue(bitBlockType)) 
28    , mOneInitializer(Constant::getAllOnesValue(bitBlockType)) {
29
30    }
31
32    void initialize(Module * m, IRBuilder <> * b) {
33        mMod = m;
34        mLLVMBuilder = b;
35    }
36   
37    Type * getBitBlockType() { return mBitBlockType;}
38    int getBitBlockSize() { return mBitBlockSize;}
39    Constant * allZeroes() {return mZeroInitializer;}
40    Constant * allOnes() {return mOneInitializer;}
41       
42    Value * simd_add(unsigned fw, Value * a, Value * b);
43    Value * simd_sub(unsigned fw, Value * a, Value * b);
44    Value * simd_mult(unsigned fw, Value * a, Value * b);
45    Value * simd_eq(unsigned fw, Value * a, Value * b);
46    Value * simd_gt(unsigned fw, Value * a, Value * b);
47    Value * simd_ugt(unsigned fw, Value * a, Value * b);
48    Value * simd_lt(unsigned fw, Value * a, Value * b);
49    Value * simd_ult(unsigned fw, Value * a, Value * b);
50    Value * simd_max(unsigned fw, Value * a, Value * b);
51    Value * simd_umax(unsigned fw, Value * a, Value * b);
52    Value * simd_min(unsigned fw, Value * a, Value * b);
53    Value * simd_umin(unsigned fw, Value * a, Value * b);
54   
55    Value * simd_slli(unsigned fw, Value * a, unsigned shift);
56    Value * simd_srli(unsigned fw, Value * a, unsigned shift);
57    Value * simd_srai(unsigned fw, Value * a, unsigned shift);
58   
59    Value * simd_cttz(unsigned fw, Value * a);
60    Value * simd_popcount(unsigned fw, Value * a);
61   
62    Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
63    Value * esimd_mergel(unsigned fw, Value * a, Value * b);
64   
65    Value * hsimd_packh(unsigned fw, Value * a, Value * b);
66    Value * hsimd_packl(unsigned fw, Value * a, Value * b);
67    Value * hsimd_signmask(unsigned fw, Value * a);
68
69   
70    Value * mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex);
71    Value * mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift);
72   
73    Value * bitblock_any(Value * a);
74
75
76private:
77    Module * mMod;
78    IRBuilder <> * mLLVMBuilder;
79    Type * mBitBlockType;
80    unsigned mBitBlockSize;
81    Constant * mZeroInitializer;
82    Constant * mOneInitializer;
83   
84    Value * bitBlockCast(Value * a);
85    VectorType * fwVectorType(unsigned fw);
86    Value * fwCast(unsigned fw, Value * a);
87};
88
89}
90#endif // IDISA_BUILDER_H
Note: See TracBrowser for help on using the repository browser.