This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

a proposal ?

I have a thought that would make many processes much more effective and, being only one voice, I would like to know if there is a demand before I propose it to Keil.

This is the result of me having to change a switch statement to a series of IFs to make an ISR process fast enough.

I realize, and thus do not complain, that Keil caould not implemet an ANSI-C switch more efficient than the way it is done.

'n' below will be either 2 or 3 (if Keil decide to implement, they can choose)

a Proposal:
if #pragma QUICKSWITCH then
a) no case value can be more than 255
b) all case values must be multiples of n
c) the switch will be implemented as a jump table

Erik

Parents
  • I have to agree with Erik on this one.
    thanks

    However, I don't see why a pragma would even be necessary

    The advantage of a #pragma as I see it would be that you effectively told the compiler "tell me if you can not do this". If an 'automatic' were implemented, you would never know (except through investigating the assembler) if you had achieved the goal. Of course, a possibility would be a #pragma TELL_IF_SWITCH_CAN_NOT_BE_JUMP_TABLE which would satisfy both approaches.

    Anyhow, I STILL can not see why this has anything to do with optimization. as I see it, the compiler should do the best it can without disrupting the flow, and leave 'worthless' statements (inserted to provide a breakpoint opportunity) in the code. Then, if desired, optimization (which may/should disrupt the flow and skip dead code) can be implemented. Using jump tables has NOTHING to do with optimization (except to make the result of optimizing look better)

    Erik

Reply
  • I have to agree with Erik on this one.
    thanks

    However, I don't see why a pragma would even be necessary

    The advantage of a #pragma as I see it would be that you effectively told the compiler "tell me if you can not do this". If an 'automatic' were implemented, you would never know (except through investigating the assembler) if you had achieved the goal. Of course, a possibility would be a #pragma TELL_IF_SWITCH_CAN_NOT_BE_JUMP_TABLE which would satisfy both approaches.

    Anyhow, I STILL can not see why this has anything to do with optimization. as I see it, the compiler should do the best it can without disrupting the flow, and leave 'worthless' statements (inserted to provide a breakpoint opportunity) in the code. Then, if desired, optimization (which may/should disrupt the flow and skip dead code) can be implemented. Using jump tables has NOTHING to do with optimization (except to make the result of optimizing look better)

    Erik

Children
  • The advantage of a #pragma as I see it would be that you effectively told the compiler "tell me if you can not do this". If an 'automatic' were implemented, you would never know (except through investigating the assembler) if you had achieved the goal.

    Good point. And I agree, the compiler should take every opportunity, regardless of OT level, to leverage direct jump tables if possible...IMO ;)