当前位置: 首页>>代码示例>>C++>>正文


C++ Operand类代码示例

本文整理汇总了C++中Operand的典型用法代码示例。如果您正苦于以下问题:C++ Operand类的具体用法?C++ Operand怎么用?C++ Operand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Operand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pop

void OperandStack::d2i(){
    Operand opL = pop();
    Operand opH = pop();

    if((opL.type != TYPE_DOUBLE) || (opH.type != TYPE_DOUBLE)) {
        printf("Error type not double: :op_stack.d2i\n");
        exit(0);
    }
	double d = to_double(opH.bytes, opL.bytes);
    int32_t i = (int32_t) d;

	Operand op;
	op.set_value(TYPE_INT, &i);
	
    push(op);
}
开发者ID:Gabrielcarvfer,项目名称:SB2014JVM,代码行数:16,代码来源:op_stack.cpp

示例2: dumpDest

void InstSelect::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  dumpDest(Func);
  Operand *Condition = getCondition();
  Operand *TrueOp = getTrueOperand();
  Operand *FalseOp = getFalseOperand();
  Str << " = select " << Condition->getType() << " ";
  Condition->dump(Func);
  Str << ", " << TrueOp->getType() << " ";
  TrueOp->dump(Func);
  Str << ", " << FalseOp->getType() << " ";
  FalseOp->dump(Func);
}
开发者ID:stichnot,项目名称:subzero,代码行数:13,代码来源:IceInst.cpp

示例3: switch

Instruction* In::CreateInstruction(Memory::MemoryOffset& memLoc, Processor* proc) {
	Memory::MemoryOffset opLoc = memLoc;
	char buf[65];
	std::string inst;

	Prefix* pre = Prefix::GetPrefix(memLoc);
	unsigned int preSize = 0;
	Instruction* newIn = 0;

	if(pre) {
		opLoc += preSize = pre->GetLength();
	}

	switch(*opLoc) {
		case IN_AL_IMM8:
		case IN_AX_IMM8:
		{
			eRegisters reg = *opLoc == IN_AL_IMM8 ? REG_AL : REG_AX;
			Operand* src = new ImmediateOperand(*(opLoc + 1), 1, (opLoc + 1).getOffset());
			Operand* dst = new RegisterOperand(reg, proc);
			GETINST(preSize + 2);
			snprintf(buf, 65, "IN %s, %s",reg == REG_AX ? "AX" : "AL", src->GetDisasm().c_str());

			newIn = new In(pre, buf, inst, (int)*opLoc);
			newIn->SetOperand(Operand::SRC, src);
			newIn->SetOperand(Operand::DST, dst);
			break;
		}
		case IN_AL_DX:
		case IN_AX_DX:
		{
			eRegisters reg = *opLoc == IN_AL_DX ? REG_AL : REG_AX;
			Operand* src = new RegisterOperand(REG_DX, proc);
			Operand* dst = new RegisterOperand(reg, proc);
			GETINST(preSize + 1);
			snprintf(buf, 65, "IN %s, DX", reg == REG_AX ? "AX" : "AL");
			newIn = new In(pre, buf, inst, (int)*opLoc);
			newIn->SetOperand(Operand::SRC, src);
			newIn->SetOperand(Operand::DST, dst);
			break;
		}
	}

	return newIn;

}
开发者ID:DarrenStahl,项目名称:Libra,代码行数:46,代码来源:In.cpp

示例4: switch

Instruction* Out::CreateInstruction(unsigned char* memLoc, Processor* proc) {
	unsigned char* opLoc = memLoc;
	char buf[65];
	std::string inst;

	Prefix* pre = Prefix::GetPrefix(memLoc);
	unsigned int preSize = 0;
	Instruction* newOut = 0;

	if(pre) {
		opLoc += preSize = pre->GetLength();
	}

	switch(*opLoc) {
		case OUT_IMM8_AL:
		case OUT_IMM8_AX:
		{
			eRegisters reg = *opLoc == OUT_IMM8_AL ? REG_AL : REG_AX;
			Operand* dst = new ImmediateOperand(*(opLoc + 1), 1);
			Operand* src = new RegisterOperand(reg, proc);
			GETINST(preSize + 2);
			snprintf(buf, 65, "OUT %s, %s", dst->GetDisasm().c_str(), reg == REG_AX ? "AX" : "AL");

			newOut = new Out(pre, buf, inst, (int)*opLoc);
			newOut->SetOperand(Operand::SRC, src);
			newOut->SetOperand(Operand::DST, dst);
			break;
		}
		case OUT_DX_AL:
		case OUT_DX_AX:
		{
			eRegisters reg = *opLoc == OUT_DX_AL ? REG_AL : REG_AX;
			Operand* dst = new RegisterOperand(REG_DX, proc);
			Operand* src = new RegisterOperand(reg, proc);
			GETINST(preSize + 1);
			snprintf(buf, 65, "OUT DX, %s", reg == REG_AX ? "AX" : "AL");
			newOut = new Out(pre, buf, inst, (int)*opLoc);
			newOut->SetOperand(Operand::SRC, src);
			newOut->SetOperand(Operand::DST, dst);
			break;
		}
	}

	return newOut;

}
开发者ID:rdnelson,项目名称:Libra,代码行数:46,代码来源:Out.cpp

示例5: assert

/// This should be called in top-down order of each def that needs its uses
/// rewrited. The order that we visit uses for a given def is irrelevant.
void SILSSAUpdater::RewriteUse(Operand &Op) {
    // Replicate function_refs to their uses. SILGen can't build phi nodes for
    // them and it would not make much sense anyways.
    if (auto *FR = dyn_cast<FunctionRefInst>(Op.get())) {
        assert(areIdentical(getAvailVals(AV)) &&
               "The function_refs need to have the same value");
        SILInstruction *User = Op.getUser();
        auto *NewFR = FR->clone(User);
        Op.set(NewFR);
        return;
    } else if (auto *IL = dyn_cast<IntegerLiteralInst>(Op.get()))
        if (areIdentical(getAvailVals(AV))) {
            // Some llvm intrinsics don't like phi nodes as their constant inputs (e.g
            // ctlz).
            SILInstruction *User = Op.getUser();
            auto *NewIL = IL->clone(User);
            Op.set(NewIL);
            return;
        }

    // Again we need to be careful here, because ssa construction (with the
    // existing representation) can change the operand from under us.
    UseWrapper UW(&Op);

    SILInstruction *User = Op.getUser();
    SILValue NewVal = GetValueInMiddleOfBlock(User->getParent());
    assert(NewVal && "Need a valid value");
    ((Operand *)UW)->set((SILValue)NewVal);
}
开发者ID:yasirmcs,项目名称:swift,代码行数:31,代码来源:SILSSAUpdater.cpp

示例6: parsing_printf

int IndirectControlFlowAnalyzer::GetMemoryReadSize(Assignment::Ptr memLoc) {
    if (!memLoc) {
        parsing_printf("\tmemLoc is null\n");
        return 0;
    }
    Instruction i = memLoc->insn();
    std::vector<Operand> ops;
    i.getOperands(ops);
    parsing_printf("\t there are %d operands\n", ops.size());
    for (auto oit = ops.begin(); oit != ops.end(); ++oit) {
        Operand o = *oit;
	if (o.readsMemory()) {
	    Expression::Ptr exp = o.getValue();
	    return exp->size();
	}
    }
    return 0;
}
开发者ID:dyninst,项目名称:dyninst,代码行数:18,代码来源:IndirectAnalyzer.C

示例7: createArrayElementOperand

bool
CodeGeneratorX64::visitLoadElementT(LLoadElementT *load)
{
    Operand source = createArrayElementOperand(ToRegister(load->elements()), load->index());

    if (load->mir()->loadDoubles()) {
        FloatRegister fpreg = ToFloatRegister(load->output());
        if (source.kind() == Operand::REG_DISP)
            masm.loadDouble(source.toAddress(), fpreg);
        else
            masm.loadDouble(source.toBaseIndex(), fpreg);
    } else {
        loadUnboxedValue(source, load->mir()->type(), load->output());
    }

    JS_ASSERT(!load->mir()->needsHoleCheck());
    return true;
}
开发者ID:Nebelhom,项目名称:mozilla-central,代码行数:18,代码来源:CodeGenerator-x64.cpp

示例8: ToRegister

bool
CodeGeneratorX86Shared::visitMulNegativeZeroCheck(MulNegativeZeroCheck *ool)
{
    LMulI *ins = ool->ins();
    Register result = ToRegister(ins->output());
    Operand lhsCopy = ToOperand(ins->lhsCopy());
    Operand rhs = ToOperand(ins->rhs());
    JS_ASSERT_IF(lhsCopy.kind() == Operand::REG, lhsCopy.reg() != result.code());

    // Result is -0 if lhs or rhs is negative.
    masm.movl(lhsCopy, result);
    masm.orl(rhs, result);
    if (!bailoutIf(Assembler::Signed, ins->snapshot()))
        return false;

    masm.mov(ImmWord(0), result);
    masm.jmp(ool->rejoin());
    return true;
}
开发者ID:jonathanmarvens,项目名称:mozilla-central,代码行数:19,代码来源:CodeGenerator-x86-shared.cpp

示例9: El_is_frpizable

/*
 *	Currently only SBs are frpizable
 */
bool El_is_frpizable(Hyperblock *hb)
{
    Op *op;
    Operand pred;

    /* See if there are any ops guarded by a predicate */
    /* Also, no table jumps allowed */
    for (Region_ops_C0_order op_i(hb); op_i!=0; op_i++) {
	op = *op_i;
	if (op->predicated()) {
	    pred = op->src(PRED1);
	    if (! pred.is_predicate_true())
	        return (false);
	}
	if (op->flag(EL_OPER_TABLE_JUMP))
	    return (false);
    }

    return (true);
}
开发者ID:yuyantingzero,项目名称:SharedFolder,代码行数:23,代码来源:el_frpize.cpp

示例10: Execute

int Or::Execute(Processor* proc) {

	Operand* dst = mOperands[Operand::DST];
	Operand* src = mOperands[Operand::SRC];

	if(!dst || !src) {
		return INVALID_ARGS;
	}

	unsigned int dstVal = dst->GetValue();
	unsigned int srcVal = src->GetValue();
	unsigned int newVal = dstVal | srcVal;

	unsigned int sign = (dst->GetBitmask() == 0xFF) ? 0x80 : 0x8000;

	proc->SetFlag(FLAGS_OF, 0);
	proc->SetFlag(FLAGS_CF, 0);
	proc->SetFlag(FLAGS_SF, newVal >= sign);
	proc->SetFlag(FLAGS_ZF, newVal == 0x00);
	proc->SetFlag(FLAGS_PF, Parity(newVal));

	dst->SetValue(newVal);

	return 0;
}
开发者ID:DarrenStahl,项目名称:Libra,代码行数:25,代码来源:Or.cpp

示例11: while

bool GradeSelector::Select( void )
{
    if( !operand )
        return false;

    Expander expander;
    expander.expansionTarget = Expander::SUM_OF_BLADES;
    expander.ManipulateTree( &operand );

    Addition* addition = dynamic_cast< Addition* >( operand );
    if( !addition )
        return false;

    Addition::OperandList::Node* node = addition->operandList.Head();
    while( node )
    {
        Addition::OperandList::Node* nextNode = node->Next();

        Operand* nestedOperand = node->data;
        int count = -1;

        OuterProduct* outerProduct = dynamic_cast< OuterProduct* >( nestedOperand );
        Vector* vector = dynamic_cast< Vector* >( nestedOperand );

        if( outerProduct && outerProduct->IsHomogeneousOfVectors() )
            count = outerProduct->operandList.Count();
        else if( vector )
            count = 1;
        else if( nestedOperand->IsScalar() )
            count = 0;

        if( ( count == grade && type == TYPE_EXCLUSIVE ) || ( count != grade && type == TYPE_INCLUSIVE ) )
            addition->operandList.Remove( node );

        node = nextNode;
    }

    return true;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:39,代码来源:GradeSelector.cpp

示例12: while

void util::NodeMap::doDepthFirstSearch(Node* aNode){
    if(m_ops.size() == 0)
        return;

    if(aNode->isLeafNode()){
        Operand op = m_ops.front();
        m_ops.pop_front();
        while(op.getType() == Operand::bracketOpen){
            if(m_ops.size() == 0)
                return ;
            op = m_ops.front();
            m_ops.pop_front();
        }

        if(op.getType() == Operand::bracketClose){
            dfsFlag = 1;
            return;
        }

        BNode* b = aNode->container;
        setOpAttrributes(op,b);
    }

    std::vector<Node*> vec = aNode->getChildren();
    for(std::vector<Node*>::iterator iter = vec.begin(); iter != vec.end(); iter++){
        if((*iter) != NULL && strcmp((*iter)->getName().c_str(), "___")){
            doDepthFirstSearch(*iter);
            if(dfsFlag == 1 && !(aNode->getName() == "match_operator" || aNode->getName() == "unspec" ||
                    aNode->getName() == "parallel" || aNode->getName() == "unspec_volatile" ||
                    aNode->getName() == "match_op_dup" || aNode->getName() == "match_operator" || aNode->getName() == "parallel" ||
                    aNode->getName() == "match_op_dup" || aNode->getName() == "sequence")){
                        return;
            }
            else{
                dfsFlag = 0;
            }
        }
    }
}
开发者ID:sm88,项目名称:gcc_715,代码行数:39,代码来源:util.cpp

示例13: SetAction

void SetAction(string word,
               Operand *&currod,
               queue<Operand*> &ods,
               stack<string> &bucket,
               int *currop,
               int *opcount,
               register int &bracket_ct,
               register int &currop_ind) {
    if (currod->GetAction() == DefaultAction) {
        currod->SetAction(word);
    } else  {
        Operand *od = new Operand(*currod);
        if (od->GetAction() != DefaultAction) {
            ods.push(od);  //Look into this
            opcount[currop_ind] += 1;
            if (opcount[currop_ind] == currop[currop_ind]) {
                FixMissingEntriesAndFillTheBucket(ods, bucket);
                bucket.push(OpenBracket);currop_ind--;opcount[currop_ind] += 1;bracket_ct--;
            }
        }
        ResetCurrentOperand(currod, DefaultComponent, word, DefaultWhen, DefaultLocation, NULL, NULL);
    }
}
开发者ID:CodePanpan,项目名称:NLP_code,代码行数:23,代码来源:NLP_Final_Code_With_Tree.cpp

示例14: Execute

int Push::Execute(Processor* proc) {

    if(mOpcode == PUSHA) {
        unsigned int sp = proc->GetRegister(REG_SP);
        proc->PushRegister(REG_AX);
        proc->PushRegister(REG_CX);
        proc->PushRegister(REG_DX);
        proc->PushRegister(REG_BX);
        proc->PushValue(sp);
        proc->PushRegister(REG_BP);
        proc->PushRegister(REG_SI);
        proc->PushRegister(REG_DI);

    } else {

        Operand* dst = mOperands[Operand::DST];
        if(!dst) {
            return INVALID_ARGS;
        }
        proc->PushValue(dst->GetValue());
    }
    return 0;
}
开发者ID:DarrenStahl,项目名称:Libra,代码行数:23,代码来源:Push.cpp

示例15: assert

/// Replace an instruction with a simplified result, including any debug uses,
/// and erase the instruction. If the instruction initiates a scope, do not
/// replace the end of its scope; it will be deleted along with its parent.
void swift::replaceAllSimplifiedUsesAndErase(
    SILInstruction *I, SILValue result,
    std::function<void(SILInstruction *)> eraseNotify) {

  auto *SVI = cast<SingleValueInstruction>(I);
  assert(SVI != result && "Cannot RAUW a value with itself");

  // Only SingleValueInstructions are currently simplified.
  while (!SVI->use_empty()) {
    Operand *use = *SVI->use_begin();
    SILInstruction *user = use->getUser();
    // Erase the end of scope marker.
    if (isEndOfScopeMarker(user)) {
      if (eraseNotify)
        eraseNotify(user);
      user->eraseFromParent();
      continue;
    }
    use->set(result);
  }
  I->eraseFromParent();
  if (eraseNotify)
    eraseNotify(I);
}
开发者ID:Nirma,项目名称:swift,代码行数:27,代码来源:SimplifyInstruction.cpp


注:本文中的Operand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。