source: icGREP/icgrep-devel/icgrep/IR_Gen/idisa_nvptx_builder.h @ 5795

Last change on this file since 5795 was 5489, checked in by nmedfort, 22 months ago

Bug fix for memory check and issues found parsing internal 'files'. Added backtrace option from execinfo.h

File size: 3.3 KB
Line 
1#ifndef IDISA_NVPTX_BUILDER_H
2#define IDISA_NVPTX_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_i64_builder.h>
10
11namespace IDISA {
12
13class IDISA_NVPTX20_Builder : public IDISA_I64_Builder {
14public:
15   
16    IDISA_NVPTX20_Builder(llvm::LLVMContext & C, unsigned vectorWidth, unsigned stride)
17    : IDISA_Builder(C, vectorWidth, stride)
18    , IDISA_I64_Builder(C, vectorWidth, stride)
19    , groupThreads(stride / vectorWidth)
20    , barrierFunc(nullptr)
21    , tidFunc(nullptr)
22    , mLongAdvanceFunc(nullptr)
23    , mLongAddFunc(nullptr)
24    , carry(nullptr)
25    , bubble(nullptr) {
26        assert ((stride % vectorWidth) == 0);
27    }
28
29    ~IDISA_NVPTX20_Builder() {}
30
31    virtual std::string getBuilderUniqueName() override;
32
33    unsigned getGroupThreads() const;
34
35    void CreateBaseFunctions() override;
36   
37    llvm::Value * bitblock_any(llvm::Value * a) override;
38    std::pair<llvm::Value *, llvm::Value *> bitblock_add_with_carry(llvm::Value * a, llvm::Value * b, llvm::Value * carryin) override;
39    virtual std::pair<llvm::Value *, llvm::Value *> bitblock_advance(llvm::Value * a, llvm::Value * shiftin, unsigned shift) override;
40    llvm::Value * bitblock_mask_from(llvm::Value * pos) override;
41    llvm::Value * bitblock_set_bit(llvm::Value * pos) override;
42
43    llvm::Value * getEOFMask(llvm::Value * remainingBytes);
44
45    llvm::Value * Advance(const unsigned index, const unsigned shiftAmount, llvm::Value * const value);
46    llvm::Value * LongAdd(llvm::Value * const valA, llvm::Value * const valB, llvm::Value * carryIn);
47
48    llvm::LoadInst * CreateAtomicLoadAcquire(llvm::Value * ptr) override;
49    llvm::StoreInst * CreateAtomicStoreRelease(llvm::Value * val, llvm::Value * ptr) override;
50
51    bool supportsIndirectBr() const final {
52        return false;
53    }
54
55    #ifdef HAS_ADDRESS_SANITIZER
56    llvm::LoadInst * CreateLoad(llvm::Value *Ptr, const char *Name) override;
57
58    llvm::LoadInst * CreateLoad(llvm::Value *Ptr, const llvm::Twine &Name = "") override;
59
60    llvm::LoadInst * CreateLoad(llvm::Type *Ty, llvm::Value *Ptr, const llvm::Twine &Name = "") override;
61
62    llvm::LoadInst * CreateLoad(llvm::Value *Ptr, bool isVolatile, const llvm::Twine &Name = "") override;
63
64    llvm::StoreInst * CreateStore(llvm::Value *Val, llvm::Value *Ptr, bool isVolatile = false) override;
65    #endif
66
67private:
68
69    void CreateGlobals();
70    void CreateBuiltinFunctions();
71    void CreateLongAdvanceFunc();
72    void CreateLongAddFunc();
73    void CreateBallotFunc();
74
75private:
76    const unsigned              groupThreads;
77    llvm::Function *            barrierFunc;
78    llvm::Function *            tidFunc;
79    llvm::Function *            mLongAdvanceFunc;
80    llvm::Function *            mLongAddFunc;
81    llvm::GlobalVariable*       carry;
82    llvm::GlobalVariable*       bubble;
83};
84
85#if 0
86
87class IDISA_NVPTX35_Builder : public IDISA_NVPTX20_Builder {
88    IDISA_NVPTX35_Builder(Module * m, int groupSize) : IDISA_NVPTX30_Builder(m, groupSize) {}
89   
90    std::pair<llvm::Value *, llvm::Value *> bitblock_advance(llvm::Value * a, llvm::Value * shiftin, unsigned shift) override;
91
92    ~IDISA_NVPTX35_Builder() {};
93    virtual std::string getBuilderUniqueName() override;
94};
95#endif   
96   
97}
98#endif // IDISA_NVPTX_BUILDER_H
Note: See TracBrowser for help on using the repository browser.