11/*
2- * Copyright (c) 2009, 2022 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2009, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3232import jdk .graal .compiler .core .common .calc .FloatConvert ;
3333import jdk .graal .compiler .debug .Assertions ;
3434import jdk .graal .compiler .debug .GraalError ;
35- import jdk .graal .compiler .lir .asm .CompilationResultBuilder ;
3635import jdk .graal .compiler .lir .LIRInstructionClass ;
37-
36+ import jdk . graal . compiler . lir . asm . CompilationResultBuilder ;
3837import jdk .vm .ci .code .Register ;
3938import jdk .vm .ci .meta .AllocatableValue ;
4039
@@ -93,12 +92,24 @@ public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
9392 case D2L :
9493 masm .fcvtzs (toSize , fromSize , result , input );
9594 break ;
95+ case F2UI :
96+ case D2UI :
97+ case F2UL :
98+ case D2UL :
99+ masm .fcvtzu (toSize , fromSize , result , input );
100+ break ;
96101 case I2F :
97102 case I2D :
98103 case L2F :
99104 case L2D :
100105 masm .scvtf (toSize , fromSize , result , input );
101106 break ;
107+ case UI2F :
108+ case UI2D :
109+ case UL2F :
110+ case UL2D :
111+ masm .ucvtf (toSize , fromSize , result , input );
112+ break ;
102113 case D2F :
103114 case F2D :
104115 masm .fcvt (toSize , fromSize , result , input );
@@ -229,18 +240,24 @@ private boolean verifyConversionSizes(ElementSize dstESize, ElementSize srcESize
229240 switch (op ) {
230241 case F2I :
231242 case I2F :
243+ case F2UI :
244+ case UI2F :
232245 assert srcESize == ElementSize .Word && dstESize == ElementSize .Word : Assertions .errorMessage (srcESize , dstESize );
233246 break ;
234247 case F2D :
235248 case I2D :
249+ case UI2D :
236250 assert srcESize == ElementSize .Word && dstESize == ElementSize .DoubleWord : Assertions .errorMessage (srcESize , dstESize );
237251 break ;
238252 case D2F :
239253 case D2I :
254+ case D2UI :
240255 assert srcESize == ElementSize .DoubleWord && dstESize == ElementSize .Word : Assertions .errorMessage (srcESize , dstESize );
241256 break ;
242257 case D2L :
243258 case L2D :
259+ case D2UL :
260+ case UL2D :
244261 assert srcESize == ElementSize .DoubleWord && dstESize == ElementSize .DoubleWord : Assertions .errorMessage (srcESize , dstESize );
245262 break ;
246263 }
@@ -258,17 +275,21 @@ public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
258275 Register input = asRegister (inputValue );
259276 switch (op ) {
260277 case F2I :
261- masm .neon .fcvtzsVV (size , srcESize , result , input );
262- break ;
263278 case D2L :
264279 masm .neon .fcvtzsVV (size , srcESize , result , input );
265280 break ;
266- case I2F :
267- masm .neon .scvtfVV (size , srcESize , result , input );
281+ case F2UI :
282+ case D2UL :
283+ masm .neon .fcvtzuVV (size , srcESize , result , input );
268284 break ;
285+ case I2F :
269286 case L2D :
270287 masm .neon .scvtfVV (size , srcESize , result , input );
271288 break ;
289+ case UI2F :
290+ case UL2D :
291+ masm .neon .ucvtfVV (size , srcESize , result , input );
292+ break ;
272293 case D2F :
273294 masm .neon .fcvtnVV (srcESize , result , input );
274295 break ;
@@ -280,16 +301,28 @@ public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
280301 masm .neon .sxtlVV (srcESize , result , input );
281302 masm .neon .scvtfVV (size , ElementSize .fromKind (resultValue .getPlatformKind ()), result , result );
282303 break ;
304+ case UI2D :
305+ /* First unsigned extend int to long, then unsigned convert to double */
306+ masm .neon .uxtlVV (srcESize , result , input );
307+ masm .neon .ucvtfVV (size , ElementSize .fromKind (resultValue .getPlatformKind ()), result , result );
308+ break ;
283309 case D2I :
284- /* First convert double to long, then to int */
310+ /* First convert double to long, then saturating extract int */
285311 masm .neon .fcvtzsVV (size , srcESize , result , input );
286- masm .neon .xtnVV (dstESize , result , result );
312+ masm .neon .sqxtnVV (dstESize , result , result );
313+ break ;
314+ case D2UI :
315+ /* First convert double to unsigned long, then saturating extract uint */
316+ masm .neon .fcvtzuVV (size , srcESize , result , input );
317+ masm .neon .uqxtnVV (dstESize , result , result );
287318 break ;
288319 /*
289320 * It is not possible to handle these conversions correctly without losing fidelity.
290321 */
291322 case F2L :
292323 case L2F :
324+ case F2UL :
325+ case UL2F :
293326 default :
294327 throw GraalError .shouldNotReachHere ("Unsupported conversion requested." ); // ExcludeFromJacocoGeneratedReport
295328 }
0 commit comments