Ignore:
Timestamp:
Jan 13, 2018, 11:57:43 AM (17 months ago)
Author:
nmedfort
Message:

Pablo support for byte comparisions; LineFeed? kernel processes byte streams directly. Some clean up of PabloBuilder? functionality.

Location:
icGREP/icgrep-devel/icgrep/IR_Gen
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.cpp

    r5812 r5828  
    678678}
    679679
    680 IntegerType * CBuilder::getIntAddrTy() const {
     680IntegerType * LLVM_READNONE CBuilder::getIntAddrTy() const {
    681681    return TypeBuilder<intptr_t, false>::get(getContext());
    682682}
    683683
    684 PointerType * CBuilder::getVoidPtrTy(const unsigned AddressSpace) const {
     684PointerType * LLVM_READNONE CBuilder::getVoidPtrTy(const unsigned AddressSpace) const {
    685685    return PointerType::get(Type::getVoidTy(getContext()), AddressSpace);
    686686}
     
    701701}
    702702
    703 PointerType * CBuilder::getFILEptrTy() {
     703PointerType * LLVM_READNONE CBuilder::getFILEptrTy() {
    704704    if (mFILEtype == nullptr) {
    705705        mFILEtype = StructType::create(getContext(), "struct._IO_FILE");
     
    10841084    } else { // if assertions are not enabled, make it a compiler assumption.
    10851085
    1086         // INVESTIGATE: while interesting, this does not seem to produce faster code and only provides a trivial reduction
    1087         // of compiled code size in LLVM 3.8 but nearly doubles compilation time. This may have been improved with later
    1088         // versions of LLVM but it's likely that assumptions ought to be hand placed once they're prove to improve performance.
     1086        // INVESTIGATE: while interesting, this does not seem to produce faster code and only provides a trivial
     1087        // reduction of compiled code size in LLVM 3.8 but nearly doubles compilation time. This may have been
     1088        // improved with later versions of LLVM but it's likely that assumptions ought to be hand placed once
     1089        // they're proven to improve performance.
    10891090
    10901091        // IRBuilder<>::CreateAssumption(assertion);
     
    11041105}
    11051106
    1106 BasicBlock * CBuilder::CreateBasicBlock(std::string && name) {
    1107     return BasicBlock::Create(getContext(), name, GetInsertBlock()->getParent());
     1107BasicBlock * CBuilder::CreateBasicBlock(const StringRef name, BasicBlock * insertBefore) {
     1108    return BasicBlock::Create(getContext(), name, GetInsertBlock()->getParent(), insertBefore);
    11081109}
    11091110
     
    11251126}
    11261127
    1127 Value * CBuilder::CreateCountForwardZeroes(Value * value, const bool isZeroUndefined) {
    1128     if (LLVM_UNLIKELY(isZeroUndefined && codegen::DebugOptionIsSet(codegen::EnableAsserts))) {
     1128Value * CBuilder::CreateCountForwardZeroes(Value * value, const bool guaranteedNonZero) {
     1129    if (LLVM_UNLIKELY(guaranteedNonZero && codegen::DebugOptionIsSet(codegen::EnableAsserts))) {
    11291130        CreateAssert(value, "CreateCountForwardZeroes: value cannot be zero!");
    11301131    }
    1131     Value * cttzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::cttz, value->getType());
    1132     return CreateCall(cttzFunc, {value, getInt1(isZeroUndefined)});
    1133 }
    1134 
    1135 Value * CBuilder::CreateCountReverseZeroes(Value * value, const bool isZeroUndefined) {
    1136     if (LLVM_UNLIKELY(isZeroUndefined && codegen::DebugOptionIsSet(codegen::EnableAsserts))) {
     1132    Value * cttzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::cttz, value->getType());   
     1133    return CreateCall(cttzFunc, {value, getInt1(guaranteedNonZero)});
     1134}
     1135
     1136Value * CBuilder::CreateCountReverseZeroes(Value * value, const bool guaranteedNonZero) {
     1137    if (LLVM_UNLIKELY(guaranteedNonZero && codegen::DebugOptionIsSet(codegen::EnableAsserts))) {
    11371138        CreateAssert(value, "CreateCountReverseZeroes: value cannot be zero!");
    11381139    }
    11391140    Value * ctlzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::ctlz, value->getType());
    1140     return CreateCall(ctlzFunc, {value, getInt1(isZeroUndefined)});
     1141    return CreateCall(ctlzFunc, {value, getInt1(guaranteedNonZero)});
    11411142}
    11421143
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5771 r5828  
    222222    }
    223223   
    224     llvm::IntegerType * getIntAddrTy() const;
    225    
    226     llvm::PointerType * getVoidPtrTy(const unsigned AddressSpace = 0) const;
    227    
    228     llvm::PointerType * getFILEptrTy();
     224    llvm::IntegerType * LLVM_READNONE getIntAddrTy() const;
     225   
     226    llvm::PointerType * LLVM_READNONE getVoidPtrTy(const unsigned AddressSpace = 0) const;
     227   
     228    llvm::PointerType * LLVM_READNONE getFILEptrTy();
    229229   
    230230    inline unsigned getCacheAlignment() const {
     
    258258    }
    259259
    260     llvm::BasicBlock * CreateBasicBlock(std::string && name);
     260    llvm::BasicBlock * CreateBasicBlock(const llvm::StringRef name, llvm::BasicBlock * insertBefore = nullptr);
    261261
    262262    virtual bool supportsIndirectBr() const;
     
    264264    llvm::Value * CreatePopcount(llvm::Value * bits);
    265265
    266     llvm::Value * CreateCountForwardZeroes(llvm::Value * value, const bool isZeroUndefined = false);
    267 
    268     llvm::Value * CreateCountReverseZeroes(llvm::Value * value, const bool isZeroUndefined = false);
     266    // TODO: AVX512 offers these as vector instructions
     267    llvm::Value * CreateCountForwardZeroes(llvm::Value * value, const bool guaranteedNonZero = false);
     268    llvm::Value * CreateCountReverseZeroes(llvm::Value * value, const bool guaranteedNonZero = false);
    269269   
    270270    // Useful bit manipulation operations 
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.cpp

    r5759 r5828  
    2828            Value * a_as_ps = CreateBitCast(a, bitBlock_f32type);
    2929            return CreateCall(signmask_f32func, a_as_ps);
     30        } else if (fw == 8) {
     31            Value * signmask_f8func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx2_pmovmskb);
     32            Type * bitBlock_i8type = VectorType::get(getInt8Ty(), mBitBlockWidth/8);
     33            Value * a_as_ps = CreateBitCast(a, bitBlock_i8type);
     34            return CreateCall(signmask_f8func, a_as_ps);
    3035        }
    3136    } else if (mBitBlockWidth == 512) {
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.cpp

    r5774 r5828  
    7575Value * IDISA_Builder::simd_fill(unsigned fw, Value * a) {
    7676    if (fw < 8) report_fatal_error("Unsupported field width: simd_fill " + std::to_string(fw));
    77    unsigned field_count = mBitBlockWidth/fw;
     77    const unsigned field_count = mBitBlockWidth/fw;
    7878    Type * singleFieldVecTy = VectorType::get(getIntNTy(fw), 1);
    7979    Value * aVec = CreateBitCast(a, singleFieldVecTy);
     
    8282
    8383Value * IDISA_Builder::simd_add(unsigned fw, Value * a, Value * b) {
    84     if (fw == 1) return simd_xor(a, b);
    85     if (fw < 8) {
     84    if (fw == 1) {
     85        return simd_xor(a, b);
     86    } else if (fw < 8) {
    8687        Constant * hi_bit_mask = Constant::getIntegerValue(getIntNTy(mBitBlockWidth),
    8788                                                           APInt::getSplat(mBitBlockWidth, APInt::getHighBitsSet(fw, 1)));
     
    271272}
    272273
    273 Value * IDISA_Builder::simd_cttz(unsigned fw, Value * a) {
    274     if (fw < 8) report_fatal_error("Unsupported field width: cttz " + std::to_string(fw));
    275     Value * cttzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::cttz, fwVectorType(fw));
    276     return CreateCall(cttzFunc, {fwCast(fw, a), ConstantInt::get(getInt1Ty(), 0)});
    277 }
    278 
    279 Value * IDISA_Builder::simd_popcount(unsigned fw, Value * a) {
    280     if (fw < 8) report_fatal_error("Unsupported field width: popcount " + std::to_string(fw));
    281     Value * ctpopFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::ctpop, fwVectorType(fw));
    282     return CreateCall(ctpopFunc, fwCast(fw, a));
    283 }
    284 
    285274Value * IDISA_Builder::simd_bitreverse(unsigned fw, Value * a) {
    286275    /*  Pure sequential solution too slow!
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.h

    r5729 r5828  
    104104    virtual llvm::Value * simd_pdep(unsigned fw, llvm::Value * v, llvm::Value * deposit_mask);
    105105   
    106     virtual llvm::Value * simd_cttz(unsigned fw, llvm::Value * a);
    107     virtual llvm::Value * simd_popcount(unsigned fw, llvm::Value * a);
     106    llvm::Value * simd_popcount(unsigned fw, llvm::Value * a) {
     107        if (LLVM_UNLIKELY(fw < 8)) {
     108            llvm::report_fatal_error("Unsupported field width: popcount " + std::to_string(fw));
     109        }
     110        return CreatePopcount(fwCast(fw, a));
     111    }
     112
    108113    virtual llvm::Value * simd_bitreverse(unsigned fw, llvm::Value * a);
    109114   
     
    134139    virtual llvm::Value * bitblock_mask_from(llvm::Value * pos);
    135140    virtual llvm::Value * bitblock_set_bit(llvm::Value * pos);
    136    
    137141
    138142    virtual void CreateBaseFunctions() {}
Note: See TracChangeset for help on using the changeset viewer.