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

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

Improved shifts

File size: 3.3 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;}
[4843]41    void genPrintRegister(std::string regName, Value * bitblockValue);
[4837]42   
43   
[4821]44    Constant * allZeroes() {return mZeroInitializer;}
45    Constant * allOnes() {return mOneInitializer;}
[4651]46       
47    Value * simd_add(unsigned fw, Value * a, Value * b);
48    Value * simd_sub(unsigned fw, Value * a, Value * b);
49    Value * simd_mult(unsigned fw, Value * a, Value * b);
50    Value * simd_eq(unsigned fw, Value * a, Value * b);
51    Value * simd_gt(unsigned fw, Value * a, Value * b);
52    Value * simd_ugt(unsigned fw, Value * a, Value * b);
53    Value * simd_lt(unsigned fw, Value * a, Value * b);
54    Value * simd_ult(unsigned fw, Value * a, Value * b);
55    Value * simd_max(unsigned fw, Value * a, Value * b);
56    Value * simd_umax(unsigned fw, Value * a, Value * b);
57    Value * simd_min(unsigned fw, Value * a, Value * b);
58    Value * simd_umin(unsigned fw, Value * a, Value * b);
59   
60    Value * simd_slli(unsigned fw, Value * a, unsigned shift);
61    Value * simd_srli(unsigned fw, Value * a, unsigned shift);
62    Value * simd_srai(unsigned fw, Value * a, unsigned shift);
63   
64    Value * simd_cttz(unsigned fw, Value * a);
[4720]65    Value * simd_popcount(unsigned fw, Value * a);
[4651]66   
[4652]67    Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
68    Value * esimd_mergel(unsigned fw, Value * a, Value * b);
[4653]69   
70    Value * hsimd_packh(unsigned fw, Value * a, Value * b);
71    Value * hsimd_packl(unsigned fw, Value * a, Value * b);
72    Value * hsimd_signmask(unsigned fw, Value * a);
[4652]73
[4697]74   
75    Value * mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex);
[4655]76    Value * mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift);
[4662]77   
78    Value * bitblock_any(Value * a);
[4837]79    Value * simd_and(Value * a, Value * b);
80    Value * simd_or(Value * a, Value * b);
81    Value * simd_xor(Value * a, Value * b);
82    Value * simd_not(Value * a);
83   
[4651]84private:
85    Module * mMod;
[4665]86    IRBuilder <> * mLLVMBuilder;
[4651]87    Type * mBitBlockType;
[4827]88    unsigned mBitBlockWidth;
[4821]89    Constant * mZeroInitializer;
90    Constant * mOneInitializer;
[4843]91    Constant * mPrintRegisterFunction;
[4651]92   
93    VectorType * fwVectorType(unsigned fw);
94    Value * fwCast(unsigned fw, Value * a);
95};
96
97}
98#endif // IDISA_BUILDER_H
Note: See TracBrowser for help on using the repository browser.