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

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

Initial library for implementing IDISA operations in LLVM IR

File size: 1.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/Type.h>
11#include <llvm/IR/Value.h>
12#include <llvm/IR/IRBuilder.h>
13
14using namespace llvm;
15
16namespace IDISA {
17
18class IDISA_Builder {
19public:
20    IDISA_Builder(Module * m, IRBuilder <> * b, Type * bitBlockType): mMod(m), llvm_builder(b), mBitBlockType(bitBlockType) {
21        if (bitBlockType->isIntegerTy()) mBitBlockSize = dyn_cast<IntegerType>(bitBlockType)-> getIntegerBitWidth();
22        else mBitBlockSize = dyn_cast<VectorType>(bitBlockType)-> getBitWidth();
23    }
24       
25    Value * simd_add(unsigned fw, Value * a, Value * b);
26    Value * simd_sub(unsigned fw, Value * a, Value * b);
27    Value * simd_mult(unsigned fw, Value * a, Value * b);
28    Value * simd_eq(unsigned fw, Value * a, Value * b);
29    Value * simd_gt(unsigned fw, Value * a, Value * b);
30    Value * simd_ugt(unsigned fw, Value * a, Value * b);
31    Value * simd_lt(unsigned fw, Value * a, Value * b);
32    Value * simd_ult(unsigned fw, Value * a, Value * b);
33    Value * simd_max(unsigned fw, Value * a, Value * b);
34    Value * simd_umax(unsigned fw, Value * a, Value * b);
35    Value * simd_min(unsigned fw, Value * a, Value * b);
36    Value * simd_umin(unsigned fw, Value * a, Value * b);
37   
38    Value * simd_slli(unsigned fw, Value * a, unsigned shift);
39    Value * simd_srli(unsigned fw, Value * a, unsigned shift);
40    Value * simd_srai(unsigned fw, Value * a, unsigned shift);
41   
42    Value * simd_cttz(unsigned fw, Value * a);
43   
44private:
45    Module * mMod;
46    IRBuilder <> * llvm_builder;
47    Type * mBitBlockType;
48    unsigned mBitBlockSize;
49   
50    Value * bitBlockCast(Value * a);
51    VectorType * fwVectorType(unsigned fw);
52    Value * fwCast(unsigned fw, Value * a);
53};
54
55}
56#endif // IDISA_BUILDER_H
Note: See TracBrowser for help on using the repository browser.