本文整理汇总了C++中ExprNode::coercedType方法的典型用法代码示例。如果您正苦于以下问题:C++ ExprNode::coercedType方法的具体用法?C++ ExprNode::coercedType怎么用?C++ ExprNode::coercedType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExprNode
的用法示例。
在下文中一共展示了ExprNode::coercedType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert_IC_MC
void FinalMachineCodeGen::convert_IC_MC(InterCode *interCode, ostream &os) {
string dst_regName ;
string src1_regName;
string src2_regName;
ExprNode **opndsList = (ExprNode **)interCode->get3Operands();
switch(interCode->getOPNType()) {
case CALL : {
string func_name = ((InvocationNode*)opndsList[0])->symTabEntry()->name();
string retAddrReg;
if (int_reg_used_cnt || fl_reg_used_cnt) {
retAddrReg = LabelClass::assignLabel()->getLabel();
} else {
retAddrReg = opndsList[0]->next()->getLabel();
}
push_registers(retAddrReg, os);
os << "JMP " << func_name << endl;
if ((int_reg_used_cnt-1) || fl_reg_used_cnt || opndsList[1]) {
os << retAddrReg << ": ";
pop_registers(os);
if (opndsList[1]) {
ExprNode *src1 = opndsList[1];
string retValueReg = src1->getRegisterName();
if(IS_FLOAT(src1->type()))
os<<"MOVF "<<RRV_F<<" ";
else
os<<"MOVI "<<RRV_I<<" ";
os<<retValueReg<<endl;
//int_reg_used_cnt--;
}
}
reg_list.resize(0);
break;
}
case FPARAM: {
ExprNode *src1 = opndsList[0];
dst_regName = src1->getRegisterName();
os << "ADD "<<RSP<<" 4 "<<RSP << endl;
if (IS_FLOAT(src1->type()))
os << "LDF "<<RSP<<" "<<dst_regName;
else
os << "LDI "<<RSP<<" "<<dst_regName;
os << C_FPARAM << endl;
break;
}
case APARAM: {
ExprNode *param = opndsList[0];
Type *ret_type = (param) ? (param->coercedType() ? (Type*)param ->coercedType() : param->type()): NULL ;
string str;
string regName;
if(param)
{
if(param->exprNodeType() == ExprNode::ExprNodeType::VALUE_NODE)
{
if(IS_FLOAT(ret_type))
{
regName = allocateNewRegName(true);
str = "STF "+regName+" "+RSP;
//fl_reg_used_cnt--;
}
else
str = "STI "+param->getRefName()+" "+RSP;
}
else
{
if(IS_FLOAT(ret_type))
{
string temp;
regName = param->getRegisterName();
if(regName.at(0) == 'R')
{
temp = convertToFloat(param, os);
str = "STF "+temp+" "+RSP;
}
else
str = "STF "+param->getRegisterName()+" "+RSP;
}
else
str = "STI "+param->getRegisterName()+" "+RSP;
}
reg_list.push_back(str + C_APARAM);
}
break;
}
case RETURN: {
if (opndsList[0]) {
ExprNode *ret_val = opndsList[0];
Type *ret_type = (ret_val) ? (ret_val ->coercedType() ? (Type*)ret_val ->coercedType() : ret_val ->type()): NULL ;
if (IS_FLOAT(ret_type)) {
dst_regName = ret_val->getRegisterName();
os<<"MOVF "<<dst_regName<<" "<<RRV_F;
} else {
dst_regName = ret_val->getRegisterName();
//.........这里部分代码省略.........