Changeset 4227 for icGREP


Ignore:
Timestamp:
Oct 9, 2014, 10:52:36 AM (5 years ago)
Author:
nmedfort
Message:

Corrected some uninitialized value usage; -Wall reports hundreds in unicode_categories.h; these were not fixed.

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

Legend:

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

    r4220 r4227  
    110110ENDIF()
    111111
     112#Enable all warnings
     113#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
    112114
    113115#Check compiler and system architecture support for SSE or AVX
  • icGREP/icgrep-devel/icgrep/compiler.cpp

    r4220 r4227  
    2525//#include "pbix_counter.h"
    2626
    27 // #define DEBUG_PRINT_RE_AST
    28 // #define DEBUG_PRINT_PBIX_AST
     27//#define DEBUG_PRINT_RE_AST
     28//#define DEBUG_PRINT_PBIX_AST
    2929
    3030#ifdef DEBUG_PRINT_RE_AST
    31 #include "printer_re.h"
     31#include <re/printer_re.h>
    3232#endif
    3333#ifdef DEBUG_PRINT_PBIX_AST
    34 #include "printer_pablos.h"
     34#include <pablo/printer_pablos.h>
    3535#endif
    3636
     
    132132    #ifdef DEBUG_PRINT_PBIX_AST
    133133    //Print to the terminal the AST that was generated by the character class compiler.
    134     std::cerr << "Pablo CC AST:" << std::endl << StatementPrinter::Print_CC_PabloStmts(cg.expressions()) << std::endl;
    135     //Print to the terminal the AST that was generated for the re subexpressions.
    136     std::cerr << "Subexpressions:" << StatementPrinter::PrintStmts(cg) << std::endl;
     134    std::cerr << "Pablo CC AST:" << std::endl << StatementPrinter::Print_CC_PabloStmts(main.expressions()) << std::endl;
    137135    #endif
    138136
     
    141139    #ifdef DEBUG_PRINT_PBIX_AST
    142140    //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    143     std::cerr << "Final Pablo AST:" << StatementPrinter::PrintStmts(cg) << ")" << std::endl;
    144     //Print a count of the Pablo statements and expressions that are contained in the AST from the pbix compiler.
    145     // std::cerr << "Pablo Statement Count: " << Pbix_Counter::Count_PabloStatements(re_cg_state.stmtsl) << std::endl;
     141    std::cerr << "Final Pablo AST:" << StatementPrinter::Print_CC_PabloStmts(main.expressions()) << ")" << std::endl;
    146142    #endif
    147143
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r4220 r4227  
    88//Pablo Expressions
    99#include <pablo/codegenstate.h>
     10#include <stdexcept>
    1011
    1112using namespace pablo;
     
    6263
    6364PabloCompiler::PabloCompiler(std::map<std::string, std::string> name_map, std::string basis_pattern, int bits)
    64 : m_name_map(name_map)
     65: mBits(bits)
     66, m_name_map(name_map)
    6567, mBasisBitPattern(basis_pattern)
    66 , mBits(bits)
    67 {
    68 
     68, mMod(new Module("icgrep", getGlobalContext()))
     69, mBasicBlock(nullptr)
     70, mExecutionEngine(nullptr)
     71, mXi64Vect(nullptr)
     72, mXi128Vect(nullptr)
     73, mBasisBitsInputPtr(nullptr)
     74, mOutputPtr(nullptr)
     75, mCarryQueueIdx(0)
     76, mptr_carry_q(nullptr)
     77, mCarryQueueSize(0)
     78, mConst_int64_neg1(nullptr)
     79, mConst_Aggregate_Xi64_0(nullptr)
     80, mConst_Aggregate_Xi64_neg1(nullptr)
     81, mFuncTy_0(nullptr)
     82, mFunc_process_block(nullptr)
     83, mBasisBitsAddr(nullptr)
     84, mPtr_carry_q_addr(nullptr)
     85, mPtr_output_addr(nullptr)
     86{
     87    //Create the jit execution engine.up
     88    InitializeNativeTarget();
     89    std::string ErrStr;
     90
     91    mExecutionEngine = EngineBuilder(mMod).setUseMCJIT(true).setErrorStr(&ErrStr).setOptLevel(CodeGenOpt::Level::Less).create();
     92    if (mExecutionEngine == nullptr) {
     93        throw std::runtime_error("\nCould not create ExecutionEngine: " + ErrStr);
     94    }
     95
     96    InitializeNativeTargetAsmPrinter();
     97    InitializeNativeTargetAsmParser();
     98
     99    DefineTypes();
     100    DeclareFunctions();
    69101}
    70102
     
    107139LLVM_Gen_RetVal PabloCompiler::compile(const PabloBlock & cg_state)
    108140{
    109     //Create the module.
    110     MakeLLVMModule();
    111 
    112     //Create the jit execution engine.up
    113     InitializeNativeTarget();
    114     std::string ErrStr;
    115 
    116     mExecutionEngine = EngineBuilder(mMod).setUseMCJIT(true).setErrorStr(&ErrStr).setOptLevel(CodeGenOpt::Level::Less).create();
    117     if (!mExecutionEngine)
    118     {
    119         std::cout << "\nCould not create ExecutionEngine: " + ErrStr << std::endl;
    120         exit(1);
    121     }
    122 
    123     InitializeNativeTargetAsmPrinter();
    124     InitializeNativeTargetAsmParser();
    125 
    126     DefineTypes();
    127     DeclareFunctions();
     141    mCarryQueueSize = 0;
    128142    DeclareCallFunctions(cg_state.expressions());
    129143
     
    158172    SetReturnMarker(GetMarker(m_name_map.find("LineFeed")->second), 1);
    159173
    160     mCarryQueueSize = mCarryQueueIdx;
     174    assert (mCarryQueueIdx == mCarryQueueSize);
    161175
    162176    //Terminate the block
     
    218232    mXi64Vect = VectorType::get(IntegerType::get(mMod->getContext(), 64), BLOCK_SIZE / 64);
    219233    mXi128Vect = VectorType::get(IntegerType::get(mMod->getContext(), 128), BLOCK_SIZE / 128);
    220     //A pointer to the BitBlock vector.
    221     mXi64Vect_Ptr1 = PointerType::get(mXi64Vect, 0);
    222234
    223235    //Constant definitions.
    224     mConst_int64_neg1 = ConstantInt::get(mMod->getContext(), APInt(64, StringRef("-1"), 10));
    225 
     236    mConst_int64_neg1 = ConstantInt::get(mMod->getContext(), APInt(64, -1));
    226237    mConst_Aggregate_Xi64_0 = ConstantAggregateZero::get(mXi64Vect);
    227238
     
    233244
    234245
    235     StructType *StructTy_struct_Basis_bits = mMod->getTypeByName("struct.Basis_bits");
    236     if (!StructTy_struct_Basis_bits) {
     246    StructType * StructTy_struct_Basis_bits = mMod->getTypeByName("struct.Basis_bits");
     247    if (StructTy_struct_Basis_bits == nullptr) {
    237248        StructTy_struct_Basis_bits = StructType::create(mMod->getContext(), "struct.Basis_bits");
    238249    }
     
    242253        StructTy_struct_Basis_bits_fields.push_back(mXi64Vect);
    243254    }
     255
     256
     257
     258
    244259    if (StructTy_struct_Basis_bits->isOpaque()) {
    245260        StructTy_struct_Basis_bits->setBody(StructTy_struct_Basis_bits_fields, /*isPacked=*/false);
    246261    }
    247 
    248262    mBasisBitsInputPtr = PointerType::get(StructTy_struct_Basis_bits, 0);
    249263
     
    252266
    253267    //The carry q array.
    254     FuncTy_0_args.push_back(mXi64Vect_Ptr1);
     268    //A pointer to the BitBlock vector.
     269    FuncTy_0_args.push_back(PointerType::get(mXi64Vect, 0));
    255270
    256271    //The output structure.
     
    383398void PabloCompiler::DeclareCallFunctions(const PabloE * expr)
    384399{
    385     if (const Call * pablo_call = dyn_cast<const Call>(expr))
    386     {
     400    if (const Call * pablo_call = dyn_cast<const Call>(expr)) {
    387401        const std::string callee = pablo_call->getCallee();
    388         if (mCalleeMap.find(callee) == mCalleeMap.end())
    389         {
     402        if (mCalleeMap.find(callee) == mCalleeMap.end()) {
    390403            void * callee_ptr = nullptr;
    391404            #define CHECK_GENERAL_CODE_CATEGORY(SUFFIX) \
     
    422435            CHECK_GENERAL_CODE_CATEGORY(Zl)
    423436            CHECK_GENERAL_CODE_CATEGORY(Zp)
    424             CHECK_GENERAL_CODE_CATEGORY(Zs) {};
     437            CHECK_GENERAL_CODE_CATEGORY(Zs)
     438            // OTHERWISE ...
     439            throw std::runtime_error("Unknown unicode category \"" + callee + "\"");
    425440            #undef CHECK_GENERAL_CODE_CATEGORY
    426             if (callee_ptr == nullptr) {
    427                 throw std::runtime_error("Unknown unicode category \"" + callee + "\"");
    428             }
    429441            Value * get_unicode_category = mMod->getOrInsertFunction("__get_category_" + callee, mXi64Vect, mBasisBitsInputPtr, NULL);
    430442            if (get_unicode_category == nullptr) {
     
    474486}
    475487
    476 void PabloCompiler::MakeLLVMModule()
    477 {
    478     mMod = new Module("icgrep", getGlobalContext());
    479 
    480 }
    481 
    482488Value* PabloCompiler::GetMarker(const std::string & name)
    483489{
     
    545551        if (if_start_idx < if_end_idx + 1) {
    546552            // Have at least two internal carries.   Accumulate and store.
    547             int if_accum_idx = mCarryQueueIdx;
    548             mCarryQueueIdx++;
     553            int if_accum_idx = mCarryQueueIdx++;
    549554
    550555            Value* if_carry_accum_value = genCarryInLoad(mptr_carry_q, if_start_idx);
     
    603608        //Create and initialize a new carry queue.
    604609        Value * ptr_while_carry_q = b_wb1.CreateAlloca(mXi64Vect, b_wb1.getInt64(mCarryQueueSize - idx));
    605         for (int i=0; i < (mCarryQueueSize - idx); i++) {
     610        for (int i = 0; i < (mCarryQueueSize - idx); i++) {
    606611            genCarryOutStore(mConst_Aggregate_Xi64_0, ptr_while_carry_q, i);
    607612        }
     
    704709        retVal = b.CreateAnd(genAddWithCarry(marker_expr, cc_expr), genNot(cc_expr), "scanthru_rslt");
    705710    }
    706     expr->setCompiledValue(retVal);
    707711    return retVal;
    708712}
     
    850854    return genAddWithCarry(strm_value, strm_value);
    851855#endif
    852 }
     856
     857}
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r4220 r4227  
    9191    LLVM_Gen_RetVal compile(const PabloBlock & cg_state);
    9292private:
    93     void MakeLLVMModule();
     93    Module * MakeLLVMModule();
    9494    void DefineTypes();
    9595    void DeclareFunctions();
     
    116116    SumWithOverflowPack callUaddOverflow(Value *e1, Value *e2);
    117117
     118    std::map<std::string, Value*>       mCalleeMap;
     119    std::map<std::string, Value*>       mMarkerMap;
     120
     121
    118122    int                                 mBits;
    119123    std::map<std::string, std::string>  m_name_map;
    120124    std::string                         mBasisBitPattern;
     125
     126
     127
    121128    Module*                             mMod;
    122129    BasicBlock*                         mBasicBlock;
     
    124131
    125132    VectorType*                         mXi64Vect;
    126     PointerType*                        mXi64Vect_Ptr1;
    127133
    128134    VectorType*                         mXi128Vect;
     
    130136    PointerType*                        mBasisBitsInputPtr;
    131137    PointerType*                        mOutputPtr;
    132 
    133     std::map<std::string, Value*>       mCalleeMap;
    134     std::map<std::string, Value*>       mMarkerMap;
    135138
    136139    int                                 mCarryQueueIdx;
     
    145148    FunctionType*                       mFuncTy_0;
    146149    Function*                           mFunc_process_block;
    147     Function*                           mFunc_llvm_uadd_with_overflow;
    148150
    149     Constant*                           mFunc_print_register;
    150     Constant*                           mFunc_test_getCategory;
    151     Constant*                           mFunc_get_unicode_category;
    152     Value*                              mFunc_get_unicode_category_Nd;
    153151
    154152    AllocaInst*                         mBasisBitsAddr;
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r4220 r4227  
    2727#include <pablo/ps_while.h>
    2828#include <pablo/symbol_generator.h>
    29 #include <unordered_map>
     29#include <map>
    3030#include <vector>
    3131#include <string>
     
    3535namespace pablo {
    3636
    37 struct PabloBlock {
     37class PabloBlock {
     38public:
    3839
    3940    PabloBlock(SymbolGenerator & symgen)
  • icGREP/icgrep-devel/icgrep/pablo/pe_advance.h

    r4220 r4227  
    1313
    1414class Advance : public PabloE {
    15     friend struct PabloBlock;
     15    friend class PabloBlock;
    1616public:
    1717    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_all.h

    r4220 r4227  
    1313
    1414class All : public PabloE {
    15     friend struct PabloBlock;
     15    friend class PabloBlock;
    1616public:
    1717    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_and.h

    r4220 r4227  
    1212namespace pablo {
    1313
    14 struct PabloBlock;
     14class PabloBlock;
    1515
    1616class And : public PabloE {
    1717    friend struct OptimizeAnd;
    18     friend struct PabloBlock;
     18    friend class PabloBlock;
    1919public:
    2020    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_call.h

    r4220 r4227  
    88
    99class Call : public PabloE {
    10     friend struct PabloBlock;
     10    friend class PabloBlock;
    1111public:
    1212    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_charclass.h

    r4220 r4227  
    1414
    1515class CharClass : public PabloE {
    16     friend struct PabloBlock;
     16    friend class PabloBlock;
    1717public:
    1818    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_matchstar.h

    r4220 r4227  
    1313
    1414class MatchStar : public PabloE {
    15     friend struct PabloBlock;
     15    friend class PabloBlock;
    1616public:
    1717    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_not.h

    r4220 r4227  
    1212namespace pablo {
    1313
    14 struct PabloBlock;
     14class PabloBlock;
    1515
    1616class Not : public PabloE {
    1717    friend struct OptimizeNot;
    18     friend struct PabloBlock;
     18    friend class PabloBlock;
    1919public:
    2020    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_or.h

    r4220 r4227  
    1212namespace pablo {
    1313
    14 struct PabloBlock;
     14class PabloBlock;
    1515
    1616class Or : public PabloE {
    1717    friend struct OptimizeOr;
    18     friend struct PabloBlock;
     18    friend class PabloBlock;
    1919public:
    2020    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_pabloe.h

    r4220 r4227  
    4040    }
    4141    virtual ~PabloE() = 0;
    42 
    43     inline Value * getCompiledValue() const {
    44         return mCompiledValue;
    45     }
    46 
    47     inline void setCompiledValue(Value * value) {
    48         mCompiledValue = value;
    49     }
    5042protected:
    5143    inline PabloE(const ClassTypeId id)
    52     : mClassTypeId(id)
    53     , mCompiledValue(nullptr) {
     44    : mClassTypeId(id) {
    5445
    5546    }
    5647private:
    5748    const ClassTypeId   mClassTypeId;
    58     Value *             mCompiledValue;
    5949};
    6050
  • icGREP/icgrep-devel/icgrep/pablo/pe_scanthru.h

    r4220 r4227  
    1313
    1414class ScanThru : public  PabloE {
    15     friend struct PabloBlock;
     15    friend class PabloBlock;
    1616public:
    1717    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_sel.h

    r4220 r4227  
    1212namespace pablo {
    1313
    14 struct PabloBlock;
     14class PabloBlock;
    1515
    1616class Sel : public PabloE {
    1717    friend struct OptimizeSel;
    18     friend struct PabloBlock;
     18    friend class PabloBlock;
    1919public:
    2020    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_var.h

    r4220 r4227  
    1515
    1616class Var : public PabloE {
    17     friend struct PabloBlock;
     17    friend class PabloBlock;
    1818public:
    1919    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/pe_xor.h

    r4220 r4227  
    1212namespace pablo {
    1313
    14 struct PabloBlock;
     14class PabloBlock;
    1515
    1616class Xor : public PabloE {
    1717    friend struct OptimizeXor;
    18     friend struct PabloBlock;
     18    friend class PabloBlock;
    1919public:
    2020    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/ps_assign.h

    r4220 r4227  
    1414
    1515class Assign : public PabloE {
    16     friend struct PabloBlock;
     16    friend class PabloBlock;
    1717public:
    1818    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.h

    r4220 r4227  
    1313
    1414class If : public PabloE {
    15     friend struct PabloBlock;
     15    friend class PabloBlock;
    1616public:
    1717    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/ps_while.h

    r4220 r4227  
    1313
    1414class While : public PabloE {
    15     friend struct PabloBlock;
     15    friend class PabloBlock;
    1616public:
    1717    static inline bool classof(const PabloE * e) {
  • icGREP/icgrep-devel/icgrep/pablo/symbol_generator.h

    r4214 r4227  
    99
    1010#include <string>
    11 #include <map>
    1211#include <unordered_map>
    1312
     
    2625
    2726private:
    28     std::map<std::string, unsigned>             mPrefixMap;
     27    std::unordered_map<std::string, unsigned>   mPrefixMap;
    2928    std::unordered_map<std::string, String *>   mStringMap;
    3029};
Note: See TracChangeset for help on using the changeset viewer.