方舟编译器_3

2021SC@SDUSC
本次博客的内容为MIRFunction类。
MIRFunction类定义在src/maple_ir/include/mir_function.h和src/maple_ir/src/mir_function.cpp之中。MIRFunction类对应的是MIR中的function,是module的下一层结构,所以function层面的信息和操作都在该类定义。

GStrIdx GetBaseClassNameStrIdx() const {
return baseClassStrIdx;
}

GStrIdx GetBaseFuncNameStrIdx() const {
return baseFuncStrIdx;
}

GStrIdx GetBaseFuncNameWithTypeStrIdx() const {
return baseFuncWithTypeStrIdx;
}

GStrIdx GetBaseFuncSigStrIdx() const {
return baseFuncSigStrIdx;
}

void SetBaseClassNameStrIdx(GStrIdx id) {
baseClassStrIdx = id;
}

void SetBaseFuncNameStrIdx(GStrIdx id) {
baseFuncStrIdx = id;
}

void SetBaseFuncNameWithTypeStrIdx(GStrIdx id) {
baseFuncWithTypeStrIdx = id;
}

使用类型strIdx更新签名 strIdx、basefunc, strIdx、baseclass,strIdx、basefunc\u
在不考虑baseclass_strIdx的情况下,basefunc_strIdx的原始非零值
参数strIdx新函数名的全名strIdx

bool IsJava() const {
return classTyIdx != 0u;
}
说明此函数是否为Java方法

void MIRFunction::UpdateFuncTypeAndFormals(const std::vector<MIRSymbol*> &symbols, bool clearOldArgs) {
auto newFuncType = ReconstructFormals(symbols, clearOldArgs);
auto newFuncTypeIdx = GlobalTables::GetTypeTable().GetOrCreateMIRType(newFuncType);
funcType = static_cast<MIRFuncType
>(GlobalTables::GetTypeTable().GetTypeFromTyIdx(newFuncTypeIdx));
delete newFuncType;
}
更新函数类型和形式

void MIRFunction::UpdateFuncTypeAndFormalsAndReturnType(const std::vector<MIRSymbol*> &symbols, const TyIdx &retTyIdx,
bool clearOldArgs) {
auto newFuncType = ReconstructFormals(symbols, clearOldArgs);
newFuncType->SetRetTyIdx(retTyIdx);
auto newFuncTypeIdx = GlobalTables::GetTypeTable().GetOrCreateMIRType(newFuncType);
funcType = static_cast<MIRFuncType
>(GlobalTables::GetTypeTable().GetTypeFromTyIdx(newFuncTypeIdx));
delete newFuncType;
}
更新函数类型和形式并返回类型

LabelIdx MIRFunction::GetOrCreateLableIdxFromName(const std::string &name) {
GStrIdx strIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(name);
LabelIdx labelIdx = GetLabelTab()->GetLabelIdxFromStrIdx(strIdx);
if (labelIdx == 0) {
labelIdx = GetLabelTab()->CreateLabel();
GetLabelTab()->SetSymbolFromStIdx(labelIdx, strIdx);
GetLabelTab()->AddToStringLabelMap(labelIdx);
}
return labelIdx;
}
从名称获取或创建标签Idx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值