[LLVMdev] ISRs for PIC16 [was [llvm]r79631 ...]
Jim Grosbach
grosbach at apple.com
Tue Aug 25 09:29:52 PDT 2009
On Aug 25, 2009, at 8:59 AM, John Regehr wrote:
>> Function pointers are where things get fun. To do these, we need to
>> determine at run time whether we need to call the ISR or the mainline
>> version of a function
>
> This sounds convenient but it may well be overkill.
>
> On a PIC-class platform we can probably consider it to be a design
> flaw if
> the programmer doesn't know whether a function pointer will be
> dereferenced from interrupt context or not. This suggests that for
> any
> function whose address is taken, there could be a required
> annotation such
> as ISR_ONLY or NONISR_ONLY. The compiler could use this to do the
> right
> thing without any heroic static analysis or dynamic binding.
>
That could work as well; however, for the PIC16, I'd still be tempted
to go with a descriptor table for function pointers. Otherwise, a
function pointer would need to be 32-bits wide (16 for the function
itself, and 16 for the argument address). At that point, it's a very
short step to supporting the runtime decision about which version of
the function to call. Generally speaking, I've found that when
possible, it's best for the compiler to just do the right thing
without requiring additional annotations from the user. Every time
I've strayed from that in a PIC target compiler, I've regretted it.
Regards,
Jim
More information about the llvm-dev
mailing list