Ejemplo n.º 1
0
  public static Stamp add(IntegerStamp stamp1, IntegerStamp stamp2) {
    Kind kind = stamp1.kind();
    assert kind == stamp2.kind();
    if (addOverflow(stamp1.lowerBound(), stamp2.lowerBound(), kind)) {
      return StampFactory.forKind(kind);
    }
    if (addOverflow(stamp1.upperBound(), stamp2.upperBound(), kind)) {
      return StampFactory.forKind(kind);
    }
    long lowerBound = stamp1.lowerBound() + stamp2.lowerBound();
    long upperBound = stamp1.upperBound() + stamp2.upperBound();
    long mask = IntegerStamp.maskFor(kind, lowerBound, upperBound);

    return StampFactory.forInteger(kind, lowerBound, upperBound, mask);
  }
Ejemplo n.º 2
0
 public static Stamp div(IntegerStamp stamp1, IntegerStamp stamp2) {
   Kind kind = stamp1.kind();
   if (stamp2.isStrictlyPositive()) {
     long lowerBound = stamp1.lowerBound() / stamp2.lowerBound();
     long upperBound = stamp1.upperBound() / stamp2.lowerBound();
     return StampFactory.forInteger(
         kind, lowerBound, upperBound, IntegerStamp.maskFor(kind, lowerBound, upperBound));
   }
   return StampFactory.forKind(kind);
 }
Ejemplo n.º 3
0
 public static Stamp leftShift(IntegerStamp value, IntegerStamp shift) {
   Kind kind = value.kind();
   int shiftBits = kind == Kind.Int ? 5 : 6;
   long shiftMask = kind == Kind.Int ? 0x1FL : 0x3FL;
   if ((shift.lowerBound() >>> shiftBits) == (shift.upperBound() >>> shiftBits)) {
     long mask = 0;
     for (long i = shift.lowerBound() & shiftMask; i <= (shift.upperBound() & shiftMask); i++) {
       mask |= value.mask() << i;
     }
     mask &= IntegerStamp.defaultMask(kind);
     return stampForMask(kind, mask);
   }
   return StampFactory.forKind(kind);
 }
Ejemplo n.º 4
0
 public static Stamp negate(Stamp stamp) {
   Kind kind = stamp.kind();
   if (stamp instanceof IntegerStamp) {
     IntegerStamp integerStamp = (IntegerStamp) stamp;
     if (integerStamp.lowerBound() != kind.getMinValue()) {
       // TODO(ls) check if the mask calculation is correct...
       return new IntegerStamp(
           kind,
           -integerStamp.upperBound(),
           -integerStamp.lowerBound(),
           IntegerStamp.defaultMask(kind) & (integerStamp.mask() | -integerStamp.mask()));
     }
   }
   return StampFactory.forKind(kind);
 }
Ejemplo n.º 5
0
 protected DirectReadNode(ValueNode address, Kind readKind) {
   super(StampFactory.forKind(readKind.getStackKind()));
   this.address = address;
   this.readKind = readKind;
 }