Changeset 6129
- Timestamp:
- Jul 9, 2018, 6:24:50 PM (8 months ago)
- Location:
- icGREP/icgrep-devel/icgrep/pablo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
icGREP/icgrep-devel/icgrep/pablo/builder.cpp
r5889 r6129 479 479 480 480 PabloAST * PabloBuilder::createInFile(PabloAST * expr) { 481 if (isa<Zeroes>(expr)) return expr; 481 482 MAKE_UNARY(createInFile, TypeId::InFile, expr); 482 483 return result; -
icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp
r6055 r6129 658 658 const PabloAST * rh = op->getRH(); 659 659 if ((isa<Var>(lh) || isa<Extract>(lh)) || (isa<Var>(rh) || isa<Extract>(rh))) { 660 const unsigned n = std::min(getIntegerBitWidth(lh->getType()), getIntegerBitWidth(rh->getType())); 661 const unsigned m = b->getBitBlockWidth() / n; 662 IntegerType * const fw = b->getIntNTy(m); 663 VectorType * const vTy = VectorType::get(b->getIntNTy(n), m); 660 if (getIntegerBitWidth(lh->getType()) != getIntegerBitWidth(rh->getType())) { 661 llvm::report_fatal_error("Integer types must be identical!"); 662 } 663 const unsigned intWidth = std::min(getIntegerBitWidth(lh->getType()), getIntegerBitWidth(rh->getType())); 664 const unsigned maskWidth = b->getBitBlockWidth() / intWidth; 665 IntegerType * const maskTy = b->getIntNTy(maskWidth); 666 VectorType * const vTy = VectorType::get(b->getIntNTy(intWidth), maskWidth); 664 667 665 668 Value * baseLhv = nullptr; … … 689 692 if (LLVM_UNLIKELY(typeId == TypeId::Add || typeId == TypeId::Subtract)) { 690 693 691 value = b->CreateAlloca(vTy, b->getInt32( n));692 693 for (unsigned i = 0; i < n; ++i) {694 value = b->CreateAlloca(vTy, b->getInt32(intWidth)); 695 696 for (unsigned i = 0; i < intWidth; ++i) { 694 697 llvm::Constant * const index = b->getInt32(i); 695 698 Value * lhv = nullptr; … … 722 725 } else { 723 726 724 value = UndefValue::get(VectorType::get( fw, n));725 726 for (unsigned i = 0; i < n; ++i) {727 value = UndefValue::get(VectorType::get(maskTy, intWidth)); 728 729 for (unsigned i = 0; i < intWidth; ++i) { 727 730 llvm::Constant * const index = b->getInt32(i); 728 731 Value * lhv = nullptr; … … 743 746 } 744 747 rhv = b->CreateBitCast(rhv, vTy); 745 746 748 Value * comp = nullptr; 747 749 switch (typeId) { 748 750 case TypeId::GreaterThanEquals: 749 751 case TypeId::LessThan: 750 comp = b->simd_ult( n, lhv, rhv);752 comp = b->simd_ult(intWidth, lhv, rhv); 751 753 break; 752 754 case TypeId::Equals: 753 755 case TypeId::NotEquals: 754 comp = b->simd_eq( n, lhv, rhv);756 comp = b->simd_eq(intWidth, lhv, rhv); 755 757 break; 756 758 case TypeId::LessThanEquals: 757 759 case TypeId::GreaterThan: 758 comp = b->simd_ugt( n, lhv, rhv);760 comp = b->simd_ugt(intWidth, lhv, rhv); 759 761 break; 760 762 default: llvm_unreachable("invalid vector operator id"); 761 763 } 762 Value * const mask = b->CreateZExtOrTrunc(b->hsimd_signmask( n, comp), fw);763 value = b->mvmd_insert(m , value, mask, i);764 Value * const mask = b->CreateZExtOrTrunc(b->hsimd_signmask(intWidth, comp), maskTy); 765 value = b->mvmd_insert(maskWidth, value, mask, i); 764 766 } 765 766 767 value = b->CreateBitCast(value, b->getBitBlockType()); 767 768 switch (typeId) { … … 769 770 case TypeId::LessThanEquals: 770 771 case TypeId::NotEquals: 771 value = b-> simd_not(value);772 value = b->CreateNot(value); 772 773 default: break; 773 774 } … … 783 784 value = b->CreateSub(lhv, rhv); break; 784 785 case TypeId::LessThan: 785 value = b->CreateICmp SLT(lhv, rhv); break;786 value = b->CreateICmpULT(lhv, rhv); break; 786 787 case TypeId::LessThanEquals: 787 value = b->CreateICmp SLE(lhv, rhv); break;788 value = b->CreateICmpULE(lhv, rhv); break; 788 789 case TypeId::Equals: 789 790 value = b->CreateICmpEQ(lhv, rhv); break; 790 791 case TypeId::GreaterThanEquals: 791 value = b->CreateICmp SGE(lhv, rhv); break;792 value = b->CreateICmpUGE(lhv, rhv); break; 792 793 case TypeId::GreaterThan: 793 value = b->CreateICmp SGT(lhv, rhv); break;794 value = b->CreateICmpUGT(lhv, rhv); break; 794 795 case TypeId::NotEquals: 795 796 value = b->CreateICmpNE(lhv, rhv); break;
Note: See TracChangeset
for help on using the changeset viewer.