Ignore:
Timestamp:
Apr 26, 2017, 10:12:11 AM (2 years ago)
Author:
cameron
Message:

Add bit manipulation instructions to CBuilder

File:
1 edited

Legend:

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

    r5425 r5427  
    697697}
    698698
     699Value * CBuilder::CreateResetLowestBit(Value * bits) {
     700    return CreateAnd(bits, CreateSub(bits, ConstantInt::get(bits->getType(), 1)));
     701}
     702
     703Value * CBuilder::CreateIsolateLowestBit(Value * bits) {
     704    return CreateAnd(bits, CreateNeg(bits));
     705}
     706
     707Value * CBuilder::CreateMaskToLowestBitInclusive(Value * bits) {
     708    return CreateXor(bits, CreateSub(bits, ConstantInt::get(bits->getType(), 1)));
     709}
     710
     711Value * CBuilder::CreateMaskToLowestBitExclusive(Value * bits) {
     712    return CreateAnd(CreateSub(bits, ConstantInt::get(bits->getType(), 1)), CreateNot(bits));
     713}
     714
     715Value * CBuilder::CreateExtractBitField(llvm::Value * bits, Value * start, Value * length) {
     716    Constant * One = ConstantInt::get(bits->getType(), 1);
     717    return CreateAnd(CreateLShr(bits, start), CreateSub(CreateShl(One, length), One));
     718}
     719
    699720Value * CBuilder::CreateCeilLog2(Value * value) {
    700721    IntegerType * ty = cast<IntegerType>(value->getType());
Note: See TracChangeset for help on using the changeset viewer.