switches in GCC JIT?

Basile Starynkevitch basile@starynkevitch.net
Thu Jan 1 00:00:00 GMT 2015


On 06/23/2015 02:25 AM, David Malcolm wrote:

> As it happens, none of the bytecode languages I've implemented so far
> have switch-like constructs.
>
> But I see now that the JVM has opcodes "lookupswitch" and "tableswitch";
> those alone make a compelling case for libgccjit supporting switches.
>
> I'm working on it now; the API I'm thinking of looks like this:
>
> extern void
> gcc_jit_block_end_with_switch (gcc_jit_block *block,
> 			          gcc_jit_location *loc,
> 			          gcc_jit_rvalue *expr,
> 			          gcc_jit_block *default_block,
> 			          int num_cases,
> 			          gcc_jit_rvalue **case_min_values,
> 			          gcc_jit_rvalue **case_max_values,
> 			          gcc_jit_block **case_blocks);
>
>
> thus supporting ranged cases, whilst also allowing individual values, by
> simply passing in the same table for both case_min_values and
> case_max_values.


Great. Don't forget in the documentation to say that simple cases can be 
be implemented by sharing the case_min_values & case_max_value, or 
perhaps even provide also a static inline function doing that.

A big thanks for being so responsive!

Regards

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***



More information about the Jit mailing list