Jakob Stoklund Olesen
2009-Jul-24 17:49 UTC
[LLVMdev] LLVM and Interrupt Service Routines.
On 24/07/2009, at 19.41, <Alireza.Moshtaghi at microchip.com> wrote:> As you know PIC16 does not have stack; so generating code for ISR and > all functions that it calls (including all stdlib and basic math > intrinsics used for mult/div/etc) requires special code generation > techniques. But we don't have this information until after llvm-ld has > merged all compilation units into one. Theoretically llvm-ld can also > correct the calling convention for the two classes of functions, but > I'm > not sure about the practicality of it.What happens with functions that are called both inside and outside ISR context? Do you have to codegen two copies of those?
Jakob Stoklund Olesen wrote:> On 24/07/2009, at 19.41, <Alireza.Moshtaghi at microchip.com> wrote: > > >> As you know PIC16 does not have stack; so generating code for ISR and >> all functions that it calls (including all stdlib and basic math >> intrinsics used for mult/div/etc) requires special code generation >> techniques. But we don't have this information until after llvm-ld has >> merged all compilation units into one. Theoretically llvm-ld can also >> correct the calling convention for the two classes of functions, but >> I'm >> not sure about the practicality of it. >> > > What happens with functions that are called both inside and outside > ISR context? Do you have to codegen two copies of those? > >Yes. That's precisely what we are trying to achieve in llvm-ld. But the problems don't end there, as llvm-ld doesn't have any idea of libcalls (they're generated in llc) and they could also be called from both places. - Sanjiv> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Jul 26, 2009, at 3:42 AM, Sanjiv Gupta wrote:>> >> What happens with functions that are called both inside and outside >> ISR context? Do you have to codegen two copies of those? >> >> > Yes. That's precisely what we are trying to achieve in llvm-ld. > But the problems don't end there, as llvm-ld doesn't have any idea of > libcalls (they're generated in llc) and they could also be called from > both places.If you have to generate two copies of the function with different entrypoints, the *front-end* should handle the duplication. This is just like C++ constructors. One really old patch that apple guys experimented in the past was a "slow and fast call" attribute, which you could stick on function declarations. If you added it to a function, the frontend would generate an entry point with a standard calling convention as well as one with a faster in-register ABI. Direct calls would use the fast entry point, but if you took the address, you'd get the address of the normal one. All of this was handled by the front-end, and works fine. I think the patch eventually got ripped out of the compiler for other reasons though. -Chris