| 1413 | // zero/sign extend. "i" is limited to either classic unsigned (min==0) or |
| 1414 | // classic signed (min=minus-power-of-2); max=power-of-2-minus-1. |
| 1415 | private Node zsMask(Node val, Type t ) { |
| 1416 | if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) { |
| 1417 | if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) ) |
| 1418 | return val; |
| 1419 | // Float rounding |
| 1420 | return peep(new RoundF32Node(val)); |
| 1421 | } |
| 1422 | if( t0._min==0 ) // Unsigned |
| 1423 | return peep(new AndNode(null,val,con(t0._max))); |
| 1424 | // Signed extension |
| 1425 | int shift = Long.numberOfLeadingZeros(t0._max)-1; |
| 1426 | Node shf = con(shift); |
| 1427 | if( shf._type==TypeInteger.ZERO ) |
| 1428 | return val; |
| 1429 | return peep(new SarNode(null,peep(new ShlNode(null,val,shf.keep())),shf.unkeep())); |
| 1430 | } |
| 1431 | |
| 1432 | /** |
| 1433 | * Parse a function body; the caller will parse the surrounding "{}" |