-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
The current IL switch as a form similar to this.
switch ( n : u32 ){ L1 : i32 .. Ln:i32 }
[ 45 02 00 00 00 03 00 00 00 05 00 00 00 ]
which can be a waste of byte if the destinations of the switch branches are relatively close.
So I propose to additional prefixes to IL.
tiny.
The tiny. prefix requires the parameters to by 1 byte in width, and the branches are now relative jumps.
tiny.switch ( n : u8 ){ J1 : i8 , Jn : i8 }
[ FD 45 02 03 05 ]
mini.
The mini. prefix requires the parameters to be 2 bytes in width, and the branches are now relative jumps.
mini.switch { n : u16 ){ J1 : i16, Jn : i16 }
[ FC 45 02 00 03 00 05 00 ]
This would reduce the size of the produced IL
Other possible uses for mini. and tiny. are prefixing JMP and Branch ins instructions.
Note:
The actual byte codes used I've selected may clash with pre-existing IL instructions, from the information available to me, suggest that FC and FD are unused.
category:proposal
theme:msil
skill-level:intermediate
cost:large