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

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

mergeh and mergel IDISA functions

File size: 2.1 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   
44    Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
45    Value * esimd_mergel(unsigned fw, Value * a, Value * b);
46
47private:
48    Module * mMod;
49    IRBuilder <> * llvm_builder;
50    Type * mBitBlockType;
51    unsigned mBitBlockSize;
52   
53    Value * bitBlockCast(Value * a);
54    VectorType * fwVectorType(unsigned fw);
55    Value * fwCast(unsigned fw, Value * a);
56};
57
58}
59#endif // IDISA_BUILDER_H
Note: See TracBrowser for help on using the repository browser.