Changeset 6120


Ignore:
Timestamp:
Jun 28, 2018, 7:32:58 AM (5 months ago)
Author:
cameron
Message:

Random value streams

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

Legend:

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

    r6059 r6120  
    13841384}
    13851385
     1386CallInst * CBuilder::CreateSRandCall(Value * randomSeed) {
     1387    Module * const m = getModule();
     1388    Function * srandFunc = m->getFunction("srand");
     1389    if (srandFunc == nullptr) {
     1390        FunctionType * fty = FunctionType::get(getVoidTy(), getInt32Ty(), nullptr);
     1391        srandFunc = Function::Create(fty, Function::ExternalLinkage, "srand", m);
     1392        srandFunc->setCallingConv(CallingConv::C);
     1393    }
     1394    return CreateCall(srandFunc, randomSeed);
     1395}
     1396
     1397CallInst * CBuilder::CreateRandCall() {
     1398    Module * const m = getModule();
     1399    Function * randFunc = m->getFunction("rand");
     1400    if (randFunc == nullptr) {
     1401        FunctionType * fty = FunctionType::get(getInt32Ty(), nullptr);
     1402        randFunc = Function::Create(fty, Function::ExternalLinkage, "rand", m);
     1403        randFunc->setCallingConv(CallingConv::C);
     1404    }
     1405    return CreateCall(randFunc, {});
     1406}
     1407
     1408
     1409
    13861410CBuilder::CBuilder(LLVMContext & C)
    13871411: IRBuilder<>(C)
  • icGREP/icgrep-devel/icgrep/IR_Gen/CBuilder.h

    r6059 r6120  
    349349                           llvm::MDNode *ScopeTag = nullptr,
    350350                           llvm::MDNode *NoAliasTag = nullptr);
     351   
     352    llvm::CallInst * CreateSRandCall(llvm::Value * randomSeed);
     353    llvm::CallInst * CreateRandCall();
    351354
    352355    void setDriver(Driver * const driver) {
Note: See TracChangeset for help on using the changeset viewer.