Exemplo n.º 1
0
BB* BBTransform::lowerExpect(Code* code, BB* src, BB::Instrs::iterator position,
                             Value* condition, bool expected, BB* deoptBlock,
                             const std::string& debugMessage) {
    auto split = BBTransform::split(code->nextBBId++, src, position + 1, code);

    static SEXP print = Rf_findFun(Rf_install("cat"), R_GlobalEnv);

    if (debugMessage.size() != 0) {
        BB* debug = new BB(code, code->nextBBId++);
        SEXP msg = Rf_mkString(debugMessage.c_str());
        auto ldprint = new LdConst(print);
        auto ldmsg = new LdConst(msg);
        debug->append(ldmsg);
        debug->append(ldprint);
        debug->append(new Call(Env::elided(), ldprint, {ldmsg},
                               Tombstone::framestate(), 0));
        debug->setNext(deoptBlock);
        deoptBlock = debug;
    }

    src->replace(position, new Branch(condition));
    if (expected) {
        src->next1 = deoptBlock;
        src->next0 = split;
    } else {
        src->next0 = deoptBlock;
        src->next1 = split;
    }

    splitEdge(code->nextBBId++, src, deoptBlock, code);

    return split;
}
Exemplo n.º 2
0
int main()
{
	cout << "Hello EGit !!!" << endl;
	cout << "You are so fantastic!" << endl;
	int i = 123;
	cout << "feature2 = " << i << endl;
	cout << "Feature1 has to be printed!" << endl;
	cout << "rebase0 testing" << endl;

	A a;
	a.dump();

	AA aa;
	aa.dump();

	BB bb;
	bb.dump();

	cout << "Let's make feature 2 as HEAD" << endl;

	CC cc;
	cc.dump();

	cout << "What are you doing, master!" << endl;

	Flash f;
	f.flashing();

	Flash f1;
	f1.flashing();


	return 0;
}
int UpdateBucket::execute(size_t wordc, CommandLine& cmds, BB& bb) {
   int idx = 1;
   string bucketName; 
   string bucketType;
   parse2(idx, cmds, bucketName, bucketType);
   bb.updateBucket(bb.getBucket(bucketName).id, bucketType);
   return EXIT_SUCCESS;
}
Exemplo n.º 4
0
void randBuild(BB & A, size_t nnz){
	for(size_t i = 0; i < nnz; ++i)
	{	typename BB::Field::Element d; A.field().init(d, rand());
		size_t ii = rand()%A.rowdim();
		size_t jj = rand()%A.coldim();
		A.setEntry(ii,jj, d);
	}
}
Exemplo n.º 5
0
BB* BBTransform::clone(BB* src, Code* target, ClosureVersion* targetClosure) {
    std::vector<BB*> bbs;

    // Copy instructions and remember old -> new instruction map.
    std::unordered_map<Value*, Instruction*> relocation_table;
    Visitor::run(src, [&](BB* bb) {
        BB* theClone = BB::cloneInstrs(bb, target->nextBBId++, target);
        assert(bb->size() == theClone->size());
        if (bb->id >= bbs.size())
            bbs.resize(bb->id + 5);
        bbs[bb->id] = theClone;
        for (size_t i = 0; i < bb->size(); ++i)
            relocation_table[bb->at(i)] = theClone->at(i);
    });

    // Fixup CFG: next pointers of copied BB's need to be filled in.
    Visitor::run(src, [&](BB* bb) {
        bbs[bb->id]->next0 = bbs[bb->id]->next1 = nullptr;
        if (bb->next0)
            bbs[bb->id]->next0 = bbs[bb->next0->id];
        if (bb->next1)
            bbs[bb->id]->next1 = bbs[bb->next1->id];
    });

    std::unordered_map<Promise*, Promise*> promMap;
    // Relocate argument pointers using old -> new map
    BB* newEntry = bbs[src->id];
    Visitor::run(newEntry, [&](Instruction* i) {
        auto phi = Phi::Cast(i);
        if (phi) {
            for (size_t j = 0; j < phi->nargs(); ++j)
                phi->updateInputAt(j, bbs[phi->inputAt(j)->id]);
        }
        i->eachArg([&](InstrArg& arg) {
            if (arg.val()->isInstruction()) {
                assert(relocation_table.count(arg.val()));
                arg.val() = relocation_table.at(arg.val());
            }
        });
        if (auto mk = MkArg::Cast(i)) {
            Promise* p = mk->prom();
            if (p->owner != targetClosure) {
                if (promMap.count(p)) {
                    mk->updatePromise(promMap.at(p));
                } else {
                    auto c = targetClosure->createProm(p->srcPoolIdx());
                    c->entry = clone(p->entry, c, targetClosure);
                    mk->updatePromise(c);
                }
            }
        }
    });

    return newEntry;
}
Exemplo n.º 6
0
void bidiag(BB & A){
	typename BB::Field::Element d; A.field().assign(d, A.field().one);
	A.setEntry(0,0, d);
	size_t n = A.coldim() > A.rowdim() ? A.rowdim() : A.coldim();
	for(size_t i = 1; i < n; ++i)
	{	A.setEntry(i,i, d);
		A.setEntry(i,i-1, d);
	}
}
Exemplo n.º 7
0
int main( int argc, char* argv[] ) 
{
	cout << sizeof( A ) << endl;
	cout << sizeof( B ) << endl;
	cout << sizeof( C ) << endl;
	cout << sizeof( D ) << endl;
	cout << sizeof( E ) << endl;
	cout << sizeof( AA ) << endl;
	E d;
	d.show();
	BB bb;
	bb.ShowBB();
	return 0;
}
Exemplo n.º 8
0
void ICP::DcBB(void) const
{
  // Build book <input-game-file> <output-code-file>

#if (IsDevHost)
  if (cib.GetTokenCount() != 3) PrintFS(fsUdBadParmCount);
  else
  {
    BB bb;

    bb.MakeBook(stateptr, cib.GetToken(1), cib.GetToken(2));
  };
#endif

#if (IsTarget)
  PrintFS(fsUdDevHostOnly);
#endif
}
Exemplo n.º 9
0
/* Writes the procedure's declaration (including arguments), local variables,
 * and invokes the procedure that writes the code of the given record *hli */
void Function::codeGen (std::ostream &fs)
{
    int numLoc;
    ostringstream ostr;
    //STKFRAME * args;       /* Procedure arguments              */
    //char buf[200],        /* Procedure's definition           */
    //        arg[30];         /* One argument                     */
    BB *pBB;              /* Pointer to basic block           */

    /* Write procedure/function header */
    cCode.init();
    if (flg & PROC_IS_FUNC)      /* Function */
        ostr<< "\n"<<TypeContainer::typeName(retVal.type)<<" "<<name<<" (";
    else                                /* Procedure */
        ostr<< "\nvoid "<<name<<" (";

    /* Write arguments */
    for (size_t i = 0; i < args.size(); i++)
    {
        if ( args[i].invalid )
            continue;
        ostr<<hlTypes[args[i].type]<<" "<<args[i].name;
        if (i < (args.size() - 1))
            ostr<<", ";
    }
    ostr<<")\n";

    /* Write comments */
    writeProcComments( ostr );

    /* Write local variables */
    if (! (flg & PROC_ASM))
    {
        numLoc = 0;
        for (ID &refId : localId )
        {
            /* Output only non-invalidated entries */
            if ( refId.illegal )
                continue;
            if (refId.loc == REG_FRAME)
            {
                /* Register variables are assigned to a local variable */
                if (((flg & SI_REGVAR) && (refId.id.regi == rSI)) ||
                        ((flg & DI_REGVAR) && (refId.id.regi == rDI)))
                {
                    refId.setLocalName(++numLoc);
                    ostr << "int "<<refId.name<<";\n";
                }
                /* Other registers are named when they are first used in
                     * the output C code, and appended to the proc decl. */
            }
            else if (refId.loc == STK_FRAME)
            {
                /* Name local variables and output appropriate type */
                    refId.setLocalName(++numLoc);
                ostr << TypeContainer::typeName(refId.type)<<" "<<refId.name<<";\n";
            }
        }
    }
    fs<<ostr.str();
    /* Write procedure's code */
    if (flg & PROC_ASM)		/* generate assembler */
    {
        Disassembler ds(3);
        ds.disassem(this);
    }
    else							/* generate C */
    {
        m_cfg.front()->writeCode (1, this, &numLoc, MAX, UN_INIT);
    }

    cCode.appendCode( "}\n\n");
    writeBundle (fs, cCode);
    freeBundle (&cCode);

    /* Write Live register analysis information */
    if (option.verbose)
        for (size_t i = 0; i < numBBs; i++)
        {
            pBB = m_dfsLast[i];
            if (pBB->flg & INVALID_BB)	continue;	/* skip invalid BBs */
            cout << "BB "<<i<<"\n";
            cout << "  Start = "<<pBB->begin()->loc_ip;
            cout << ", end = "<<pBB->begin()->loc_ip+pBB->size()<<"\n";
            cout << "  LiveUse = ";
            Machine_X86::writeRegVector(cout,pBB->liveUse);
            cout << "\n  Def = ";
            Machine_X86::writeRegVector(cout,pBB->def);
            cout << "\n  LiveOut = ";
            Machine_X86::writeRegVector(cout,pBB->liveOut);
            cout << "\n  LiveIn = ";
            Machine_X86::writeRegVector(cout,pBB->liveIn);
            cout <<"\n\n";
        }
}