src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java
changeset 58877 aec7bf35d6f5
parent 58533 46b0b7fe255c
equal deleted inserted replaced
58876:1a8d65e71a66 58877:aec7bf35d6f5
   218         Variable result = getLIRGen().newVariable(resultLirKind);
   218         Variable result = getLIRGen().newVariable(resultLirKind);
   219         getLIRGen().append(new AArch64FloatConvertOp(op, result, asAllocatable(inputVal)));
   219         getLIRGen().append(new AArch64FloatConvertOp(op, result, asAllocatable(inputVal)));
   220         return result;
   220         return result;
   221     }
   221     }
   222 
   222 
   223     public Value emitMAdd(Value a, Value b, Value c) {
   223     Value emitIntegerMAdd(Value a, Value b, Value c, boolean isI2L) {
   224         return emitMultiplyAddSub(AArch64ArithmeticOp.ADD, a, b, c);
   224         return emitMultiplyAddSub(isI2L ? AArch64ArithmeticOp.SMADDL : AArch64ArithmeticOp.MADD, a, b, c);
   225     }
   225     }
   226 
   226 
   227     public Value emitMSub(Value a, Value b, Value c) {
   227     Value emitIntegerMSub(Value a, Value b, Value c, boolean isI2L) {
   228         return emitMultiplyAddSub(AArch64ArithmeticOp.SUB, a, b, c);
   228         return emitMultiplyAddSub(isI2L ? AArch64ArithmeticOp.SMSUBL : AArch64ArithmeticOp.MSUB, a, b, c);
   229     }
   229     }
   230 
   230 
   231     private Value emitMultiplyAddSub(AArch64ArithmeticOp op, Value a, Value b, Value c) {
   231     private Value emitMultiplyAddSub(AArch64ArithmeticOp op, Value a, Value b, Value c) {
   232         assert a.getPlatformKind() == b.getPlatformKind() && b.getPlatformKind() == c.getPlatformKind();
   232         assert a.getPlatformKind() == b.getPlatformKind();
   233         if (op == AArch64ArithmeticOp.ADD || op == AArch64ArithmeticOp.SUB) {
   233         Variable result;
   234             assert isNumericInteger(a.getPlatformKind());
   234         if (op == AArch64ArithmeticOp.SMADDL || op == AArch64ArithmeticOp.SMSUBL) {
   235         } else if (op == AArch64ArithmeticOp.FADD) {
   235             // For signed multiply int and then add/sub long.
   236             assert a.getPlatformKind() == AArch64Kind.SINGLE || a.getPlatformKind() == AArch64Kind.DOUBLE;
   236             assert a.getPlatformKind() != c.getPlatformKind();
   237         }
   237             result = getLIRGen().newVariable(LIRKind.combine(c));
   238 
   238         } else {
   239         Variable result = getLIRGen().newVariable(LIRKind.combine(a, b, c));
   239             assert a.getPlatformKind() == c.getPlatformKind();
       
   240             if (op == AArch64ArithmeticOp.FADD) {
       
   241                 // For floating-point Math.fma intrinsic.
       
   242                 assert a.getPlatformKind() == AArch64Kind.SINGLE || a.getPlatformKind() == AArch64Kind.DOUBLE;
       
   243             } else {
       
   244                 // For int/long multiply add or sub.
       
   245                 assert op == AArch64ArithmeticOp.MADD || op == AArch64ArithmeticOp.MSUB;
       
   246                 assert isNumericInteger(a.getPlatformKind());
       
   247             }
       
   248             result = getLIRGen().newVariable(LIRKind.combine(a, b, c));
       
   249         }
       
   250 
   240         AllocatableValue x = moveSp(asAllocatable(a));
   251         AllocatableValue x = moveSp(asAllocatable(a));
   241         AllocatableValue y = moveSp(asAllocatable(b));
   252         AllocatableValue y = moveSp(asAllocatable(b));
   242         AllocatableValue z = moveSp(asAllocatable(c));
   253         AllocatableValue z = moveSp(asAllocatable(c));
   243         getLIRGen().append(new AArch64ArithmeticOp.MultiplyAddSubOp(op, result, x, y, z));
   254         getLIRGen().append(new AArch64ArithmeticOp.MultiplyAddSubOp(op, result, x, y, z));
   244         return result;
   255         return result;
   449         return result;
   460         return result;
   450     }
   461     }
   451 
   462 
   452     @Override
   463     @Override
   453     public Value emitFusedMultiplyAdd(Value a, Value b, Value c) {
   464     public Value emitFusedMultiplyAdd(Value a, Value b, Value c) {
   454         return emitMultiplyAddSub(AArch64ArithmeticOp.FADD, a, b, c);
   465         return emitMultiplyAddSub(AArch64ArithmeticOp.FMADD, a, b, c);
   455     }
   466     }
   456 
   467 
   457     @Override
   468     @Override
   458     public Value emitCountLeadingZeros(Value value) {
   469     public Value emitCountLeadingZeros(Value value) {
   459         Variable result = getLIRGen().newVariable(LIRKind.combine(value).changeType(AArch64Kind.DWORD));
   470         Variable result = getLIRGen().newVariable(LIRKind.combine(value).changeType(AArch64Kind.DWORD));