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

Method zsMask

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

Source from the content-addressed store, hash-verified

926 // zero/sign extend. "i" is limited to either classic unsigned (min==0) or
927 // classic signed (min=minus-power-of-2); max=power-of-2-minus-1.
928 private Node zsMask(Node val, Type t ) {
929 if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) {
930 if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) )
931 return val;
932 // Float rounding
933 return new RoundF32Node(val).peephole();
934 }
935 if( t0._min==0 ) // Unsigned
936 return new AndNode(val,con(t0._max)).peephole();
937 // Signed extension
938 int shift = Long.numberOfLeadingZeros(t0._max)-1;
939 Node shf = con(shift);
940 if( shf._type==TypeInteger.ZERO )
941 return val;
942 return new SarNode(new ShlNode(val,shf.keep()).peephole(),shf.unkeep()).peephole();
943 }
944
945
946 /**

Callers 2

parseAsgnMethod · 0.95
parsePostfixMethod · 0.95

Calls 5

conMethod · 0.95
keepMethod · 0.95
unkeepMethod · 0.95
isaMethod · 0.45
peepholeMethod · 0.45

Tested by

no test coverage detected