Ignore:
Timestamp:
May 10, 2017, 4:26:11 PM (2 years ago)
Author:
nmedfort
Message:

Large refactoring step. Removed IR generation code from Kernel (formally KernelBuilder?) and moved it into the new KernelBuilder? class.

Location:
icGREP/icgrep-devel/icgrep/IR_Gen
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.cpp

    r5436 r5440  
    1818
    1919Value * CBuilder::CreateOpenCall(Value * filename, Value * oflag, Value * mode) {
    20     Function * openFn = mMod->getFunction("open");
     20    Module * const m = getModule();
     21    Function * openFn = m->getFunction("open");
    2122    if (openFn == nullptr) {
    2223        IntegerType * int32Ty = getInt32Ty();
    2324        PointerType * int8PtrTy = getInt8PtrTy();
    24         openFn = cast<Function>(mMod->getOrInsertFunction("open",
     25        openFn = cast<Function>(m->getOrInsertFunction("open",
    2526                                                         int32Ty, int8PtrTy, int32Ty, int32Ty, nullptr));
    2627    }
     
    3132Value * CBuilder::CreateWriteCall(Value * fileDescriptor, Value * buf, Value * nbyte) {
    3233    PointerType * voidPtrTy = getVoidPtrTy();
    33     Function * write = mMod->getFunction("write");
     34    Module * const m = getModule();
     35    Function * write = m->getFunction("write");
    3436    if (write == nullptr) {
    3537        IntegerType * sizeTy = getSizeTy();
    3638        IntegerType * int32Ty = getInt32Ty();
    37         write = cast<Function>(mMod->getOrInsertFunction("write",
     39        write = cast<Function>(m->getOrInsertFunction("write",
    3840                                                        AttributeSet().addAttribute(getContext(), 2U, Attribute::NoAlias),
    3941                                                        sizeTy, int32Ty, voidPtrTy, sizeTy, nullptr));
     
    4547Value * CBuilder::CreateReadCall(Value * fileDescriptor, Value * buf, Value * nbyte) {
    4648    PointerType * voidPtrTy = getVoidPtrTy();
    47     Function * readFn = mMod->getFunction("read");
     49    Module * const m = getModule();
     50    Function * readFn = m->getFunction("read");
    4851    if (readFn == nullptr) {
    4952        IntegerType * sizeTy = getSizeTy();
    5053        IntegerType * int32Ty = getInt32Ty();
    51         readFn = cast<Function>(mMod->getOrInsertFunction("read",
     54        readFn = cast<Function>(m->getOrInsertFunction("read",
    5255                                                         AttributeSet().addAttribute(getContext(), 2U, Attribute::NoAlias),
    5356                                                         sizeTy, int32Ty, voidPtrTy, sizeTy, nullptr));
     
    5861
    5962Value * CBuilder::CreateCloseCall(Value * fileDescriptor) {
    60     Function * closeFn = mMod->getFunction("close");
     63    Module * const m = getModule();
     64    Function * closeFn = m->getFunction("close");
    6165    if (closeFn == nullptr) {
    6266        IntegerType * int32Ty = getInt32Ty();
    6367        FunctionType * fty = FunctionType::get(int32Ty, {int32Ty}, true);
    64         closeFn = Function::Create(fty, Function::ExternalLinkage, "close", mMod);
     68        closeFn = Function::Create(fty, Function::ExternalLinkage, "close", m);
    6569    }
    6670    return CreateCall(closeFn, fileDescriptor);
     
    6973
    7074Value * CBuilder::CreateUnlinkCall(Value * path) {
    71     Function * unlinkFunc = mMod->getFunction("unlink");
     75    Module * const m = getModule();
     76    Function * unlinkFunc = m->getFunction("unlink");
    7277    if (unlinkFunc == nullptr) {
    7378        FunctionType * fty = FunctionType::get(getInt32Ty(), {getInt8PtrTy()}, false);
    74         unlinkFunc = Function::Create(fty, Function::ExternalLinkage, "unlink", mMod);
     79        unlinkFunc = Function::Create(fty, Function::ExternalLinkage, "unlink", m);
    7580        unlinkFunc->setCallingConv(CallingConv::C);
    7681    }
     
    7984
    8085Value * CBuilder::CreateMkstempCall(Value * ftemplate) {
    81     Function * mkstempFn = mMod->getFunction("mkstemp");
     86    Module * const m = getModule();
     87    Function * mkstempFn = m->getFunction("mkstemp");
    8288    if (mkstempFn == nullptr) {
    83         mkstempFn = cast<Function>(mMod->getOrInsertFunction("mkstemp", getInt32Ty(), getInt8PtrTy(), nullptr));
     89        mkstempFn = cast<Function>(m->getOrInsertFunction("mkstemp", getInt32Ty(), getInt8PtrTy(), nullptr));
    8490    }
    8591    return CreateCall(mkstempFn, ftemplate);
     
    8894
    8995Value * CBuilder::CreateStrlenCall(Value * str) {
    90     Function * strlenFn = mMod->getFunction("strlen");
     96    Module * const m = getModule();
     97    Function * strlenFn = m->getFunction("strlen");
    9198    if (strlenFn == nullptr) {
    92         strlenFn = cast<Function>(mMod->getOrInsertFunction("strlen", getSizeTy(), getInt8PtrTy(), nullptr));
     99        strlenFn = cast<Function>(m->getOrInsertFunction("strlen", getSizeTy(), getInt8PtrTy(), nullptr));
    93100    }
    94101    return CreateCall(strlenFn, str);
     
    97104
    98105Function * CBuilder::GetPrintf() {
    99     Function * printf = mMod->getFunction("printf");
     106    Module * const m = getModule();
     107    Function * printf = m->getFunction("printf");
    100108    if (printf == nullptr) {
    101109        FunctionType * fty = FunctionType::get(getInt32Ty(), {getInt8PtrTy()}, true);
    102         printf = Function::Create(fty, Function::ExternalLinkage, "printf", mMod);
     110        printf = Function::Create(fty, Function::ExternalLinkage, "printf", m);
    103111        printf->addAttribute(1, Attribute::NoAlias);
    104112    }
     
    107115
    108116Function * CBuilder::GetDprintf() {
    109     Function * dprintf = mMod->getFunction("dprintf");
     117    Module * const m = getModule();
     118    Function * dprintf = m->getFunction("dprintf");
    110119    if (dprintf == nullptr) {
    111120        FunctionType * fty = FunctionType::get(getInt32Ty(), {getInt32Ty(), getInt8PtrTy()}, true);
    112         dprintf = Function::Create(fty, Function::ExternalLinkage, "dprintf", mMod);
     121        dprintf = Function::Create(fty, Function::ExternalLinkage, "dprintf", m);
    113122    }
    114123    return dprintf;
     
    116125
    117126void CBuilder::CallPrintInt(const std::string & name, Value * const value) {
    118     Constant * printRegister = mMod->getFunction("PrintInt");
     127    Module * const m = getModule();
     128    Constant * printRegister = m->getFunction("PrintInt");
    119129    IntegerType * int64Ty = getInt64Ty();
    120130    if (LLVM_UNLIKELY(printRegister == nullptr)) {
    121131        FunctionType *FT = FunctionType::get(getVoidTy(), { getInt8PtrTy(), int64Ty }, false);
    122         Function * function = Function::Create(FT, Function::InternalLinkage, "PrintInt", mMod);
     132        Function * function = Function::Create(FT, Function::InternalLinkage, "PrintInt", m);
    123133        auto arg = function->arg_begin();
    124134        std::string out = "%-40s = %" PRIx64 "\n";
     
    149159
    150160void CBuilder::CallPrintIntToStderr(const std::string & name, Value * const value) {
    151     Constant * printRegister = mMod->getFunction("PrintIntToStderr");
     161    Module * const m = getModule();
     162    Constant * printRegister = m->getFunction("PrintIntToStderr");
    152163    if (LLVM_UNLIKELY(printRegister == nullptr)) {
    153164        FunctionType *FT = FunctionType::get(getVoidTy(), { PointerType::get(getInt8Ty(), 0), getSizeTy() }, false);
    154         Function * function = Function::Create(FT, Function::InternalLinkage, "PrintIntToStderr", mMod);
     165        Function * function = Function::Create(FT, Function::InternalLinkage, "PrintIntToStderr", m);
    155166        auto arg = function->arg_begin();
    156167        std::string out = "%-40s = %" PRIx64 "\n";
     
    182193
    183194void CBuilder::CallPrintMsgToStderr(const std::string & message) {
    184     Constant * printMsg = mMod->getFunction("PrintMsgToStderr");
     195    Module * const m = getModule();
     196    Constant * printMsg = m->getFunction("PrintMsgToStderr");
    185197    if (LLVM_UNLIKELY(printMsg == nullptr)) {
    186198        FunctionType *FT = FunctionType::get(getVoidTy(), { PointerType::get(getInt8Ty(), 0) }, false);
    187         Function * function = Function::Create(FT, Function::InternalLinkage, "PrintMsgToStderr", mMod);
     199        Function * function = Function::Create(FT, Function::InternalLinkage, "PrintMsgToStderr", m);
    188200        auto arg = function->arg_begin();
    189201        std::string out = "%s\n";
     
    219231    if (malloc == nullptr) {
    220232        FunctionType * fty = FunctionType::get(voidPtrTy, {intTy}, false);
    221         malloc = Function::Create(fty, Function::ExternalLinkage, "malloc", mMod);
     233        malloc = Function::Create(fty, Function::ExternalLinkage, "malloc", m);
    222234        malloc->setCallingConv(CallingConv::C);
    223235        malloc->setDoesNotAlias(0);
     
    236248        report_fatal_error("CreateAlignedMalloc: alignment must be a power of 2");
    237249    }
    238     DataLayout DL(mMod);
     250    Module * const m = getModule();
     251    DataLayout DL(m);
    239252    IntegerType * const intTy = getIntPtrTy(DL);
    240     Function * aligned_malloc = mMod->getFunction("aligned_malloc" + std::to_string(alignment));
     253    Function * aligned_malloc = m->getFunction("aligned_malloc" + std::to_string(alignment));
    241254    if (LLVM_UNLIKELY(aligned_malloc == nullptr)) {
    242255        const auto ip = saveIP();
    243256        PointerType * const voidPtrTy = getVoidPtrTy();
    244257        FunctionType * fty = FunctionType::get(voidPtrTy, {intTy}, false);
    245         aligned_malloc = Function::Create(fty, Function::InternalLinkage, "aligned_malloc" + std::to_string(alignment), mMod);
     258        aligned_malloc = Function::Create(fty, Function::InternalLinkage, "aligned_malloc" + std::to_string(alignment), m);
    246259        aligned_malloc->setCallingConv(CallingConv::C);
    247260        aligned_malloc->setDoesNotAlias(0);
     
    288301
    289302Value * CBuilder::CreateMMap(Value * const addr, Value * size, Value * const prot, Value * const flags, Value * const fd, Value * const offset) {
    290     Function * fMMap = mMod->getFunction("mmap");
     303    Module * const m = getModule();
     304    Function * fMMap = m->getFunction("mmap");
    291305    if (LLVM_UNLIKELY(fMMap == nullptr)) {
    292306        PointerType * const voidPtrTy = getVoidPtrTy();
     
    294308        IntegerType * const sizeTy = getSizeTy();
    295309        FunctionType * fty = FunctionType::get(voidPtrTy, {voidPtrTy, sizeTy, intTy, intTy, intTy, sizeTy}, false);
    296         fMMap = Function::Create(fty, Function::ExternalLinkage, "mmap", mMod);
     310        fMMap = Function::Create(fty, Function::ExternalLinkage, "mmap", m);
    297311    }
    298312    Value * ptr = CreateCall(fMMap, {addr, size, prot, flags, fd, offset});
     
    332346    Value * result = nullptr;
    333347    if (T.isOSLinux() || T.isOSDarwin()) {
     348        Module * const m = getModule();
    334349        IntegerType * const intTy = getInt32Ty();
    335350        IntegerType * const sizeTy = getSizeTy();
    336351        PointerType * const voidPtrTy = getVoidPtrTy();
    337         Function * MAdviseFunc = mMod->getFunction("madvise");
     352        Function * MAdviseFunc = m->getFunction("madvise");
    338353        if (LLVM_UNLIKELY(MAdviseFunc == nullptr)) {
    339354            FunctionType * fty = FunctionType::get(intTy, {voidPtrTy, sizeTy, intTy}, false);
    340             MAdviseFunc = Function::Create(fty, Function::ExternalLinkage, "madvise", mMod);
     355            MAdviseFunc = Function::Create(fty, Function::ExternalLinkage, "madvise", m);
    341356        }
    342357        addr = CreatePointerCast(addr, voidPtrTy);
     
    361376
    362377Value * CBuilder::CheckMMapSuccess(Value * const addr) {
    363     DataLayout DL(mMod);
     378    Module * const m = getModule();
     379    DataLayout DL(m);
    364380    IntegerType * const intTy = getIntPtrTy(DL);
    365381    return CreateICmpNE(CreatePtrToInt(addr, intTy), ConstantInt::getAllOnesValue(intTy)); // MAP_FAILED = -1
     
    374390    Value * ptr = nullptr;
    375391    if (T.isOSLinux()) {
    376         DataLayout DL(mMod);
     392        Module * const m = getModule();
     393        DataLayout DL(m);
    377394        PointerType * const voidPtrTy = getVoidPtrTy();
    378395        IntegerType * const sizeTy = getSizeTy();
    379396        IntegerType * const intTy = getIntPtrTy(DL);
    380         Function * fMRemap = mMod->getFunction("mremap");
     397        Function * fMRemap = m->getFunction("mremap");
    381398        if (LLVM_UNLIKELY(fMRemap == nullptr)) {
    382399            FunctionType * fty = FunctionType::get(voidPtrTy, {voidPtrTy, sizeTy, sizeTy, intTy}, false);
    383             fMRemap = Function::Create(fty, Function::ExternalLinkage, "mremap", mMod);
     400            fMRemap = Function::Create(fty, Function::ExternalLinkage, "mremap", m);
    384401        }
    385402        addr = CreatePointerCast(addr, voidPtrTy);
     
    402419    IntegerType * const sizeTy = getSizeTy();
    403420    PointerType * const voidPtrTy = getVoidPtrTy();
    404     Function * munmapFunc = mMod->getFunction("munmap");
     421    Module * const m = getModule();
     422    Function * munmapFunc = m->getFunction("munmap");
    405423    if (LLVM_UNLIKELY(munmapFunc == nullptr)) {
    406424        FunctionType * const fty = FunctionType::get(sizeTy, {voidPtrTy, sizeTy}, false);
    407         munmapFunc = Function::Create(fty, Function::ExternalLinkage, "munmap", mMod);
     425        munmapFunc = Function::Create(fty, Function::ExternalLinkage, "munmap", m);
    408426    }
    409427    len = CreateZExtOrTrunc(len, sizeTy);
     
    427445    if (free == nullptr) {
    428446        FunctionType * fty = FunctionType::get(getVoidTy(), {voidPtrTy}, false);
    429         free = Function::Create(fty, Function::ExternalLinkage, "free", mMod);
     447        Module * const m = getModule();
     448        free = Function::Create(fty, Function::ExternalLinkage, "free", m);
    430449        free->setCallingConv(CallingConv::C);
    431450    }
     
    464483
    465484Value * CBuilder::CreateRealloc(Value * ptr, Value * size) {
    466     DataLayout DL(getModule());
     485    Module * const m = getModule();
     486    DataLayout DL(m);
    467487    IntegerType * const intTy = getIntPtrTy(DL);
    468488    PointerType * type = cast<PointerType>(ptr->getType());
     
    474494        }
    475495    }
    476     Module * const m = getModule();
    477496    Function * realloc = m->getFunction("realloc");
    478497    if (realloc == nullptr) {
    479498        PointerType * const voidPtrTy = getVoidPtrTy();
    480         FunctionType * fty = FunctionType::get(voidPtrTy, {voidPtrTy, intTy}, false);
    481         realloc = Function::Create(fty, Function::ExternalLinkage, "realloc", mMod);
     499        FunctionType * fty = FunctionType::get(voidPtrTy, {voidPtrTy, intTy}, false);       
     500        realloc = Function::Create(fty, Function::ExternalLinkage, "realloc", m);
    482501        realloc->setCallingConv(CallingConv::C);
    483502        realloc->setDoesNotAlias(1);
     
    517536
    518537Value * CBuilder::CreateFOpenCall(Value * filename, Value * mode) {
    519     Function * fOpenFunc = mMod->getFunction("fopen");
     538    Module * const m = getModule();
     539    Function * fOpenFunc = m->getFunction("fopen");
    520540    if (fOpenFunc == nullptr) {
    521541        FunctionType * fty = FunctionType::get(getFILEptrTy(), {getInt8Ty()->getPointerTo(), getInt8Ty()->getPointerTo()}, false);
    522         fOpenFunc = Function::Create(fty, Function::ExternalLinkage, "fopen", mMod);
     542        fOpenFunc = Function::Create(fty, Function::ExternalLinkage, "fopen", m);
    523543        fOpenFunc->setCallingConv(CallingConv::C);
    524544    }
     
    527547
    528548Value * CBuilder::CreateFReadCall(Value * ptr, Value * size, Value * nitems, Value * stream) {
    529     Function * fReadFunc = mMod->getFunction("fread");
     549    Module * const m = getModule();
     550    Function * fReadFunc = m->getFunction("fread");
    530551    PointerType * const voidPtrTy = getVoidPtrTy();
    531552    if (fReadFunc == nullptr) {
    532553        IntegerType * const sizeTy = getSizeTy();
    533554        FunctionType * fty = FunctionType::get(sizeTy, {voidPtrTy, sizeTy, sizeTy, getFILEptrTy()}, false);
    534         fReadFunc = Function::Create(fty, Function::ExternalLinkage, "fread", mMod);
     555        fReadFunc = Function::Create(fty, Function::ExternalLinkage, "fread", m);
    535556        fReadFunc->setCallingConv(CallingConv::C);
    536557    }
     
    540561
    541562Value * CBuilder::CreateFWriteCall(Value * ptr, Value * size, Value * nitems, Value * stream) {
    542     Function * fWriteFunc = mMod->getFunction("fwrite");
     563    Module * const m = getModule();
     564    Function * fWriteFunc = m->getFunction("fwrite");
    543565    PointerType * const voidPtrTy = getVoidPtrTy();
    544566    if (fWriteFunc == nullptr) {
    545567        IntegerType * const sizeTy = getSizeTy();
    546568        FunctionType * fty = FunctionType::get(sizeTy, {voidPtrTy, sizeTy, sizeTy, getFILEptrTy()}, false);
    547         fWriteFunc = Function::Create(fty, Function::ExternalLinkage, "fwrite", mMod);
     569        fWriteFunc = Function::Create(fty, Function::ExternalLinkage, "fwrite", m);
    548570        fWriteFunc->setCallingConv(CallingConv::C);
    549571    }
     
    553575
    554576Value * CBuilder::CreateFCloseCall(Value * stream) {
    555     Function * fCloseFunc = mMod->getFunction("fclose");
     577    Module * const m = getModule();
     578    Function * fCloseFunc = m->getFunction("fclose");
    556579    if (fCloseFunc == nullptr) {
    557580        FunctionType * fty = FunctionType::get(getInt32Ty(), {getFILEptrTy()}, false);
    558         fCloseFunc = Function::Create(fty, Function::ExternalLinkage, "fclose", mMod);
     581        fCloseFunc = Function::Create(fty, Function::ExternalLinkage, "fclose", m);
    559582        fCloseFunc->setCallingConv(CallingConv::C);
    560583    }
     
    563586
    564587Value * CBuilder::CreateRenameCall(Value * oldName, Value * newName) {
    565     Function * renameFunc = mMod->getFunction("rename");
     588    Module * const m = getModule();
     589    Function * renameFunc = m->getFunction("rename");
    566590    if (renameFunc == nullptr) {
    567591        FunctionType * fty = FunctionType::get(getInt32Ty(), {getInt8PtrTy(), getInt8PtrTy()}, false);
    568         renameFunc = Function::Create(fty, Function::ExternalLinkage, "rename", mMod);
     592        renameFunc = Function::Create(fty, Function::ExternalLinkage, "rename", m);
    569593        renameFunc->setCallingConv(CallingConv::C);
    570594    }
     
    573597
    574598Value * CBuilder::CreateRemoveCall(Value * path) {
    575     Function * removeFunc = mMod->getFunction("remove");
     599    Module * const m = getModule();
     600    Function * removeFunc = m->getFunction("remove");
    576601    if (removeFunc == nullptr) {
    577602        FunctionType * fty = FunctionType::get(getInt32Ty(), {getInt8PtrTy()}, false);
    578         removeFunc = Function::Create(fty, Function::ExternalLinkage, "remove", mMod);
     603        removeFunc = Function::Create(fty, Function::ExternalLinkage, "remove", m);
    579604        removeFunc->setCallingConv(CallingConv::C);
    580605    }
     
    583608
    584609Value * CBuilder::CreatePThreadCreateCall(Value * thread, Value * attr, Function * start_routine, Value * arg) {
     610    Module * const m = getModule();
    585611    Type * const voidPtrTy = getVoidPtrTy();
    586     Function * pthreadCreateFunc = mMod->getFunction("pthread_create");
     612    Function * pthreadCreateFunc = m->getFunction("pthread_create");
    587613    if (pthreadCreateFunc == nullptr) {
    588614        Type * pthreadTy = getSizeTy();
    589615        FunctionType * funVoidPtrVoidTy = FunctionType::get(getVoidTy(), {getVoidPtrTy()}, false);
    590616        FunctionType * fty = FunctionType::get(getInt32Ty(), {pthreadTy->getPointerTo(), voidPtrTy, funVoidPtrVoidTy->getPointerTo(), voidPtrTy}, false);
    591         pthreadCreateFunc = Function::Create(fty, Function::ExternalLinkage, "pthread_create", mMod);
     617        pthreadCreateFunc = Function::Create(fty, Function::ExternalLinkage, "pthread_create", m);
    592618        pthreadCreateFunc->setCallingConv(CallingConv::C);
    593619    }
     
    596622
    597623Value * CBuilder::CreatePThreadExitCall(Value * value_ptr) {
    598     Function * pthreadExitFunc = mMod->getFunction("pthread_exit");
     624    Module * const m = getModule();
     625    Function * pthreadExitFunc = m->getFunction("pthread_exit");
    599626    if (pthreadExitFunc == nullptr) {
    600627        FunctionType * fty = FunctionType::get(getVoidTy(), {getVoidPtrTy()}, false);
    601         pthreadExitFunc = Function::Create(fty, Function::ExternalLinkage, "pthread_exit", mMod);
     628        pthreadExitFunc = Function::Create(fty, Function::ExternalLinkage, "pthread_exit", m);
    602629        pthreadExitFunc->addFnAttr(Attribute::NoReturn);
    603630        pthreadExitFunc->setCallingConv(CallingConv::C);
     
    609636
    610637Value * CBuilder::CreatePThreadJoinCall(Value * thread, Value * value_ptr){
    611     Function * pthreadJoinFunc = mMod->getFunction("pthread_join");
     638    Module * const m = getModule();
     639    Function * pthreadJoinFunc = m->getFunction("pthread_join");
    612640    if (pthreadJoinFunc == nullptr) {
    613641        Type * pthreadTy = getSizeTy();
    614642        FunctionType * fty = FunctionType::get(getInt32Ty(), {pthreadTy, getVoidPtrTy()->getPointerTo()}, false);
    615         pthreadJoinFunc = Function::Create(fty, Function::ExternalLinkage, "pthread_join", mMod);
     643        pthreadJoinFunc = Function::Create(fty, Function::ExternalLinkage, "pthread_join", m);
    616644        pthreadJoinFunc->setCallingConv(CallingConv::C);
    617645    }
     
    619647}
    620648
    621 void CBuilder::CreateAssert(Value * const assertion, StringRef failureMessage) {
     649void CBuilder::CreateAssert(Value * const assertion, StringRef failureMessage) {   
    622650    if (codegen::EnableAsserts) {
    623         Function * function = mMod->getFunction("__assert");
     651        Module * const m = getModule();
     652        Function * function = m->getFunction("__assert");
    624653        if (LLVM_UNLIKELY(function == nullptr)) {
    625654            auto ip = saveIP();
    626655            FunctionType * fty = FunctionType::get(getVoidTy(), { getInt1Ty(), getInt8PtrTy(), getSizeTy() }, false);
    627             function = Function::Create(fty, Function::PrivateLinkage, "__assert", mMod);
     656            function = Function::Create(fty, Function::PrivateLinkage, "__assert", m);
    628657            function->setDoesNotThrow();
    629658            function->setDoesNotAlias(2);
     
    661690
    662691void CBuilder::CreateExit(const int exitCode) {
    663     Function * exit = mMod->getFunction("exit");
     692    Module * const m = getModule();
     693    Function * exit = m->getFunction("exit");
    664694    if (LLVM_UNLIKELY(exit == nullptr)) {
    665695        FunctionType * fty = FunctionType::get(getVoidTy(), {getInt32Ty()}, false);
    666         exit = Function::Create(fty, Function::ExternalLinkage, "exit", mMod);
     696        exit = Function::Create(fty, Function::ExternalLinkage, "exit", m);
    667697        exit->setDoesNotReturn();
    668698        exit->setDoesNotThrow();
    669699    }
    670700    CreateCall(exit, getInt32(exitCode));
     701}
     702
     703llvm::BasicBlock * CBuilder::CreateBasicBlock(std::string && name) {
     704    return BasicBlock::Create(getContext(), name, GetInsertBlock()->getParent());
    671705}
    672706
     
    679713}
    680714
    681 inline static unsigned ceil_log2(const unsigned v) {
    682     assert ("log2(0) is undefined!" && v != 0);
    683     return 32 - __builtin_clz(v - 1);
    684 }
    685 
    686715Value * CBuilder::CreatePopcount(Value * bits) {
    687     Value * ctpopFunc = Intrinsic::getDeclaration(mMod, Intrinsic::ctpop, bits->getType());
     716    Value * ctpopFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::ctpop, bits->getType());
    688717    return CreateCall(ctpopFunc, bits);
    689718}
    690719
    691720Value * CBuilder::CreateCountForwardZeroes(Value * value) {
    692     Value * cttzFunc = Intrinsic::getDeclaration(mMod, Intrinsic::cttz, value->getType());
     721    Value * cttzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::cttz, value->getType());
    693722    return CreateCall(cttzFunc, {value, ConstantInt::getFalse(getContext())});
    694723}
    695724
    696725Value * CBuilder::CreateCountReverseZeroes(Value * value) {
    697     Value * ctlzFunc = Intrinsic::getDeclaration(mMod, Intrinsic::ctlz, value->getType());
     726    Value * ctlzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::ctlz, value->getType());
    698727    return CreateCall(ctlzFunc, {value, ConstantInt::getFalse(getContext())});
    699728}
     
    728757
    729758Value * CBuilder::GetString(StringRef Str) {
    730     Value * ptr = mMod->getGlobalVariable(Str, true);
     759    Module * const m = getModule();
     760    Value * ptr = m->getGlobalVariable(Str, true);
    731761    if (ptr == nullptr) {
    732762        ptr = CreateGlobalString(Str, Str);
     
    737767
    738768Value * CBuilder::CreateReadCycleCounter() {
    739     Value * cycleCountFunc = Intrinsic::getDeclaration(mMod, Intrinsic::readcyclecounter);
     769    Module * const m = getModule();
     770    Value * cycleCountFunc = Intrinsic::getDeclaration(m, Intrinsic::readcyclecounter);
    740771    return CreateCall(cycleCountFunc, std::vector<Value *>({}));
    741772}
     
    743774Function * CBuilder::LinkFunction(llvm::StringRef name, FunctionType * type, void * functionPtr) const {
    744775    assert (mDriver);
    745     return mDriver->LinkFunction(mMod, name, type, functionPtr);
     776    return mDriver->LinkFunction(getModule(), name, type, functionPtr);
    746777}
    747778
    748779CBuilder::CBuilder(llvm::LLVMContext & C, const unsigned GeneralRegisterWidthInBits)
    749780: IRBuilder<>(C)
    750 , mMod(nullptr)
    751781, mCacheLineAlignment(64)
    752782, mSizeType(getIntNTy(GeneralRegisterWidthInBits))
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r5436 r5440  
    1010#include <llvm/IR/Constants.h>
    1111#include <llvm/ADT/Triple.h>
     12#ifndef NDEBUG
     13#include <llvm/IR/Function.h>
     14#endif
    1215
    1316namespace kernels { class KernelBuilder; }
     
    3033
    3134    llvm::Module * getModule() const {
    32         return mMod;
    33     }
    34 
    35     void setModule(llvm::Module * const mod) {
    36         mMod = mod;
     35        #ifndef NDEBUG
     36        llvm::BasicBlock * const bb = GetInsertBlock();
     37        if (bb) {
     38            llvm::Function * const f = bb->getParent();
     39            assert ("CBuilder has an insert point that is not contained within a Function" && f);
     40            assert ("CBuilder module differs from insertion point module" && (mModule == f->getParent()));
     41        }
     42        #endif
     43        return mModule;
     44    }
     45
     46    void setModule(llvm::Module * module) {
     47        mModule = module;
     48        ClearInsertionPoint();
    3749    }
    3850
     
    173185    }
    174186
     187    llvm::BasicBlock * CreateBasicBlock(std::string && name);
     188
    175189    virtual bool supportsIndirectBr() const {
    176190        return true;
     
    210224
    211225protected:
    212     llvm::Module *                  mMod;
     226
     227    llvm::Module *                  mModule;
    213228    unsigned                        mCacheLineAlignment;
    214229    llvm::IntegerType *             mSizeType;
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.cpp

    r5436 r5440  
    1717    if (mBitBlockWidth == 256) {
    1818        if (fw == 64) {
    19             Value * signmask_f64func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx_movmsk_pd_256);
     19            Value * signmask_f64func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx_movmsk_pd_256);
    2020            Type * bitBlock_f64type = VectorType::get(getDoubleTy(), mBitBlockWidth/64);
    2121            Value * a_as_pd = CreateBitCast(a, bitBlock_f64type);
    2222            return CreateCall(signmask_f64func, a_as_pd);
    2323        } else if (fw == 32) {
    24             Value * signmask_f32func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx_movmsk_ps_256);
     24            Value * signmask_f32func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx_movmsk_ps_256);
    2525            Type * bitBlock_f32type = VectorType::get(getFloatTy(), mBitBlockWidth/32);
    2626            Value * a_as_ps = CreateBitCast(a, bitBlock_f32type);
     
    3838            Type * halfBlock_f32type = VectorType::get(getFloatTy(), mBitBlockWidth/64);
    3939            Value * pack_as_ps = CreateBitCast(packh, halfBlock_f32type);
    40             Value * signmask_f32func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx_movmsk_ps_256);
     40            Value * signmask_f32func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx_movmsk_ps_256);
    4141            return CreateCall(signmask_f32func, pack_as_ps);
    4242        }
     
    9696Value * IDISA_AVX2_Builder::esimd_mergeh(unsigned fw, Value * a, Value * b) {
    9797    if ((fw == 128) && (mBitBlockWidth == 256)) {
    98         Value * vperm2i128func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx2_vperm2i128);
     98        Value * vperm2i128func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx2_vperm2i128);
    9999        return CreateCall(vperm2i128func, {fwCast(64, a), fwCast(64, b), getInt8(0x31)});
    100100    }
     
    105105Value * IDISA_AVX2_Builder::esimd_mergel(unsigned fw, Value * a, Value * b) {
    106106    if ((fw == 128) && (mBitBlockWidth == 256)) {
    107         Value * vperm2i128func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx2_vperm2i128);
     107        Value * vperm2i128func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx2_vperm2i128);
    108108        return CreateCall(vperm2i128func, {fwCast(64, a), fwCast(64, b), getInt8(0x20)});
    109109    }
     
    114114Value * IDISA_AVX2_Builder::hsimd_packl_in_lanes(unsigned lanes, unsigned fw, Value * a, Value * b) {
    115115    if ((fw == 16)  && (lanes == 2)) {
    116         Value * vpackuswbfunc = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx2_packuswb);
     116        Value * vpackuswbfunc = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx2_packuswb);
    117117        Value * a_low = fwCast(16, simd_and(a, simd_lomask(fw)));
    118118        Value * b_low = fwCast(16, simd_and(b, simd_lomask(fw)));
     
    125125Value * IDISA_AVX2_Builder::hsimd_packh_in_lanes(unsigned lanes, unsigned fw, Value * a, Value * b) {
    126126    if ((fw == 16)  && (lanes == 2)) {
    127         Value * vpackuswbfunc = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx2_packuswb);
     127        Value * vpackuswbfunc = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_avx2_packuswb);
    128128        Value * a_low = simd_srli(fw, a, fw/2);
    129129        Value * b_low = simd_srli(fw, b, fw/2);
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.cpp

    r5436 r5440  
    3030
    3131void IDISA_Builder::CallPrintRegister(const std::string & name, Value * const value) {
    32     Constant * printRegister = mMod->getFunction("PrintRegister");
     32    Module * const m = getModule();
     33    Constant * printRegister = m->getFunction("PrintRegister");
    3334    if (LLVM_UNLIKELY(printRegister == nullptr)) {
    3435        FunctionType *FT = FunctionType::get(getVoidTy(), { PointerType::get(getInt8Ty(), 0), getBitBlockType() }, false);
    35         Function * function = Function::Create(FT, Function::InternalLinkage, "PrintRegister", mMod);
     36        Function * function = Function::Create(FT, Function::InternalLinkage, "PrintRegister", m);
    3637        auto arg = function->arg_begin();
    3738        std::string tmp;
     
    4243        }
    4344        out << '\n';
    44         BasicBlock * entry = BasicBlock::Create(mMod->getContext(), "entry", function);
     45        BasicBlock * entry = BasicBlock::Create(m->getContext(), "entry", function);
    4546        IRBuilder<> builder(entry);
    4647        std::vector<Value *> args;
     
    148149
    149150Value * IDISA_Builder::simd_cttz(unsigned fw, Value * a) {
    150     Value * cttzFunc = Intrinsic::getDeclaration(mMod, Intrinsic::cttz, fwVectorType(fw));
     151    Value * cttzFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::cttz, fwVectorType(fw));
    151152    return CreateCall(cttzFunc, {fwCast(fw, a), ConstantInt::get(getInt1Ty(), 0)});
    152153}
    153154
    154155Value * IDISA_Builder::simd_popcount(unsigned fw, Value * a) {
    155     Value * ctpopFunc = Intrinsic::getDeclaration(mMod, Intrinsic::ctpop, fwVectorType(fw));
     156    Value * ctpopFunc = Intrinsic::getDeclaration(getModule(), Intrinsic::ctpop, fwVectorType(fw));
    156157    return CreateCall(ctpopFunc, fwCast(fw, a));
    157158}
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_nvptx_builder.cpp

    r5374 r5440  
    1919Value * IDISA_NVPTX20_Builder::bitblock_any(Value * val) {
    2020    Type * const int32ty = getInt32Ty();
    21     Function * barrierOrFunc = cast<Function>(mMod->getOrInsertFunction("llvm.nvvm.barrier0.or", int32ty, int32ty, nullptr));
     21    Function * barrierOrFunc = cast<Function>(getModule()->getOrInsertFunction("llvm.nvvm.barrier0.or", int32ty, int32ty, nullptr));
    2222    Value * nonZero_i1 = CreateICmpUGT(val, ConstantInt::getNullValue(mBitBlockType));
    2323    Value * nonZero_i32 = CreateZExt(CreateBitCast(nonZero_i1, getInt1Ty()), int32ty);
     
    6666
    6767void IDISA_NVPTX20_Builder::CreateGlobals(){
    68 
     68    Module * const m = getModule();
    6969    Type * const carryTy = ArrayType::get(mBitBlockType, groupThreads+1);
    70     carry = new GlobalVariable(*mMod,
     70    carry = new GlobalVariable(*m,
    7171        /*Type=*/carryTy,
    7272        /*isConstant=*/false,
     
    8181    Type * const bubbleTy = ArrayType::get(mBitBlockType, groupThreads);
    8282
    83     bubble = new GlobalVariable(*mMod,
     83    bubble = new GlobalVariable(*m,
    8484        /*Type=*/bubbleTy,
    8585        /*isConstant=*/false,
     
    102102    Type * const voidTy = getVoidTy();
    103103    Type * const int32ty = getInt32Ty();
    104     barrierFunc = cast<Function>(mMod->getOrInsertFunction("llvm.nvvm.barrier0", voidTy, nullptr));
    105     tidFunc = cast<Function>(mMod->getOrInsertFunction("llvm.nvvm.read.ptx.sreg.tid.x", int32ty, nullptr));
    106 
     104    Module * const m = getModule();
     105    barrierFunc = cast<Function>(m->getOrInsertFunction("llvm.nvvm.barrier0", voidTy, nullptr));
     106    tidFunc = cast<Function>(m->getOrInsertFunction("llvm.nvvm.read.ptx.sreg.tid.x", int32ty, nullptr));
    107107}
    108108
    109109void IDISA_NVPTX20_Builder::CreateLongAdvanceFunc(){
    110   Type * const int32ty = getInt32Ty();
    111   Type * returnType = StructType::get(mMod->getContext(), {mBitBlockType, mBitBlockType});
    112 
    113   mLongAdvanceFunc = cast<Function>(mMod->getOrInsertFunction("LongAdvance", returnType, int32ty, mBitBlockType, mBitBlockType, mBitBlockType, nullptr));
    114   mLongAdvanceFunc->setCallingConv(CallingConv::C);
    115   Function::arg_iterator args = mLongAdvanceFunc->arg_begin();
    116 
    117   Value * const id = &*(args++);
    118   id->setName("id");
    119   Value * const val = &*(args++);
    120   val->setName("val");
    121   Value * const shftAmount = &*(args++);
    122   shftAmount->setName("shftAmount");
    123   Value * const blockCarry = &*(args++);
    124   blockCarry->setName("blockCarry");
    125 
    126   SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", mLongAdvanceFunc,0));
    127 
    128   Value * firstCarryPtr = CreateGEP(carry, {getInt32(0), getInt32(0)});
    129   CreateStore(blockCarry, firstCarryPtr);
    130 
    131   Value * adv0 = CreateShl(val, shftAmount);
    132   Value * nextid = CreateAdd(id, getInt32(1));
    133   Value * carryNextPtr = CreateGEP(carry, {getInt32(0), nextid});
    134   Value * lshr0 = CreateLShr(val, CreateSub(CreateBitCast(getInt64(64), mBitBlockType), shftAmount));
    135   CreateStore(lshr0, carryNextPtr);
    136 
    137   CreateCall(barrierFunc);
    138 
    139   Value * lastCarryPtr = CreateGEP(carry, {getInt32(0), getInt32(groupThreads)});
    140   Value * blockCarryOut = CreateLoad(lastCarryPtr, "blockCarryOut");
    141 
    142   Value * carryPtr = CreateGEP(carry, {getInt32(0), id});
    143   Value * carryVal = CreateLoad(carryPtr, "carryVal");
    144   Value * adv1 = CreateOr(adv0, carryVal);
    145 
    146  
    147   Value * retVal = UndefValue::get(returnType);
    148   retVal = CreateInsertValue(retVal, adv1, 0);
    149   retVal = CreateInsertValue(retVal, blockCarryOut, 1);
    150   CreateRet(retVal);
     110    Type * const int32ty = getInt32Ty();
     111    Module * const m = getModule();
     112    Type * returnType = StructType::get(m->getContext(), {mBitBlockType, mBitBlockType});
     113    mLongAdvanceFunc = cast<Function>(m->getOrInsertFunction("LongAdvance", returnType, int32ty, mBitBlockType, mBitBlockType, mBitBlockType, nullptr));
     114    mLongAdvanceFunc->setCallingConv(CallingConv::C);
     115    auto args = mLongAdvanceFunc->arg_begin();
     116
     117    Value * const id = &*(args++);
     118    id->setName("id");
     119    Value * const val = &*(args++);
     120    val->setName("val");
     121    Value * const shftAmount = &*(args++);
     122    shftAmount->setName("shftAmount");
     123    Value * const blockCarry = &*(args++);
     124    blockCarry->setName("blockCarry");
     125
     126    SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", mLongAdvanceFunc,0));
     127
     128    Value * firstCarryPtr = CreateGEP(carry, {getInt32(0), getInt32(0)});
     129    CreateStore(blockCarry, firstCarryPtr);
     130
     131    Value * adv0 = CreateShl(val, shftAmount);
     132    Value * nextid = CreateAdd(id, getInt32(1));
     133    Value * carryNextPtr = CreateGEP(carry, {getInt32(0), nextid});
     134    Value * lshr0 = CreateLShr(val, CreateSub(CreateBitCast(getInt64(64), mBitBlockType), shftAmount));
     135    CreateStore(lshr0, carryNextPtr);
     136
     137    CreateCall(barrierFunc);
     138
     139    Value * lastCarryPtr = CreateGEP(carry, {getInt32(0), getInt32(groupThreads)});
     140    Value * blockCarryOut = CreateLoad(lastCarryPtr, "blockCarryOut");
     141
     142    Value * carryPtr = CreateGEP(carry, {getInt32(0), id});
     143    Value * carryVal = CreateLoad(carryPtr, "carryVal");
     144    Value * adv1 = CreateOr(adv0, carryVal);
     145
     146
     147    Value * retVal = UndefValue::get(returnType);
     148    retVal = CreateInsertValue(retVal, adv1, 0);
     149    retVal = CreateInsertValue(retVal, blockCarryOut, 1);
     150    CreateRet(retVal);
    151151
    152152}
     
    157157  Type * const int64ty = getInt64Ty();
    158158  Type * const int32ty = getInt32Ty();
    159   Type * returnType = StructType::get(mMod->getContext(), {mBitBlockType, mBitBlockType});
    160 
    161   mLongAddFunc = cast<Function>(mMod->getOrInsertFunction("LongAdd", returnType, int32ty, mBitBlockType, mBitBlockType, mBitBlockType, nullptr));
     159  Module * const m = getModule();
     160
     161  Type * returnType = StructType::get(m->getContext(), {mBitBlockType, mBitBlockType});
     162
     163  mLongAddFunc = cast<Function>(m->getOrInsertFunction("LongAdd", returnType, int32ty, mBitBlockType, mBitBlockType, mBitBlockType, nullptr));
    162164  mLongAddFunc->setCallingConv(CallingConv::C);
    163165  Function::arg_iterator args = mLongAddFunc->arg_begin();
     
    172174  blockCarry->setName("blockCarry");
    173175
    174   BasicBlock * entryBlock = BasicBlock::Create(mMod->getContext(), "entry", mLongAddFunc, 0);
    175   BasicBlock * bubbleCalculateBlock = BasicBlock::Create(mMod->getContext(), "bubbleCalculate", mLongAddFunc, 0);
    176   BasicBlock * bubbleSetBlock = BasicBlock::Create(mMod->getContext(), "bubbleSet", mLongAddFunc, 0);
     176  BasicBlock * entryBlock = BasicBlock::Create(m->getContext(), "entry", mLongAddFunc, 0);
     177  BasicBlock * bubbleCalculateBlock = BasicBlock::Create(m->getContext(), "bubbleCalculate", mLongAddFunc, 0);
     178  BasicBlock * bubbleSetBlock = BasicBlock::Create(m->getContext(), "bubbleSet", mLongAddFunc, 0);
    177179
    178180  SetInsertPoint(entryBlock);
     
    243245    Type * const int32ty = getInt32Ty();
    244246    Type * const int1ty = getInt1Ty();
    245     Function * const ballotFn = cast<Function>(mMod->getOrInsertFunction("ballot_nvptx", int32ty, int1ty, nullptr));
     247    Module * const m = getModule();
     248    Function * const ballotFn = cast<Function>(m->getOrInsertFunction("ballot_nvptx", int32ty, int1ty, nullptr));
    246249    ballotFn->setCallingConv(CallingConv::C);
    247250    Function::arg_iterator args = ballotFn->arg_begin();
     
    250253    input->setName("input");
    251254
    252     SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", ballotFn, 0));
     255    SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", ballotFn, 0));
    253256
    254257    Value * conv = CreateZExt(input, int32ty);
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_sse_builder.cpp

    r5374 r5440  
    1212std::string IDISA_SSE2_Builder::getBuilderUniqueName() { return mBitBlockWidth != 128 ? "SSE2_" + std::to_string(mBitBlockWidth) : "SSE2";}
    1313
    14 Value * IDISA_SSE2_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {
     14Value * IDISA_SSE2_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {   
    1515    if ((fw == 16) && (mBitBlockWidth == 128)) {
    16         Value * packuswb_func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_sse2_packuswb_128);
     16        Value * packuswb_func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_sse2_packuswb_128);
    1717        return CreateCall(packuswb_func, {simd_srli(16, a, 8), simd_srli(16, b, 8)});
    1818    }
     
    2323Value * IDISA_SSE2_Builder::hsimd_packl(unsigned fw, Value * a, Value * b) {
    2424    if ((fw == 16) && (mBitBlockWidth == 128)) {
    25         Value * packuswb_func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_sse2_packuswb_128);
     25        Value * packuswb_func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_sse2_packuswb_128);
    2626        Value * mask = simd_lomask(16);
    2727        return CreateCall(packuswb_func, {fwCast(16, simd_and(a, mask)), fwCast(16, simd_and(b, mask))});
     
    3535    if (mBitBlockWidth == 128) {
    3636        if (fw == 64) {
    37             Value * signmask_f64func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_sse2_movmsk_pd);
     37            Value * signmask_f64func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_sse2_movmsk_pd);
    3838            Type * bitBlock_f64type = VectorType::get(getDoubleTy(), mBitBlockWidth/64);
    3939            Value * a_as_pd = CreateBitCast(a, bitBlock_f64type);
     
    4141        }
    4242        if (fw == 8) {
    43             Value * pmovmskb_func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_sse2_pmovmskb_128);
     43            Value * pmovmskb_func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_sse2_pmovmskb_128);
    4444            return CreateCall(pmovmskb_func, fwCast(8, a));
    4545        }
     
    4747    const auto fieldCount = mBitBlockWidth / fw;
    4848    if ((fieldCount > 4) && (fieldCount <= 16)) {
    49         Value * pmovmskb_func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_sse2_pmovmskb_128);
     49        Value * pmovmskb_func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_sse2_pmovmskb_128);
    5050        int fieldBytes = fw / 8;
    5151        int hiByte = fieldBytes - 1;
     
    6767    // SSE special cases using Intrinsic::x86_sse_movmsk_ps (fw=32 only)
    6868    if (fw == 32) {
    69         Value * signmask_f32func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_sse_movmsk_ps);
     69        Value * signmask_f32func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_sse_movmsk_ps);
    7070        Type * bitBlock_f32type = VectorType::get(getFloatTy(), mBitBlockWidth/32);
    7171        Value * a_as_ps = CreateBitCast(a, bitBlock_f32type);
     
    8383        Type * halfBlock_f32type = VectorType::get(getFloatTy(), mBitBlockWidth/64);
    8484        Value * pack_as_ps = CreateBitCast(packh, halfBlock_f32type);
    85         Value * signmask_f32func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_sse_movmsk_ps);
     85        Value * signmask_f32func = Intrinsic::getDeclaration(getModule(), Intrinsic::x86_sse_movmsk_ps);
    8686        Value * mask = CreateCall(signmask_f32func, pack_as_ps);
    8787        return mask;
Note: See TracChangeset for help on using the changeset viewer.