source: icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.h @ 6106

Last change on this file since 6106 was 6106, checked in by cameron, 10 months ago

mergeh, mergel for arbitrary BitBlockWidth?

File size: 5.0 KB
Line 
1#ifndef IDISA_AVX_BUILDER_H
2#define IDISA_AVX_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*/
8
9#include <IR_Gen/idisa_sse_builder.h>
10#include <toolchain/toolchain.h>
11
12namespace IDISA {
13   
14    const unsigned AVX_width = 256;
15    const unsigned AVX512_width = 512;
16
17class IDISA_AVX_Builder : public IDISA_SSE2_Builder {
18public:
19    const unsigned NativeBitBlockWidth = AVX_width;
20    IDISA_AVX_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned laneWidth)
21    : IDISA_Builder(C, AVX_width, vectorWidth, laneWidth)
22    , IDISA_SSE2_Builder(C, vectorWidth, laneWidth)
23    {
24
25    }
26
27    virtual std::string getBuilderUniqueName() override;
28
29    llvm::Value * hsimd_signmask(unsigned fw, llvm::Value * a) override;
30
31    ~IDISA_AVX_Builder() {}
32
33};
34
35class IDISA_AVX2_Builder : public IDISA_AVX_Builder {
36public:
37    const unsigned NativeBitBlockWidth = AVX_width;
38    IDISA_AVX2_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned laneWidth)
39    : IDISA_Builder(C, AVX_width, vectorWidth, laneWidth)
40    , IDISA_AVX_Builder(C, vectorWidth, laneWidth) {
41
42    }
43
44    virtual std::string getBuilderUniqueName() override;
45    llvm::Value * hsimd_packh(unsigned fw, llvm::Value * a, llvm::Value * b) override;
46    llvm::Value * hsimd_packl(unsigned fw, llvm::Value * a, llvm::Value * b) override;
47    llvm::Value * esimd_mergeh(unsigned fw, llvm::Value * a, llvm::Value * b) override;
48    llvm::Value * esimd_mergel(unsigned fw, llvm::Value * a, llvm::Value * b) override;
49    llvm::Value * hsimd_packh_in_lanes(unsigned lanes, unsigned fw, llvm::Value * a, llvm::Value * b) override;
50    llvm::Value * hsimd_packl_in_lanes(unsigned lanes, unsigned fw, llvm::Value * a, llvm::Value * b) override;
51    std::pair<llvm::Value *, llvm::Value *> bitblock_add_with_carry(llvm::Value * a, llvm::Value * b, llvm::Value * carryin) override;
52    std::pair<llvm::Value *, llvm::Value *> bitblock_indexed_advance(llvm::Value * a, llvm::Value * index_strm, llvm::Value * shiftin, unsigned shift) override;
53    llvm::Value * hsimd_signmask(unsigned fw, llvm::Value * a) override;
54    llvm::Value * mvmd_srl(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
55    llvm::Value * mvmd_sll(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
56    llvm::Value * mvmd_shuffle(unsigned fw, llvm::Value * data_table, llvm::Value * index_vector) override;
57    llvm::Value * mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) override;
58    llvm::Value * simd_pext(unsigned fw, llvm::Value * v, llvm::Value * extract_mask) override;
59    llvm::Value * simd_pdep(unsigned fw, llvm::Value * v, llvm::Value * deposit_mask) override;
60   
61
62    ~IDISA_AVX2_Builder() {}
63};
64
65#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(3, 8, 0)
66class IDISA_AVX512F_Builder : public IDISA_AVX2_Builder {
67public:
68    const unsigned NativeBitBlockWidth = AVX512_width;
69    IDISA_AVX512F_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned laneWidth)
70    : IDISA_Builder(C, AVX512_width, vectorWidth, laneWidth)
71    , IDISA_AVX2_Builder(C, vectorWidth, laneWidth) {
72        getAVX512Features();
73    }
74
75    virtual std::string getBuilderUniqueName() override;
76    void getAVX512Features();
77    llvm::Value * hsimd_packh(unsigned fw, llvm::Value * a, llvm::Value * b) override;
78    llvm::Value * hsimd_packl(unsigned fw, llvm::Value * a, llvm::Value * b) override;
79    llvm::Value * esimd_mergeh(unsigned fw, llvm::Value * a, llvm::Value * b) override;
80    llvm::Value * esimd_mergel(unsigned fw, llvm::Value * a, llvm::Value * b) override;
81    llvm::Value * esimd_bitspread(unsigned fw, llvm::Value * bitmask) override;
82    llvm::Value * simd_popcount(unsigned fw, llvm::Value * a) override;
83    llvm::Value * mvmd_slli(unsigned fw, llvm::Value * a, unsigned shift) override;
84    llvm::Value * mvmd_dslli(unsigned fw, llvm::Value * a, llvm::Value * b, unsigned shift) override;
85    llvm::Value * hsimd_signmask(unsigned fw, llvm::Value * a) override;
86    llvm::Value * mvmd_shuffle(unsigned fw, llvm::Value * data_table, llvm::Value * index_vector) override;
87    llvm::Value * mvmd_shuffle2(unsigned fw, llvm::Value * table0, llvm::Value * table1, llvm::Value * index_vector) override;
88    llvm::Value * mvmd_compress(unsigned fw, llvm::Value * a, llvm::Value * select_mask) override;
89    llvm::Value * mvmd_srl(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
90    llvm::Value * mvmd_sll(unsigned fw, llvm::Value * a, llvm::Value * shift) override;
91    llvm::Value * simd_if(unsigned fw, llvm::Value * cond, llvm::Value * a, llvm::Value * b) override;
92
93    ~IDISA_AVX512F_Builder() {
94    }
95private:
96    struct Features {
97        //not an exhaustive list, can be extended if needed
98        bool hasAVX512CD = false;
99        bool hasAVX512BW = false;
100        bool hasAVX512DQ = false;
101        bool hasAVX512VL = false;
102        bool hasAVX512VBMI = false;
103        bool hasAVX512VBMI2 = false;
104        bool hasAVX512VPOPCNTDQ = false;
105    };
106    Features hostCPUFeatures;
107};
108#endif
109
110}
111#endif // IDISA_AVX_BUILDER_H
Note: See TracBrowser for help on using the repository browser.