< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/type/PrimitiveStamp.java

Print this page




  22  */
  23 
  24 
  25 package org.graalvm.compiler.core.common.type;
  26 
  27 import jdk.vm.ci.meta.Constant;
  28 import jdk.vm.ci.meta.MemoryAccessProvider;
  29 
  30 /**
  31  * Type describing primitive values.
  32  */
  33 public abstract class PrimitiveStamp extends ArithmeticStamp {
  34 
  35     private final int bits;
  36 
  37     protected PrimitiveStamp(int bits, ArithmeticOpTable ops) {
  38         super(ops);
  39         this.bits = bits;
  40     }
  41 





  42     /**
  43      * The width in bits of the value described by this stamp.
  44      */
  45     public int getBits() {
  46         return bits;
  47     }
  48 
  49     public static int getBits(Stamp stamp) {
  50         if (stamp instanceof PrimitiveStamp) {
  51             return ((PrimitiveStamp) stamp).getBits();
  52         } else {
  53             return 0;
  54         }
  55     }
  56 
  57     @Override
  58     public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
  59         try {
  60             return provider.readPrimitiveConstant(getStackKind(), base, displacement, getBits());
  61         } catch (IllegalArgumentException e) {




  22  */
  23 
  24 
  25 package org.graalvm.compiler.core.common.type;
  26 
  27 import jdk.vm.ci.meta.Constant;
  28 import jdk.vm.ci.meta.MemoryAccessProvider;
  29 
  30 /**
  31  * Type describing primitive values.
  32  */
  33 public abstract class PrimitiveStamp extends ArithmeticStamp {
  34 
  35     private final int bits;
  36 
  37     protected PrimitiveStamp(int bits, ArithmeticOpTable ops) {
  38         super(ops);
  39         this.bits = bits;
  40     }
  41 
  42     @Override
  43     public void accept(Visitor v) {
  44         v.visitInt(bits);
  45     }
  46 
  47     /**
  48      * The width in bits of the value described by this stamp.
  49      */
  50     public int getBits() {
  51         return bits;
  52     }
  53 
  54     public static int getBits(Stamp stamp) {
  55         if (stamp instanceof PrimitiveStamp) {
  56             return ((PrimitiveStamp) stamp).getBits();
  57         } else {
  58             return 0;
  59         }
  60     }
  61 
  62     @Override
  63     public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
  64         try {
  65             return provider.readPrimitiveConstant(getStackKind(), base, displacement, getBits());
  66         } catch (IllegalArgumentException e) {


< prev index next >