MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / zsMask

Method zsMask

chapter21/src/main/java/com/seaofnodes/simple/Parser.java:1341–1356  ·  view source on GitHub ↗
(Node val, Type t )

Source from the content-addressed store, hash-verified

1339 // zero/sign extend. "i" is limited to either classic unsigned (min==0) or
1340 // classic signed (min=minus-power-of-2); max=power-of-2-minus-1.
1341 private Node zsMask(Node val, Type t ) {
1342 if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) {
1343 if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) )
1344 return val;
1345 // Float rounding
1346 return peep(new RoundF32Node(val));
1347 }
1348 if( t0._min==0 ) // Unsigned
1349 return peep(new AndNode(null,val,con(t0._max)));
1350 // Signed extension
1351 int shift = Long.numberOfLeadingZeros(t0._max)-1;
1352 Node shf = con(shift);
1353 if( shf._type==TypeInteger.ZERO )
1354 return val;
1355 return peep(new SarNode(null,peep(new ShlNode(null,val,shf.keep())),shf.unkeep()));
1356 }
1357
1358 /**
1359 * Parse a function body; the caller will parse the surrounding "{}"

Callers 2

liftExprMethod · 0.95
parseUnaryMethod · 0.95

Calls 5

peepMethod · 0.95
conMethod · 0.95
keepMethod · 0.95
unkeepMethod · 0.95
isaMethod · 0.45

Tested by

no test coverage detected