Changeset 4088


Ignore:
Timestamp:
Aug 28, 2014, 4:08:00 PM (4 years ago)
Author:
linmengl
Message:

migrate to LLVM 3.5 API. define USE_LLVM_3_5 in llvm_gen.h to compile with LLVM 3.5; otherwise define USE_LLVM_3_4 to continue using LLVM 3.4

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r4086 r4088  
    430430
    431431    //Create a verifier.  The verifier will print an error message if our module is malformed in any way.
     432#ifdef USE_LLVM_3_5
     433    verifyModule(*mMod, &dbgs());
     434#endif
     435
     436#ifdef USE_LLVM_3_4
    432437    verifyModule(*mMod, PrintMessageAction);
     438#endif
    433439
    434440    //Un-comment this line in order to display the IR that has been generated by this module.
     
    440446    FunctionPassManager fpm(mMod);
    441447
     448#ifdef USE_LLVM_3_5
     449    mMod->setDataLayout(mExecutionEngine->getDataLayout());
    442450    // Set up the optimizer pipeline.  Start with registering info about how the target lays out data structures.
     451    fpm.add(new DataLayoutPass(mMod));
     452#endif
     453
     454#ifdef USE_LLVM_3_4
    443455    fpm.add(new DataLayout(*mExecutionEngine->getDataLayout()));
     456#endif
    444457
    445458    fpm.add(createPromoteMemoryToRegisterPass()); //Transform to SSA form.
     
    774787{
    775788    mMod = new Module("icgrep", getGlobalContext());
    776     mMod->setDataLayout("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128");
    777     mMod->setTargetTriple("x86_64-unknown-linux-gnu");
     789
     790#ifdef USE_LLVM_3_4
     791    mMod->setDataLayout("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128");
     792    mMod->setTargetTriple("i386-pc-linux-gnu");
     793#endif
    778794}
    779795
     
    793809
    794810    if (mMarkerMap.find(name) == mMarkerMap.end())
    795     {       
     811    {
    796812        Value* ptr = b.CreateAlloca(m64x2Vect);
    797813        Value* void_1 = b.CreateStore(mConst_Aggregate_64x2_0, ptr);
     
    834850    {
    835851        IRBuilder<> b(mBasicBlock);
    836        
     852
    837853        b.CreateStore(Generate_PabloE(assign->getExpr()), GetMarker(assign->getM()));
    838        
     854
    839855        retVal = assign->getM();
    840856    }
     
    844860        BasicBlock*  ifBodyBlock = BasicBlock::Create(mMod->getContext(), "if.body",mFunc_process_block, 0);
    845861        BasicBlock*  ifEndBlock = BasicBlock::Create(mMod->getContext(), "if.end",mFunc_process_block, 0);
    846        
     862
    847863        int if_start_idx = mCarryQueueIdx;
    848        
     864
    849865        Value* if_test_value = Generate_PabloE(ifstmt->getExpr());
    850866
    851867        /* Generate the statements into the if body block, and also determine the
    852868           final carry index.  */
    853        
     869
    854870        IRBuilder<> b_ifbody(ifBodyBlock);
    855871        mBasicBlock = ifBodyBlock;
    856872        std::string returnMarker = Generate_PabloStatements(ifstmt->getPSList());
    857873        int if_end_idx = mCarryQueueIdx;
    858        
     874
    859875        if (if_start_idx < if_end_idx + 1) {
    860876            // Have at least two internal carries.   Accumulate and store.
    861877            int if_accum_idx = mCarryQueueIdx;
    862878            mCarryQueueIdx++;
    863            
     879
    864880            Value* if_carry_accum_value = genCarryInLoad(mptr_carry_q, if_start_idx);
    865            
     881
    866882            for (int c = if_start_idx+1; c < if_end_idx; c++)
    867883            {
     
    870886            }
    871887            Value* void_1 = genCarryOutStore(if_carry_accum_value, mptr_carry_q, if_accum_idx);
    872            
     888
    873889        }
    874890        b_ifbody.CreateBr(ifEndBlock);
    875        
     891
    876892        IRBuilder<> b_entry(ifEntryBlock);
    877893        mBasicBlock = ifEntryBlock;
     
    883899        }
    884900        b_entry.CreateCondBr(genBitBlockAny(if_test_value), ifEndBlock, ifBodyBlock);
    885        
     901
    886902        mBasicBlock = ifEndBlock;
    887903
     
    10441060        int this_carry_idx = mCarryQueueIdx;
    10451061        mCarryQueueIdx++;
    1046        
     1062
    10471063        Value* carryq_value = genCarryInLoad(mptr_carry_q, this_carry_idx);
    10481064
     
    10991115Value* LLVM_Generator::genAddWithCarry(Value* e1, Value* e2) {
    11001116    IRBuilder<> b(mBasicBlock);
    1101    
     1117
    11021118    //CarryQ - carry in.
    11031119    int this_carry_idx = mCarryQueueIdx;
    11041120    mCarryQueueIdx++;
    1105    
     1121
    11061122    Value* carryq_value = genCarryInLoad(mptr_carry_q, this_carry_idx);
    11071123
     
    11101126    Value* digitsum = b.CreateAdd(e1, e2, "digitsum");
    11111127    Value* partial = b.CreateAdd(digitsum, carryq_value, "partial");
    1112     Value* digitcarry = b.CreateOr(carrygen, b.CreateAnd(carryprop, genNot(partial)));   
     1128    Value* digitcarry = b.CreateOr(carrygen, b.CreateAnd(carryprop, genNot(partial)));
    11131129    Value* mid_carry_in = genShiftLeft64(b.CreateLShr(digitcarry, 63), "mid_carry_in");
    11141130
    11151131    Value* sum = b.CreateAdd(partial, mid_carry_in, "sum");
    11161132    Value* carry_out = genShiftRight127(b.CreateOr(carrygen, b.CreateAnd(carryprop, genNot(sum))), "carry_out");
    1117    
    1118     //CarryQ - carry out:   
     1133
     1134    //CarryQ - carry out:
    11191135    Value* void_1 = genCarryOutStore(carry_out, mptr_carry_q, this_carry_idx);
    1120    
     1136
    11211137    return sum;
    11221138}
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r4085 r4088  
    77#ifndef LLVM_GENERATOR_H
    88#define LLVM_GENERATOR_H
     9
     10#define USE_LLVM_3_5
    911
    1012//Regular Expressions
     
    5557#include <algorithm>
    5658
    57 #include <llvm/Support/raw_ostream.h>
     59#include "llvm/Support/raw_ostream.h"
    5860
    59 #include <llvm/Pass.h>
    60 #include <llvm/PassManager.h>
    61 #include <llvm/ADT/SmallVector.h>
    62 #include <llvm/Analysis/Verifier.h>
     61#ifdef USE_LLVM_3_4
     62#include "llvm/Analysis/Verifier.h"
     63#endif
     64
     65#ifdef USE_LLVM_3_5
     66#include "llvm/IR/Verifier.h"
     67#endif
     68
     69#include "llvm/Pass.h"
     70#include "llvm/PassManager.h"
     71#include "llvm/ADT/SmallVector.h"
    6372#include "llvm/Analysis/Passes.h"
    64 #include <llvm/Assembly/PrintModulePass.h>
    65 #include <llvm/IR/BasicBlock.h>
    66 #include <llvm/IR/CallingConv.h>
    67 #include <llvm/IR/Constants.h>
     73#include "llvm/Assembly/PrintModulePass.h"
     74#include "llvm/IR/BasicBlock.h"
     75#include "llvm/IR/CallingConv.h"
     76#include "llvm/IR/Constants.h"
    6877#include "llvm/IR/DataLayout.h"
    6978#include "llvm/IR/DerivedTypes.h"
    70 #include <llvm/IR/Function.h>
    71 #include <llvm/IR/GlobalVariable.h>
    72 #include <llvm/IR/InlineAsm.h>
    73 #include <llvm/IR/Instructions.h>
    74 #include <llvm/IR/LLVMContext.h>
    75 #include <llvm/IR/Module.h>
    76 #include <llvm/Support/FormattedStream.h>
    77 #include <llvm/Support/MathExtras.h>
    78 #include <llvm/Support/Casting.h>
     79#include "llvm/IR/Function.h"
     80#include "llvm/IR/GlobalVariable.h"
     81#include "llvm/IR/InlineAsm.h"
     82#include "llvm/IR/Instructions.h"
     83#include "llvm/IR/LLVMContext.h"
     84#include "llvm/IR/Module.h"
     85#include "llvm/Support/FormattedStream.h"
     86#include "llvm/Support/MathExtras.h"
     87#include "llvm/Support/Casting.h"
     88#include "llvm/Support/Debug.h"
    7989
    8090#include "llvm/Support/TargetSelect.h"
    8191#include "llvm/Transforms/Scalar.h"
    8292
    83 #include <llvm/ExecutionEngine/ExecutionEngine.h>
    84 #include <llvm/ExecutionEngine/MCJIT.h>
     93#include "llvm/ExecutionEngine/ExecutionEngine.h"
     94#include "llvm/ExecutionEngine/MCJIT.h"
    8595
    86 #include <llvm/Linker.h>
    87 #include <llvm/IRReader/IRReader.h>
    88 #include <llvm/Bitcode/ReaderWriter.h>
    89 #include <llvm/Support/MemoryBuffer.h>
     96#include "llvm/Linker.h"
     97#include "llvm/IRReader/IRReader.h"
     98#include "llvm/Bitcode/ReaderWriter.h"
     99#include "llvm/Support/MemoryBuffer.h"
    90100
    91 #include <llvm/IR/IRBuilder.h>
     101#include "llvm/IR/IRBuilder.h"
    92102
    93103#include <simd-lib/bitblock.hpp>
Note: See TracChangeset for help on using the changeset viewer.