Changeset 5624


Ignore:
Timestamp:
Aug 30, 2017, 11:48:17 AM (3 weeks ago)
Author:
nmedfort
Message:

Modified CountForward/ReverseZeroes? to allow a zero value to be valid.

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

Legend:

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

    r5622 r5624  
    986986}
    987987
    988 Value * CBuilder::CreateCountForwardZeroes(Value * value) {
    989     CreateAssert(value, "CreateCountForwardZeroes: value cannot be zero!");
     988Value * CBuilder::CreateCountForwardZeroes(Value * value, const bool isZeroUndefined) {
     989    if (isZeroUndefined) {
     990        CreateAssert(value, "CreateCountForwardZeroes: value cannot be zero!");
     991    }
    990992    Value * cttzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::cttz, value->getType());
    991     return CreateCall(cttzFunc, {value, ConstantInt::getFalse(getContext())});
    992 }
    993 
    994 Value * CBuilder::CreateCountReverseZeroes(Value * value) {
    995     CreateAssert(value, "CreateCountReverseZeroes: value cannot be zero!");
     993    return CreateCall(cttzFunc, {value, getInt1(isZeroUndefined)});
     994}
     995
     996Value * CBuilder::CreateCountReverseZeroes(Value * value, const bool isZeroUndefined) {
     997    if (isZeroUndefined) {
     998        CreateAssert(value, "CreateCountReverseZeroes: value cannot be zero!");
     999    }
    9961000    Value * ctlzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::ctlz, value->getType());
    997     return CreateCall(ctlzFunc, {value, ConstantInt::getFalse(getContext())});
     1001    return CreateCall(ctlzFunc, {value, getInt1(isZeroUndefined)});
    9981002}
    9991003
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5622 r5624  
    217217    llvm::Value * CreatePopcount(llvm::Value * bits);
    218218
    219     llvm::Value * CreateCountForwardZeroes(llvm::Value * value);
    220 
    221     llvm::Value * CreateCountReverseZeroes(llvm::Value * value);
     219    llvm::Value * CreateCountForwardZeroes(llvm::Value * value, const bool isZeroUndefined = false);
     220
     221    llvm::Value * CreateCountReverseZeroes(llvm::Value * value, const bool isZeroUndefined = false);
    222222   
    223223    // Useful bit manipulation operations 
Note: See TracChangeset for help on using the changeset viewer.