8181810: PPC64: Leverage extrdi for bitfield extract

Thu, 12 Oct 2017 16:36:12 +0100

author
mdoerr
date
Thu, 12 Oct 2017 16:36:12 +0100
changeset 8906
584eac5794ff
parent 8905
7c3dc80542b6
child 8908
d1b47c83a9dd

8181810: PPC64: Leverage extrdi for bitfield extract
Reviewed-by: mdoerr, simonis
Contributed-by: Matthew Brandyberry <mbrandy@linux.vnet.ibm.com>

src/cpu/ppc/vm/ppc.ad file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/ppc/vm/ppc.ad	Fri Nov 25 11:15:12 2016 -0200
     1.2 +++ b/src/cpu/ppc/vm/ppc.ad	Thu Oct 12 16:36:12 2017 +0100
     1.3 @@ -1,6 +1,6 @@
     1.4  //
     1.5  // Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 -// Copyright 2012, 2014 SAP AG. All rights reserved.
     1.7 +// Copyright (c) 2012, 2017 SAP SE. All rights reserved.
     1.8  // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.9  //
    1.10  // This code is free software; you can redistribute it and/or modify it
    1.11 @@ -8610,6 +8610,44 @@
    1.12    ins_pipe(pipe_class_default);
    1.13  %}
    1.14  
    1.15 +// Bitfield Extract: URShiftI + AndI
    1.16 +instruct andI_urShiftI_regI_immI_immIpow2minus1(iRegIdst dst, iRegIsrc src1, immI src2, immIpow2minus1 src3) %{
    1.17 +  match(Set dst (AndI (URShiftI src1 src2) src3));
    1.18 +
    1.19 +  format %{ "EXTRDI  $dst, $src1, shift=$src2, mask=$src3 \t// int bitfield extract" %}
    1.20 +  size(4);
    1.21 +  ins_encode %{
    1.22 +    // TODO: PPC port $archOpcode(ppc64Opcode_rldicl);
    1.23 +    int rshift = ($src2$$constant) & 0x1f;
    1.24 +    int length = log2_long(((jlong) $src3$$constant) + 1);
    1.25 +    if (rshift + length > 32) {
    1.26 +      // if necessary, adjust mask to omit rotated bits.
    1.27 +      length = 32 - rshift;
    1.28 +    }
    1.29 +    __ extrdi($dst$$Register, $src1$$Register, length, 64 - (rshift + length));
    1.30 +  %}
    1.31 +  ins_pipe(pipe_class_default);
    1.32 +%}
    1.33 +
    1.34 +// Bitfield Extract: URShiftL + AndL
    1.35 +instruct andL_urShiftL_regL_immI_immLpow2minus1(iRegLdst dst, iRegLsrc src1, immI src2, immLpow2minus1 src3) %{
    1.36 +  match(Set dst (AndL (URShiftL src1 src2) src3));
    1.37 +
    1.38 +  format %{ "EXTRDI  $dst, $src1, shift=$src2, mask=$src3 \t// long bitfield extract" %}
    1.39 +  size(4);
    1.40 +  ins_encode %{
    1.41 +    // TODO: PPC port $archOpcode(ppc64Opcode_rldicl);
    1.42 +    int rshift  = ($src2$$constant) & 0x3f;
    1.43 +    int length = log2_long(((jlong) $src3$$constant) + 1);
    1.44 +    if (rshift + length > 64) {
    1.45 +      // if necessary, adjust mask to omit rotated bits.
    1.46 +      length = 64 - rshift;
    1.47 +    }
    1.48 +    __ extrdi($dst$$Register, $src1$$Register, length, 64 - (rshift + length));
    1.49 +  %}
    1.50 +  ins_pipe(pipe_class_default);
    1.51 +%}
    1.52 +
    1.53  instruct sxtI_reg(iRegIdst dst, iRegIsrc src) %{
    1.54    match(Set dst (ConvL2I (ConvI2L src)));
    1.55  

mercurial