[LLVMdev] LLVM and Interrupt Service Routines.

Alireza.Moshtaghi at microchip.com Alireza.Moshtaghi at microchip.com
Fri Jul 24 10:41:34 PDT 2009


Please read below:

> > - Save /all/ registers, including those that are normally caller
> > saved.
> > - Use a special return instruction (RETI).
> > - Step over the "red zone" on the stack.
> > - Set up a safe stack frame before calling normal functions.
> >
> > I usually write the first level interrupt handler in assembler, and
> > then
> > call normal C function from there.
> 
> Wouldn't a custom calling convention work for all of these
requirements?
> 

Custom calling convention can work for the above, but for PIC16 these
are not the only things to do...
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.

Regards
Ali




More information about the llvm-dev mailing list