mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
A series of FunC improvements (#378)
* Don't use IFJMP/IFNOTJMP in inline functions * Fix incorrect ifelse branch code generation https://github.com/ton-blockchain/ton/issues/374 * Make generate_code_all clearer * Don't replace IFJMP with IF in inner blocks in inline functions * Allow unbalance if/else by using RETALT * Fix wrong PUSHCONT * Bugfix in IF code generation for inline functions * Fix unbalanced if/else * Bugfix and improvements in code generation * Fix analyzing while(0) in func https://github.com/ton-blockchain/ton/issues/377 * FunC and Asm.fif: Fix inlining large functions https://github.com/ton-blockchain/ton/issues/375 Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
fecf760aae
commit
40cec56e28
5 changed files with 144 additions and 81 deletions
|
@ -99,12 +99,28 @@ void generate_output_func(SymDef* func_sym) {
|
|||
if (verbosity >= 2) {
|
||||
std::cerr << "\n---------- resulting code for " << name << " -------------\n";
|
||||
}
|
||||
bool inline_func = (func_val->flags & 1);
|
||||
bool inline_ref = (func_val->flags & 2);
|
||||
*outs << std::string(indent * 2, ' ') << name << " PROC" << (inline_ref ? "REF" : "") << ":<{\n";
|
||||
code.generate_code(
|
||||
*outs,
|
||||
(stack_layout_comments ? Stack::_StkCmt | Stack::_CptStkCmt : 0) | (opt_level < 2 ? Stack::_DisableOpt : 0),
|
||||
indent + 1);
|
||||
const char* modifier = "";
|
||||
if (inline_func) {
|
||||
modifier = "INLINE";
|
||||
} else if (inline_ref) {
|
||||
modifier = "REF";
|
||||
}
|
||||
*outs << std::string(indent * 2, ' ') << name << " PROC" << modifier << ":<{\n";
|
||||
int mode = 0;
|
||||
if (stack_layout_comments) {
|
||||
mode |= Stack::_StkCmt | Stack::_CptStkCmt;
|
||||
}
|
||||
if (opt_level < 2) {
|
||||
mode |= Stack::_DisableOpt;
|
||||
}
|
||||
auto fv = dynamic_cast<const SymValCodeFunc*>(func_sym->value);
|
||||
// Flags: 1 - inline, 2 - inline_ref
|
||||
if (fv && (fv->flags & 1) && code.ops->noreturn()) {
|
||||
mode |= Stack::_InlineFunc;
|
||||
}
|
||||
code.generate_code(*outs, mode, indent + 1);
|
||||
*outs << std::string(indent * 2, ' ') << "}>\n";
|
||||
if (verbosity >= 2) {
|
||||
std::cerr << "--------------\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue