Tests/testDSL.cpp
//-----------------------------------------------------------------------------
// Test for specific DSL operations.
//-----------------------------------------------------------------------------
Test for specific DSL operations.
Test for specific DSL operations .
void int_ops_kernel(Int::Ptr result) {
  using namespace V3DLib::functions;
   NEVER FORGET:
   Previous definition:
      auto store = [&result] (IntExpr const &val) {
   This resulted in the passed Int var to be converted to IntExpr,
   and then back to Int, creating a useless interim variable in the source lang
  auto store = [&result] (Int const &val) {
    comment("store starts next"); 
    *result = val;
    result += 16;
  };
  Int a = index();
  a += 3;
  store(a);
  a -= 11;
  store(a);
  store(abs(index() - 8));
  store(two_complement(index() - 8));        2's complement, library call
  Int b = topmost_bit(1 << (index() + 3));
  store(b);
  b = -256;
  store(b);
  comment("First division test starts next");
  store(16*16/index());
  comment("First usage -index() starts next");
  store((-16*16)/(-index()));
  store((-16*16)/index());
  store(16*16/(-index()));
  store(17*index()/11);
}
void int_ops_kernel ( Int :: Ptr result ) { using namespace V3DLib :: functions ; auto store = [ & result ] ( Int const & val ) { comment ( " " ) ; * result = val ; result += 16 ; } ; Int a = index ( ) ; a += 3 ; store ( a ) ; a -= 11 ; store ( a ) ; store ( abs ( index ( ) - 8 ) ) ; store ( two_complement ( index ( ) - 8 ) ) ; Int b = topmost_bit ( 1 << ( index ( ) + 3 ) ) ; store ( b ) ; b = -256 ; store ( b ) ; comment ( " " ) ; store ( 16 * 16 / index ( ) ) ; comment ( " " ) ; store ( ( -16 * 16 ) / ( - index ( ) ) ) ; store ( ( -16 * 16 ) / index ( ) ) ; store ( 16 * 16 / ( - index ( ) ) ) ; store ( 17 * index ( ) / 11 ) ; }
Test for specific DSL operations.
Test for specific DSL operations .
// // NEVER FORGET: // // Previous definition: // //    auto store = [&result] (IntExpr const &val) { // // This resulted in the passed Int var to be converted to IntExpr, // and then back to Int, creating a useless interim variable in the source lang // // 2's complement, library call