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

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

esimd_mergel/h 1 for AVX-512

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