Ignore:
Timestamp:
Jan 27, 2017, 2:22:06 PM (3 years ago)
Author:
nmedfort
Message:

Optimized Symbol Generation (and fixed potential bug that could allow duplicate names being constructed); made PabloKernel? extend PabloAST (temporarily removed PabloAST::getName() to avoid diamond problem); added an internal scalar to PabloKernel? struct for each Count to avoid InOut? output scalar variable problem; allowed CodeMotionPass? to move code within the same scope but across a branch statement. Began work on separating Kernels into either Block-Oriented or Segment-Oriented kernels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pe_string.h

    r5270 r5283  
    77namespace pablo {
    88
    9 class String : public PabloAST {
     9class String : public PabloAST, public llvm::StringRef {
    1010    friend class SymbolGenerator;
    1111public:
    12     using StringAllocator = SlabAllocator<char>;
    13 
    1412    static inline bool classof(const PabloAST * e) {
    1513        return e->getClassTypeId() == ClassTypeId::String;
     
    1715    static inline bool classof(const void *) {
    1816        return false;
    19     }
    20     virtual ~String(){
     17    }
     18    virtual ~String() { }
     19protected:
     20    String(llvm::Type * type, const llvm::StringRef & str, Allocator & allocator) noexcept
     21    : PabloAST(ClassTypeId::String, type,  allocator)
     22    , llvm::StringRef(str.data(), str.size()) {
    2123
    2224    }
    23     inline const llvm::StringRef & value() const {
    24         return mValue;
    25     }
    26     inline std::string to_string() const {
    27         return mValue.str();
    28     }
    29     inline llvm::StringRef value() {
    30         return mValue;
    31     }
    32 protected:
    33     String(llvm::Type * type, const std::string & value, Allocator & allocator) noexcept
    34     : PabloAST(ClassTypeId::String, type, this, allocator)
    35     , mValue(duplicate(value, allocator)) {
    36 
    37     }
    38 
    39     inline const char * duplicate(const std::string & value, Allocator & allocator) {
    40         char * string = reinterpret_cast<char*>(allocator.allocate<char*>(value.length() + 1));
    41         std::memcpy(string, value.c_str(), value.length());
    42         string[value.length()] = '\0';
    43         return string;
    44     }
    45 private:
    46     const llvm::StringRef mValue;
    4725};
    4826
Note: See TracChangeset for help on using the changeset viewer.