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

Last change on this file since 4891 was 4891, checked in by cameron, 3 years ago

Initial check-in of s2p generation

File size: 3.6 KB
RevLine 
[4651]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>
[4821]10#include <llvm/IR/Constant.h>
[4651]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:
[4665]21
22    IDISA_Builder(Type * bitBlockType)
23    : mMod(nullptr)
24    , mLLVMBuilder(nullptr)
25    , mBitBlockType(bitBlockType)
[4827]26    , mBitBlockWidth(bitBlockType->isIntegerTy() ? cast<IntegerType>(bitBlockType)->getIntegerBitWidth() : cast<VectorType>(bitBlockType)->getBitWidth())
[4821]27    , mZeroInitializer(Constant::getNullValue(bitBlockType)) 
[4843]28    , mOneInitializer(Constant::getAllOnesValue(bitBlockType))
29    , mPrintRegisterFunction(nullptr) {
[4665]30
[4651]31    }
[4665]32
33    void initialize(Module * m, IRBuilder <> * b) {
34        mMod = m;
35        mLLVMBuilder = b;
36    }
[4821]37   
38    Type * getBitBlockType() { return mBitBlockType;}
[4837]39    Value * bitCast(Value * a) {return a->getType() == mBitBlockType ? a : mLLVMBuilder->CreateBitCast(a, mBitBlockType);}
[4827]40    int getBitBlockWidth() { return mBitBlockWidth;}
[4881]41    Module * getModule() {return mMod;}
[4843]42    void genPrintRegister(std::string regName, Value * bitblockValue);
[4837]43   
44   
[4821]45    Constant * allZeroes() {return mZeroInitializer;}
46    Constant * allOnes() {return mOneInitializer;}
[4651]47       
48    Value * simd_add(unsigned fw, Value * a, Value * b);
49    Value * simd_sub(unsigned fw, Value * a, Value * b);
50    Value * simd_mult(unsigned fw, Value * a, Value * b);
51    Value * simd_eq(unsigned fw, Value * a, Value * b);
52    Value * simd_gt(unsigned fw, Value * a, Value * b);
53    Value * simd_ugt(unsigned fw, Value * a, Value * b);
54    Value * simd_lt(unsigned fw, Value * a, Value * b);
55    Value * simd_ult(unsigned fw, Value * a, Value * b);
56    Value * simd_max(unsigned fw, Value * a, Value * b);
57    Value * simd_umax(unsigned fw, Value * a, Value * b);
58    Value * simd_min(unsigned fw, Value * a, Value * b);
59    Value * simd_umin(unsigned fw, Value * a, Value * b);
[4891]60    Value * simd_if(unsigned fw, Value * cond, Value * a, Value * b);
[4651]61   
62    Value * simd_slli(unsigned fw, Value * a, unsigned shift);
63    Value * simd_srli(unsigned fw, Value * a, unsigned shift);
64    Value * simd_srai(unsigned fw, Value * a, unsigned shift);
65   
66    Value * simd_cttz(unsigned fw, Value * a);
[4720]67    Value * simd_popcount(unsigned fw, Value * a);
[4651]68   
[4652]69    Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
70    Value * esimd_mergel(unsigned fw, Value * a, Value * b);
[4879]71    Value * esimd_bitspread(unsigned fw, Value * bitmask);
[4653]72   
73    Value * hsimd_packh(unsigned fw, Value * a, Value * b);
74    Value * hsimd_packl(unsigned fw, Value * a, Value * b);
75    Value * hsimd_signmask(unsigned fw, Value * a);
[4652]76
[4697]77   
78    Value * mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex);
[4881]79    Value * mvmd_insert(unsigned fw, Value * blk, Value * elt, unsigned fieldIndex);
[4655]80    Value * mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift);
[4662]81   
82    Value * bitblock_any(Value * a);
[4837]83    Value * simd_and(Value * a, Value * b);
84    Value * simd_or(Value * a, Value * b);
85    Value * simd_xor(Value * a, Value * b);
86    Value * simd_not(Value * a);
[4891]87    Value * fwCast(unsigned fw, Value * a);
[4837]88   
[4651]89private:
90    Module * mMod;
[4665]91    IRBuilder <> * mLLVMBuilder;
[4651]92    Type * mBitBlockType;
[4827]93    unsigned mBitBlockWidth;
[4821]94    Constant * mZeroInitializer;
95    Constant * mOneInitializer;
[4843]96    Constant * mPrintRegisterFunction;
[4651]97   
98    VectorType * fwVectorType(unsigned fw);
99};
100
101}
102#endif // IDISA_BUILDER_H
Note: See TracBrowser for help on using the repository browser.