< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64Compare.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.aarch64;
  26 


  27 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.CONST;
  28 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
  29 import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
  30 import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
  31 import static jdk.vm.ci.code.ValueUtil.asRegister;
  32 import static jdk.vm.ci.code.ValueUtil.isRegister;
  33 
  34 import org.graalvm.compiler.core.common.NumUtil;
  35 import org.graalvm.compiler.asm.aarch64.AArch64Assembler;
  36 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;

  37 import org.graalvm.compiler.core.common.calc.Condition;
  38 import org.graalvm.compiler.debug.GraalError;
  39 import org.graalvm.compiler.lir.LIRInstructionClass;
  40 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  41 
  42 import jdk.vm.ci.aarch64.AArch64Kind;
  43 import jdk.vm.ci.meta.JavaConstant;
  44 import jdk.vm.ci.meta.Value;
  45 
  46 public class AArch64Compare {
  47 
  48     public static class CompareOp extends AArch64LIRInstruction {
  49         public static final LIRInstructionClass<CompareOp> TYPE = LIRInstructionClass.create(CompareOp.class);
  50 
  51         @Use protected Value x;
  52         @Use({REG, CONST}) protected Value y;
  53 
  54         public CompareOp(Value x, Value y) {
  55             super(TYPE);
  56             assert ((AArch64Kind) x.getPlatformKind()).isInteger() && ((AArch64Kind) y.getPlatformKind()).isInteger();
  57             assert x.getPlatformKind() == y.getPlatformKind();
  58             this.x = x;
  59             this.y = y;
  60         }
  61 
  62         @Override
  63         public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
  64             gpCompare(masm, x, y);
  65         }
  66     }
  67 
  68     /**
  69      * Compares integer values x and y.
  70      *
  71      * @param x integer value to compare. May not be null.
  72      * @param y integer value to compare. May not be null.
  73      */
  74     public static void gpCompare(AArch64MacroAssembler masm, Value x, Value y) {
  75         final int size = x.getPlatformKind().getSizeInBytes() * Byte.SIZE;
  76         if (isRegister(y)) {
  77             masm.cmp(size, asRegister(x), asRegister(y));




   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.aarch64;
  26 
  27 import static jdk.vm.ci.code.ValueUtil.asRegister;
  28 import static jdk.vm.ci.code.ValueUtil.isRegister;
  29 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.CONST;
  30 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
  31 import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
  32 import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;


  33 

  34 import org.graalvm.compiler.asm.aarch64.AArch64Assembler;
  35 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
  36 import org.graalvm.compiler.core.common.NumUtil;
  37 import org.graalvm.compiler.core.common.calc.Condition;
  38 import org.graalvm.compiler.debug.GraalError;
  39 import org.graalvm.compiler.lir.LIRInstructionClass;
  40 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  41 

  42 import jdk.vm.ci.meta.JavaConstant;
  43 import jdk.vm.ci.meta.Value;
  44 
  45 public class AArch64Compare {
  46 
  47     public static class CompareOp extends AArch64LIRInstruction {
  48         public static final LIRInstructionClass<CompareOp> TYPE = LIRInstructionClass.create(CompareOp.class);
  49 
  50         @Use protected Value x;
  51         @Use({REG, CONST}) protected Value y;
  52 
  53         public CompareOp(Value x, Value y) {
  54             super(TYPE);
  55             assert x.getPlatformKind() == y.getPlatformKind() : x.getPlatformKind() + " " + y.getPlatformKind();

  56             this.x = x;
  57             this.y = y;
  58         }
  59 
  60         @Override
  61         public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
  62             gpCompare(masm, x, y);
  63         }
  64     }
  65 
  66     /**
  67      * Compares integer values x and y.
  68      *
  69      * @param x integer value to compare. May not be null.
  70      * @param y integer value to compare. May not be null.
  71      */
  72     public static void gpCompare(AArch64MacroAssembler masm, Value x, Value y) {
  73         final int size = x.getPlatformKind().getSizeInBytes() * Byte.SIZE;
  74         if (isRegister(y)) {
  75             masm.cmp(size, asRegister(x), asRegister(y));


< prev index next >