source: icGREP/icgrep-devel/icgrep/IDISA/idisa_nvptx_builder.h @ 5192

Last change on this file since 5192 was 5192, checked in by cameron, 2 years ago

CreateAtomicLoadAcquire?, CreateAtomicStoreRelease? with NVPTX overrides

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