Mercurial > hg > CbC > CbC_llvm
changeset 155:70c77e05b61e
write goto with environment with out logjmp basic idea
author | anatofuz |
---|---|
date | Wed, 11 Mar 2020 19:59:35 +0900 |
parents | f7e988d3e4cc |
children | 8b836e0217ba |
files | clang/lib/Parse/ParseCbC.cpp |
diffstat | 1 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/clang/lib/Parse/ParseCbC.cpp Wed Mar 11 19:23:03 2020 +0900 +++ b/clang/lib/Parse/ParseCbC.cpp Wed Mar 11 19:59:35 2020 +0900 @@ -75,6 +75,37 @@ }; } +/// goto with environment with out logjmp +/// basic idea is prepare struct containes pointer to return value variable and stack pointer +/// +/// int main() { +/// struct __CbC_return { +/// int* i; +/// void* sp; +// void* fp; +/// } ret; +// int i; +/// if (0) { +// _CBC_RETURN: +// %fp = ret.fp; +// %rsp = ret.sp; +// i = *(ret.i); //? +// return i; +// } +/// ret.i = &i; +/// ret.sp = %rsp; +// ret.fp = %rfp; +/// __code c(int i,void* env) = _CBC_RETURN; +/// goto f(c, &ret); +/// } +/// +/// __code ret(int, void* env) { +// sp = env; +// %rax = 1; +// jmp _CBC_RETURN; +/// } +/// +/// /// Prepare__retForGotoWithTheEnvExpr - Prepare __CbC_return, code segment for returning and some necessary statements. /// It is called when the parser find __return and statements are put into complex statement.