Changeset 4118 for icGREP


Ignore:
Timestamp:
Sep 1, 2014, 1:11:04 AM (5 years ago)
Author:
linmengl
Message:

auto detect LLVM version in CMakeList.txt; add #ifdef blocks

Location:
icGREP/icgrep-devel/icgrep
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r4096 r4118  
    3838llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES mcjit native)
    3939
     40message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
    4041
    4142add_library(PabloADT pe_advance.cpp  pe_all.cpp  pe_and.cpp pe_call.cpp pe_charclass.cpp  pe_matchstar.cpp pe_scanthru.cpp pe_not.cpp  pe_or.cpp  pe_pabloe.cpp  pe_sel.cpp  pe_var.cpp  pe_xor.cpp ps_assign.cpp  ps_if.cpp  ps_pablos.cpp  ps_while.cpp printer_pablos.cpp)
     
    5859set(CMAKE_CXX_FLAGS_RELEASE "-std=gnu++0x -O3 -msse2")
    5960
     61# detect LLVM version and add compiler flags.
     62if (${LLVM_PACKAGE_VERSION} MATCHES "3.4")
     63  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_LLVM_3_4")
     64elseif (${LLVM_PACKAGE_VERSION} MATCHES "3.5")
     65  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_LLVM_3_5")
     66endif(${LLVM_PACKAGE_VERSION} MATCHES "3.4")
     67
    6068add_test(
    6169  NAME greptest
  • icGREP/icgrep-devel/icgrep/icgrep.cpp

    r4080 r4118  
    7272#endif
    7373
     74//define this indicates that we use llvm.uadd.with.overflow for genAddWithCarry
     75#define USE_UADD_OVERFLOW
     76
    7477BitBlock get_category(Basis_bits &basis_bits, const char* category);
    7578
     
    8487    char * infile_buffer;
    8588#endif
    86    
     89
    8790    int opt_code;
    8891    int count_only_option = 0;
     
    296299    BitStreamScanner<BitBlock, uint64_t, uint64_t, SEGMENT_BLOCKS> LF_scanner;
    297300    BitStreamScanner<BitBlock, uint64_t, uint64_t, SEGMENT_BLOCKS> match_scanner;
    298        
    299    
     301
     302
    300303#ifndef USE_MMAP
    301304    ATTRIBUTE_SIMD_ALIGN char src_buffer[SEGMENT_SIZE];
    302    
     305
    303306    chars_read = fread((void *)&src_buffer[0], 1, SEGMENT_SIZE, infile);
    304307    chars_avail = chars_read;
    305308    if (chars_avail >= SEGMENT_SIZE) chars_avail = SEGMENT_SIZE;
    306309#endif
    307 #ifdef USE_MMAP   
     310#ifdef USE_MMAP
    308311    int segment = 0;
    309312    int segment_base = 0;
    310313    chars_avail = infile_size;
    311    
     314
    312315#endif
    313316//////////////////////////////////////////////////////////////////////////////////////////
     
    315318//////////////////////////////////////////////////////////////////////////////////////////
    316319
    317    
    318    
     320
     321
    319322    while (chars_avail >= SEGMENT_SIZE) {
    320323
     
    332335#ifdef USE_MMAP
    333336            block_base = blk*BLOCK_SIZE + segment_base;
    334             s2p_do_block((BytePack *) &infile_buffer[block_base], basis_bits);   
     337            s2p_do_block((BytePack *) &infile_buffer[block_base], basis_bits);
    335338#endif
    336339            process_block(basis_bits, carry_q, output);
     
    368371#endif
    369372#ifdef USE_MMAP
    370    
     373
    371374#endif
    372375
     
    389392#ifdef USE_MMAP
    390393                fwrite(&infile_buffer[segment_base + line_start], 1, line_end - line_start + 1, outfile);
    391  
     394
    392395#endif
    393396
     
    415418        line_start -= SEGMENT_SIZE;  /* Will be negative offset for use within next segment. */
    416419        chars_avail -= SEGMENT_SIZE;
    417    
     420
    418421#endif
    419422    }
     
    442445#ifdef USE_MMAP
    443446        block_base = block_pos + segment_base;
    444         s2p_do_block((BytePack *) &infile_buffer[block_base], basis_bits);   
     447        s2p_do_block((BytePack *) &infile_buffer[block_base], basis_bits);
    445448#endif
    446449        process_block(basis_bits, carry_q, output);
     
    479482#ifdef USE_MMAP
    480483     block_base = block_pos + segment_base;
    481      s2p_do_final_block((BytePack *) &infile_buffer[block_base], basis_bits, EOF_mask);   
     484     s2p_do_final_block((BytePack *) &infile_buffer[block_base], basis_bits, EOF_mask);
    482485#endif
    483486    process_block(basis_bits, carry_q, output);
     
    520523#ifdef USE_MMAP
    521524            fwrite(&infile_buffer[segment_base + line_start], 1, line_end - line_start + 1, outfile);
    522  
     525
    523526#endif
    524527            line_start = line_end + 1;
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r4117 r4118  
    551551    // to call->  b.CreateCall(mFunc_print_register, unicode_category);
    552552
     553#ifdef USE_UADD_OVERFLOW
    553554    // Type Definitions for llvm.uadd.with.overflow.i128
    554555    std::vector<Type*>StructTy_0_fields;
     
    588589    }
    589590    mFunc_llvm_uadd_with_overflow_i128->setAttributes(mFunc_llvm_uadd_with_overflow_i128_PAL);
     591#endif
    590592
    591593    //Starts on process_block
     
    11831185
    11841186#ifdef USE_UADD_OVERFLOW
    1185     //new code chunk, use llvm.uadd.with.overflow.i128
     1187    //use llvm.uadd.with.overflow.i128
    11861188    CastInst* int128_e1 = new BitCastInst(e1, IntegerType::get(mMod->getContext(), 128), "e1_128", mBasicBlock);
    11871189    CastInst* int128_e2 = new BitCastInst(e2, IntegerType::get(mMod->getContext(), 128), "e2_128", mBasicBlock);
     
    12031205
    12041206    Value* void_1 = genCarryOutStore(carry_out, mptr_carry_q, this_carry_idx);
    1205 
    12061207    return ret_sum;
    1207     //new code chunk ends
    1208 #endif
    1209 #ifndef USE_UADD_OVERFLOW
    1210     //Old code chunk, calculate carry through logical ops
     1208#else
     1209    //calculate carry through logical ops
    12111210    Value* carrygen = b.CreateAnd(e1, e2, "carrygen");
    12121211    Value* carryprop = b.CreateOr(e1, e2, "carryprop");
     
    12211220
    12221221    return sum;
    1223     //Old code chunk ends
    12241222#endif
    12251223}
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r4117 r4118  
    88#define LLVM_GENERATOR_H
    99
    10 #define USE_LLVM_3_4
    1110//#define DUMP_GENERATED_IR
    1211
Note: See TracChangeset for help on using the changeset viewer.