Changeset 4942


Ignore:
Timestamp:
Feb 23, 2016, 4:08:10 PM (3 years ago)
Author:
lindanl
Message:

Remove simd-lib. Print register implemented in LLVM IR.

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

Legend:

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

    r4939 r4942  
    319319        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_S2P_AVX2 -DBLOCK_SIZE=256 -march=core-avx2 -m64")
    320320    ENDIF()
     321ELSE ()
     322    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBLOCK_SIZE=128")
    321323ENDIF()
    322324
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.cpp

    r4937 r4942  
    1010#include <llvm/IR/Intrinsics.h>
    1111#include <llvm/IR/Function.h>
     12#include <llvm/IR/TypeBuilder.h>
    1213
    1314namespace IDISA {
     
    2223}
    2324
     25// void IDISA_Builder::genPrintRegister(std::string regName, Value * bitblockValue) {
     26//     if (mPrintRegisterFunction == nullptr) {
     27//         mPrintRegisterFunction = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(mMod->getContext()), Type::getInt8PtrTy(mMod->getContext()), mBitBlockType, NULL);
     28//     }
     29//     Constant * regNameData = ConstantDataArray::getString(mMod->getContext(), regName);
     30//     GlobalVariable *regStrVar = new GlobalVariable(*mMod,
     31//                                                    ArrayType::get(IntegerType::get(mMod->getContext(), 8), regName.length()+1),
     32//                                                    /*isConstant=*/ true,
     33//                                                    /*Linkage=*/ GlobalValue::PrivateLinkage,
     34//                                                    /*Initializer=*/ regNameData);
     35//     Value * regStrPtr = CreateGEP(regStrVar, std::vector<Value *>({getInt64(0), getInt32(0)}));
     36//     CreateCall(mPrintRegisterFunction, std::vector<Value *>({regStrPtr, bitCast(bitblockValue)}));
     37// }
     38
     39Constant* geti8StrVal(Module& M, char const* str, Twine const& name) {
     40    LLVMContext& ctx = getGlobalContext();
     41    Constant* strConstant = ConstantDataArray::getString(ctx, str);
     42    GlobalVariable* GVStr = new GlobalVariable(M, strConstant->getType(), true, GlobalValue::InternalLinkage, strConstant, name);
     43    Constant* zero = Constant::getNullValue(IntegerType::getInt32Ty(ctx));
     44    Constant* indices[] = {zero, zero};
     45    Constant* strVal = ConstantExpr::getGetElementPtr(GVStr, indices, true);
     46    return strVal;
     47}
     48
     49static Function *create_printf(LLVMContext &ctx, Module *mod) {
     50
     51  FunctionType *printf_type =
     52      TypeBuilder<int(char *, ...), false>::get(getGlobalContext());
     53
     54  Function *func = cast<Function>(mod->getOrInsertFunction(
     55      "printf", printf_type,
     56      AttributeSet().addAttribute(mod->getContext(), 1U, Attribute::NoAlias)));
     57
     58  return func;
     59}
     60
    2461void IDISA_Builder::genPrintRegister(std::string regName, Value * bitblockValue) {
    25     if (mPrintRegisterFunction == nullptr) {
    26         mPrintRegisterFunction = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(mMod->getContext()), Type::getInt8PtrTy(mMod->getContext()), mBitBlockType, nullptr);
    27     }
    28     Constant * regNameData = ConstantDataArray::getString(mMod->getContext(), regName);
    29     GlobalVariable *regStrVar = new GlobalVariable(*mMod,
    30                                                    ArrayType::get(IntegerType::get(mMod->getContext(), 8), regName.length()+1),
    31                                                    /*isConstant=*/ true,
    32                                                    /*Linkage=*/ GlobalValue::PrivateLinkage,
    33                                                    /*Initializer=*/ regNameData);
    34     Value * regStrPtr = CreateGEP(regStrVar, std::vector<Value *>({getInt64(0), getInt32(0)}));
    35     CreateCall(mPrintRegisterFunction, std::vector<Value *>({regStrPtr, bitCast(bitblockValue)}));
    36 }
    37 
    38     Constant * IDISA_Builder::simd_himask(unsigned fw) {
    39         return Constant::getIntegerValue(getIntNTy(mBitBlockWidth), APInt::getSplat(mBitBlockWidth, APInt::getHighBitsSet(fw, fw/2)));
    40     }
    41    
    42     Constant * IDISA_Builder::simd_lomask(unsigned fw) {
    43         return Constant::getIntegerValue(getIntNTy(mBitBlockWidth), APInt::getSplat(mBitBlockWidth, APInt::getLowBitsSet(fw, fw/2)));
    44     }
    45    
    46     Value * IDISA_Builder::simd_add(unsigned fw, Value * a, Value * b) {
    47     return CreateAdd(fwCast(fw, a), fwCast(fw, b));
     62    Function *printf_func = create_printf(mMod->getContext(), mMod);
     63    Type * printType = VectorType::get(getIntNTy(8), mBitBlockWidth/8);
     64    Value * val = CreateBitCast(bitblockValue, printType);
     65    std::vector<Value *> args;
     66    std::string str = regName + "\t = %02X";
     67    for(unsigned int i=0; i<mBitBlockWidth/8-1; i++)
     68        str += ", %02X";
     69    str += "\n";
     70    args.push_back(geti8StrVal(*mMod, str.c_str(), regName));
     71    for(unsigned int i=0; i<mBitBlockWidth/8; i++)
     72        args.push_back(CreateExtractElement(val, ConstantInt::get(getIntNTy(32), i)));
     73    args.push_back(val);
     74    CreateCall(printf_func, args);
     75}
     76
     77Constant * IDISA_Builder::simd_himask(unsigned fw) {
     78    return Constant::getIntegerValue(getIntNTy(mBitBlockWidth), APInt::getSplat(mBitBlockWidth, APInt::getHighBitsSet(fw, fw/2)));
     79}
     80
     81Constant * IDISA_Builder::simd_lomask(unsigned fw) {
     82    return Constant::getIntegerValue(getIntNTy(mBitBlockWidth), APInt::getSplat(mBitBlockWidth, APInt::getLowBitsSet(fw, fw/2)));
     83}
     84
     85Value * IDISA_Builder::simd_add(unsigned fw, Value * a, Value * b) {
     86return CreateAdd(fwCast(fw, a), fwCast(fw, b));
    4887}
    4988
  • icGREP/icgrep-devel/icgrep/pablo/carry_data.cpp

    r4925 r4942  
    55 */
    66
    7 
    8 #include <include/simd-lib/bitblock.hpp>
    97#include <pablo/pablo_compiler.h>
    108#include <pablo/codegenstate.h>
  • icGREP/icgrep-devel/icgrep/pablo/carry_data.h

    r4925 r4942  
    77#ifndef CARRY_DATA_H
    88#define CARRY_DATA_H
    9 #include <include/simd-lib/bitblock.hpp>
     9
    1010#include <stdexcept>
    1111#include <iostream>
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4941 r4942  
    55 */
    66
    7 #include <include/simd-lib/bitblock.hpp>
    87#include <stdexcept>
    98#include <pablo/carry_data.h>
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_automultiplexing.cpp

    r4937 r4942  
    11#include "pablo_automultiplexing.hpp"
    2 #include <include/simd-lib/builtins.hpp>
    32#include <pablo/builder.hpp>
    43#include <pablo/function.h>
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4939 r4942  
    1313#include <re/re_name.h>
    1414#include <stdexcept>
    15 #include <include/simd-lib/bitblock.hpp>
    1615#include <sstream>
    1716#include <IDISA/idisa_builder.h>
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r4939 r4942  
    344344}
    345345
    346 extern "C" {
    347   void wrapped_print_register(char * regName, BitBlock bit_block) {
    348       print_register<BitBlock>(regName, bit_block);
    349   }
    350 }
     346// extern "C" {
     347//   void wrapped_print_register(char * regName, BitBlock bit_block) {
     348//       print_register<BitBlock>(regName, bit_block);
     349//   }
     350// }
    351351
    352352void icgrep_Linking(Module * m, ExecutionEngine * e) {
     
    358358        if (fnName == "process_block_initialize_carries") continue;
    359359       
    360         if (fnName == "wrapped_print_register") {
    361             e->addGlobalMapping(cast<GlobalValue>(it), (void *)&wrapped_print_register);
    362         }
     360        // if (fnName == "wrapped_print_register") {
     361        //     e->addGlobalMapping(cast<GlobalValue>(it), (void *)&wrapped_print_register);
     362        // }
    363363        if (fnName == "wrapped_report_match") {
    364364            e->addGlobalMapping(cast<GlobalValue>(it), (void *)&wrapped_report_match);
Note: See TracChangeset for help on using the changeset viewer.