Parse a function body; the caller will parse the surrounding "{}" { [type arg,] -> expr } { expr } // The no-argument function
()
| 1438 | |
| 1439 | |
| 1440 | // zero/sign extend. "i" is limited to either classic unsigned (min==0) or |
| 1441 | // classic signed (min=minus-power-of-2); max=power-of-2-minus-1. |
| 1442 | private Node zsMask(Node val, Type t ) { |
| 1443 | if( val._type instanceof TypeFloat && t instanceof TypeInteger ) |
| 1444 | val = new ToIntegerNode(val).peephole(); |
| 1445 | if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) { |
| 1446 | if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) ) |
| 1447 | return val; |
| 1448 | // Float rounding |
| 1449 | return peep(new RoundF32Node(val)); |
| 1450 | } |
| 1451 | if( t0._min==0 ) // Unsigned |
| 1452 | return peep(new AndNode(null,val,con(t0._max))); |
| 1453 | // Signed extension |
| 1454 | int shift = Long.numberOfLeadingZeros(t0._max)-1; |
| 1455 | Node shf = con(shift); |
| 1456 | if( shf._type==TypeInteger.ZERO ) |
| 1457 | return val; |
| 1458 | return peep(new SarNode(null,peep(new ShlNode(null,val,shf.keep())),shf.unkeep())); |
| 1459 | } |
| 1460 | |
| 1461 | /** |
no test coverage detected