< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/LIRGeneratorTool.java

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.lir.gen;
  26 



  27 import org.graalvm.compiler.core.common.CompressEncoding;
  28 import org.graalvm.compiler.core.common.LIRKind;
  29 import org.graalvm.compiler.core.common.calc.Condition;
  30 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  31 import org.graalvm.compiler.core.common.spi.CodeGenProviders;
  32 import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
  33 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
  34 import org.graalvm.compiler.core.common.type.Stamp;
  35 import org.graalvm.compiler.debug.GraalError;
  36 import org.graalvm.compiler.graph.NodeSourcePosition;
  37 import org.graalvm.compiler.lir.LIRFrameState;
  38 import org.graalvm.compiler.lir.LIRInstruction;
  39 import org.graalvm.compiler.lir.LabelRef;
  40 import org.graalvm.compiler.lir.SwitchStrategy;
  41 import org.graalvm.compiler.lir.Variable;

  42 
  43 import jdk.vm.ci.code.CodeCacheProvider;
  44 import jdk.vm.ci.code.Register;
  45 import jdk.vm.ci.code.RegisterAttributes;
  46 import jdk.vm.ci.code.RegisterConfig;

  47 import jdk.vm.ci.code.TargetDescription;
  48 import jdk.vm.ci.code.ValueKindFactory;
  49 import jdk.vm.ci.meta.AllocatableValue;
  50 import jdk.vm.ci.meta.Constant;
  51 import jdk.vm.ci.meta.JavaConstant;
  52 import jdk.vm.ci.meta.JavaKind;
  53 import jdk.vm.ci.meta.MetaAccessProvider;
  54 import jdk.vm.ci.meta.PlatformKind;
  55 import jdk.vm.ci.meta.Value;
  56 import jdk.vm.ci.meta.ValueKind;
  57 
  58 public interface LIRGeneratorTool extends DiagnosticLIRGeneratorTool, ValueKindFactory<LIRKind> {
  59 
  60     /**
  61      * Factory for creating moves.
  62      */
  63     interface MoveFactory {
  64 
  65         /**
  66          * Checks whether the supplied constant can be used without loading it into a register for


 247     void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueSuccessorProbability);
 248 
 249     Variable emitConditionalMove(PlatformKind cmpKind, Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue);
 250 
 251     Variable emitIntegerTestMove(Value leftVal, Value right, Value trueValue, Value falseValue);
 252 
 253     void emitStrategySwitch(JavaConstant[] keyConstants, double[] keyProbabilities, LabelRef[] keyTargets, LabelRef defaultTarget, Variable value);
 254 
 255     void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget);
 256 
 257     Variable emitByteSwap(Value operand);
 258 
 259     @SuppressWarnings("unused")
 260     default Variable emitArrayCompareTo(JavaKind kind1, JavaKind kind2, Value array1, Value array2, Value length1, Value length2) {
 261         throw GraalError.unimplemented("String.compareTo substitution is not implemented on this architecture");
 262     }
 263 
 264     Variable emitArrayEquals(JavaKind kind, Value array1, Value array2, Value length, int constantLength, boolean directPointers);
 265 
 266     @SuppressWarnings("unused")





 267     default Variable emitArrayIndexOf(JavaKind kind, boolean findTwoConsecutive, Value sourcePointer, Value sourceCount, Value... searchValues) {
 268         throw GraalError.unimplemented("String.indexOf substitution is not implemented on this architecture");
 269     }
 270 
 271     /*
 272      * The routines emitStringLatin1Inflate/3 and emitStringUTF16Compress/3 models a simplified
 273      * version of
 274      *
 275      * emitStringLatin1Inflate(Value src, Value src_ndx, Value dst, Value dst_ndx, Value len) and
 276      * emitStringUTF16Compress(Value src, Value src_ndx, Value dst, Value dst_ndx, Value len)
 277      *
 278      * respectively, where we have hoisted the offset address computations in a method replacement
 279      * snippet.
 280      */
 281     @SuppressWarnings("unused")
 282     default void emitStringLatin1Inflate(Value src, Value dst, Value len) {
 283         throw GraalError.unimplemented("StringLatin1.inflate substitution is not implemented on this architecture");
 284     }
 285 
 286     @SuppressWarnings("unused")


 296 
 297     void emitPrefetchAllocate(Value address);
 298 
 299     Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull);
 300 
 301     Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull);
 302 
 303     default void emitConvertNullToZero(AllocatableValue result, Value input) {
 304         emitMove(result, input);
 305     }
 306 
 307     default void emitConvertZeroToNull(AllocatableValue result, Value input) {
 308         emitMove(result, input);
 309     }
 310 
 311     /**
 312      * Emits an instruction that prevents speculative execution from proceeding: no instruction
 313      * after this fence will execute until all previous instructions have retired.
 314      */
 315     void emitSpeculationFence();

















 316 }


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.lir.gen;
  26 
  27 import java.util.BitSet;
  28 import java.util.List;
  29 
  30 import org.graalvm.compiler.core.common.CompressEncoding;
  31 import org.graalvm.compiler.core.common.LIRKind;
  32 import org.graalvm.compiler.core.common.calc.Condition;
  33 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  34 import org.graalvm.compiler.core.common.spi.CodeGenProviders;
  35 import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
  36 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
  37 import org.graalvm.compiler.core.common.type.Stamp;
  38 import org.graalvm.compiler.debug.GraalError;
  39 import org.graalvm.compiler.graph.NodeSourcePosition;
  40 import org.graalvm.compiler.lir.LIRFrameState;
  41 import org.graalvm.compiler.lir.LIRInstruction;
  42 import org.graalvm.compiler.lir.LabelRef;
  43 import org.graalvm.compiler.lir.SwitchStrategy;
  44 import org.graalvm.compiler.lir.Variable;
  45 import org.graalvm.compiler.lir.VirtualStackSlot;
  46 
  47 import jdk.vm.ci.code.CodeCacheProvider;
  48 import jdk.vm.ci.code.Register;
  49 import jdk.vm.ci.code.RegisterAttributes;
  50 import jdk.vm.ci.code.RegisterConfig;
  51 import jdk.vm.ci.code.StackSlot;
  52 import jdk.vm.ci.code.TargetDescription;
  53 import jdk.vm.ci.code.ValueKindFactory;
  54 import jdk.vm.ci.meta.AllocatableValue;
  55 import jdk.vm.ci.meta.Constant;
  56 import jdk.vm.ci.meta.JavaConstant;
  57 import jdk.vm.ci.meta.JavaKind;
  58 import jdk.vm.ci.meta.MetaAccessProvider;
  59 import jdk.vm.ci.meta.PlatformKind;
  60 import jdk.vm.ci.meta.Value;
  61 import jdk.vm.ci.meta.ValueKind;
  62 
  63 public interface LIRGeneratorTool extends DiagnosticLIRGeneratorTool, ValueKindFactory<LIRKind> {
  64 
  65     /**
  66      * Factory for creating moves.
  67      */
  68     interface MoveFactory {
  69 
  70         /**
  71          * Checks whether the supplied constant can be used without loading it into a register for


 252     void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueSuccessorProbability);
 253 
 254     Variable emitConditionalMove(PlatformKind cmpKind, Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue);
 255 
 256     Variable emitIntegerTestMove(Value leftVal, Value right, Value trueValue, Value falseValue);
 257 
 258     void emitStrategySwitch(JavaConstant[] keyConstants, double[] keyProbabilities, LabelRef[] keyTargets, LabelRef defaultTarget, Variable value);
 259 
 260     void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget);
 261 
 262     Variable emitByteSwap(Value operand);
 263 
 264     @SuppressWarnings("unused")
 265     default Variable emitArrayCompareTo(JavaKind kind1, JavaKind kind2, Value array1, Value array2, Value length1, Value length2) {
 266         throw GraalError.unimplemented("String.compareTo substitution is not implemented on this architecture");
 267     }
 268 
 269     Variable emitArrayEquals(JavaKind kind, Value array1, Value array2, Value length, int constantLength, boolean directPointers);
 270 
 271     @SuppressWarnings("unused")
 272     default Variable emitArrayEquals(JavaKind kind1, JavaKind kind2, Value array1, Value array2, Value length, int constantLength, boolean directPointers) {
 273         throw GraalError.unimplemented("Array.equals with different types substitution is not implemented on this architecture");
 274     }
 275 
 276     @SuppressWarnings("unused")
 277     default Variable emitArrayIndexOf(JavaKind kind, boolean findTwoConsecutive, Value sourcePointer, Value sourceCount, Value... searchValues) {
 278         throw GraalError.unimplemented("String.indexOf substitution is not implemented on this architecture");
 279     }
 280 
 281     /*
 282      * The routines emitStringLatin1Inflate/3 and emitStringUTF16Compress/3 models a simplified
 283      * version of
 284      *
 285      * emitStringLatin1Inflate(Value src, Value src_ndx, Value dst, Value dst_ndx, Value len) and
 286      * emitStringUTF16Compress(Value src, Value src_ndx, Value dst, Value dst_ndx, Value len)
 287      *
 288      * respectively, where we have hoisted the offset address computations in a method replacement
 289      * snippet.
 290      */
 291     @SuppressWarnings("unused")
 292     default void emitStringLatin1Inflate(Value src, Value dst, Value len) {
 293         throw GraalError.unimplemented("StringLatin1.inflate substitution is not implemented on this architecture");
 294     }
 295 
 296     @SuppressWarnings("unused")


 306 
 307     void emitPrefetchAllocate(Value address);
 308 
 309     Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull);
 310 
 311     Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull);
 312 
 313     default void emitConvertNullToZero(AllocatableValue result, Value input) {
 314         emitMove(result, input);
 315     }
 316 
 317     default void emitConvertZeroToNull(AllocatableValue result, Value input) {
 318         emitMove(result, input);
 319     }
 320 
 321     /**
 322      * Emits an instruction that prevents speculative execution from proceeding: no instruction
 323      * after this fence will execute until all previous instructions have retired.
 324      */
 325     void emitSpeculationFence();
 326 
 327     default VirtualStackSlot allocateStackSlots(int slots, BitSet objects, List<VirtualStackSlot> outObjectStackSlots) {
 328         return getResult().getFrameMapBuilder().allocateStackSlots(slots, objects, outObjectStackSlots);
 329     }
 330 
 331     default Value emitReadCallerStackPointer(Stamp wordStamp) {
 332         /*
 333          * We do not know the frame size yet. So we load the address of the first spill slot
 334          * relative to the beginning of the frame, which is equivalent to the stack pointer of the
 335          * caller.
 336          */
 337         return emitAddress(StackSlot.get(getLIRKind(wordStamp), 0, true));
 338     }
 339 
 340     default Value emitReadReturnAddress(Stamp wordStamp, int returnAddressSize) {
 341         return emitMove(StackSlot.get(getLIRKind(wordStamp), -returnAddressSize, true));
 342     }
 343 }
< prev index next >