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

Last change on this file since 5464 was 5464, checked in by nmedfort, 2 years ago

Restructuring work for the Driver classes. Start of work to eliminate the memory leaks with the ExecutionEngine?. Replaced custom AlignedMalloc? with backend call to std::aligned_malloc. Salvaged some work on DistributionPass? for reevaluation.

File size: 2.6 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 registerWidth, unsigned vectorWidth, unsigned stride)
17    : IDISA_Builder(C, registerWidth, registerWidth, stride)
18    , IDISA_I64_Builder(C, registerWidth, registerWidth, stride)
19    , groupThreads(stride/vectorWidth) {
20
21    }
22
23    ~IDISA_NVPTX20_Builder() {}
24
25    virtual std::string getBuilderUniqueName() override;
26
27    int getGroupThreads();
28
29    void CreateBaseFunctions() override;
30   
31    llvm::Value * bitblock_any(llvm::Value * a) override;
32    std::pair<llvm::Value *, llvm::Value *> bitblock_add_with_carry(llvm::Value * a, llvm::Value * b, llvm::Value * carryin) override;
33    virtual std::pair<llvm::Value *, llvm::Value *> bitblock_advance(llvm::Value * a, llvm::Value * shiftin, unsigned shift) override;
34    llvm::Value * bitblock_mask_from(llvm::Value * pos) override;
35    llvm::Value * bitblock_set_bit(llvm::Value * pos) override;
36
37    llvm::Value * getEOFMask(llvm::Value * remainingBytes);
38
39    llvm::Value * Advance(const unsigned index, const unsigned shiftAmount, llvm::Value * const value);
40    llvm::Value * LongAdd(llvm::Value * const valA, llvm::Value * const valB, llvm::Value * carryIn);
41
42    llvm::LoadInst * CreateAtomicLoadAcquire(llvm::Value * ptr) override;
43    llvm::StoreInst * CreateAtomicStoreRelease(llvm::Value * val, llvm::Value * ptr) override;
44
45    bool supportsIndirectBr() const final {
46        return false;
47    }
48
49private:
50
51    void CreateGlobals();
52    void CreateBuiltinFunctions();
53    void CreateLongAdvanceFunc();
54    void CreateLongAddFunc();
55    void CreateBallotFunc();
56
57private:
58    int                         groupThreads;
59    llvm::Function *            barrierFunc;
60    llvm::Function *            tidFunc;
61    llvm::Function *            mLongAdvanceFunc;
62    llvm::Function *            mLongAddFunc;
63    llvm::GlobalVariable*       carry;
64    llvm::GlobalVariable*       bubble;
65};
66
67#if 0
68
69class IDISA_NVPTX35_Builder : public IDISA_NVPTX20_Builder {
70    IDISA_NVPTX35_Builder(Module * m, int groupSize) : IDISA_NVPTX30_Builder(m, groupSize) {}
71   
72    std::pair<llvm::Value *, llvm::Value *> bitblock_advance(llvm::Value * a, llvm::Value * shiftin, unsigned shift) override;
73
74    ~IDISA_NVPTX35_Builder() {};
75    virtual std::string getBuilderUniqueName() override;
76};
77#endif   
78   
79}
80#endif // IDISA_NVPTX_BUILDER_H
Note: See TracBrowser for help on using the repository browser.