< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.sparc/src/org/graalvm/compiler/hotspot/sparc/SPARCHotSpotMove.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.hotspot.sparc;
  26 

  27 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BPR;
  28 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.Annul.ANNUL;


  29 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BranchPredict.PREDICT_TAKEN;

  30 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.RCondition.Rc_z;
  31 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.ILLEGAL;
  32 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
  33 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.STACK;
  34 import static org.graalvm.compiler.lir.sparc.SPARCMove.loadFromConstantTable;
  35 import static jdk.vm.ci.code.ValueUtil.asRegister;
  36 
  37 import org.graalvm.compiler.asm.Label;
  38 import org.graalvm.compiler.asm.sparc.SPARCAddress;
  39 import org.graalvm.compiler.asm.sparc.SPARCAssembler.CC;
  40 import org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag;
  41 import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler;
  42 import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister;
  43 import org.graalvm.compiler.core.common.CompressEncoding;
  44 import org.graalvm.compiler.lir.LIRInstructionClass;
  45 import org.graalvm.compiler.lir.StandardOp.LoadConstantOp;
  46 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  47 import org.graalvm.compiler.lir.sparc.SPARCDelayedControlTransfer;
  48 import org.graalvm.compiler.lir.sparc.SPARCLIRInstruction;
  49 import org.graalvm.compiler.lir.sparc.SPARCTailDelayedLIRInstruction;
  50 
  51 import jdk.vm.ci.code.Register;
  52 import jdk.vm.ci.code.ValueUtil;
  53 import jdk.vm.ci.hotspot.HotSpotConstant;
  54 import jdk.vm.ci.meta.AllocatableValue;
  55 import jdk.vm.ci.meta.Constant;

  56 
  57 public class SPARCHotSpotMove {
  58 
  59     public static class LoadHotSpotObjectConstantInline extends SPARCLIRInstruction implements SPARCTailDelayedLIRInstruction, LoadConstantOp {
  60         public static final LIRInstructionClass<LoadHotSpotObjectConstantInline> TYPE = LIRInstructionClass.create(LoadHotSpotObjectConstantInline.class);
  61 
  62         public static final SizeEstimate SIZE = SizeEstimate.create(8);
  63         private HotSpotConstant constant;
  64         @Def({REG, STACK}) AllocatableValue result;
  65 
  66         public LoadHotSpotObjectConstantInline(HotSpotConstant constant, AllocatableValue result) {
  67             super(TYPE, SIZE);
  68             this.constant = constant;
  69             this.result = result;
  70         }
  71 
  72         @Override
  73         protected void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
  74             crb.recordInlineDataInCode(constant);
  75             if (constant.isCompressed()) {


 133         @Def({REG}) protected AllocatableValue result;
 134         @Use({REG}) protected AllocatableValue input;
 135         @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
 136 
 137         public CompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
 138             super(TYPE, SIZE);
 139             this.result = result;
 140             this.input = input;
 141             this.baseRegister = baseRegister;
 142             this.encoding = encoding;
 143             this.nonNull = nonNull;
 144         }
 145 
 146         @Override
 147         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
 148             Register inputRegister = asRegister(input);
 149             Register resReg = asRegister(result);
 150             if (encoding.hasBase()) {
 151                 Register baseReg = asRegister(baseRegister);
 152                 if (!nonNull) {
 153                     masm.cmp(inputRegister, baseReg);
 154                     masm.movcc(ConditionFlag.Equal, CC.Xcc, baseReg, resReg);
 155                     masm.sub(resReg, baseReg, resReg);














 156                 } else {
 157                     masm.sub(inputRegister, baseReg, resReg);



 158                 }

 159                 if (encoding.getShift() != 0) {
 160                     masm.srlx(resReg, encoding.getShift(), resReg);
 161                 }
 162             } else {
 163                 masm.srlx(inputRegister, encoding.getShift(), resReg);
 164             }
 165         }
 166     }
 167 
 168     public static final class UncompressPointer extends SPARCLIRInstruction {
 169         public static final LIRInstructionClass<UncompressPointer> TYPE = LIRInstructionClass.create(UncompressPointer.class);
 170         public static final SizeEstimate SIZE = SizeEstimate.create(4);
 171 
 172         private final CompressEncoding encoding;
 173         private final boolean nonNull;
 174 
 175         @Def({REG}) protected AllocatableValue result;
 176         @Use({REG}) protected AllocatableValue input;
 177         @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
 178 
 179         public UncompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
 180             super(TYPE, SIZE);
 181             this.result = result;
 182             this.input = input;
 183             this.baseRegister = baseRegister;
 184             this.encoding = encoding;
 185             this.nonNull = nonNull;
 186         }
 187 
 188         @Override
 189         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
 190             Register inputRegister = asRegister(input);
 191             Register resReg = asRegister(result);
 192             Register baseReg = encoding.hasBase() ? asRegister(baseRegister) : null;
 193             emitUncompressCode(masm, inputRegister, resReg, baseReg, encoding.getShift(), nonNull);
 194         }
 195 
 196         public static void emitUncompressCode(SPARCMacroAssembler masm, Register inputRegister, Register resReg, Register baseReg, int shift, boolean nonNull) {
 197             Register secondaryInput;
 198             if (shift != 0) {
 199                 masm.sll(inputRegister, shift, resReg);
 200                 secondaryInput = resReg;
 201             } else {
 202                 secondaryInput = inputRegister;
 203             }
 204 
 205             if (baseReg != null) {
 206                 if (nonNull) {
 207                     masm.add(secondaryInput, baseReg, resReg);
 208                 } else {
 209                     Label done = new Label();
 210                     BPR.emit(masm, Rc_z, ANNUL, PREDICT_TAKEN, secondaryInput, done);
 211                     masm.add(baseReg, secondaryInput, resReg);
 212                     masm.bind(done);
 213                 }
 214             }
 215         }
 216     }
 217 
 218 }


   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.hotspot.sparc;
  26 
  27 import static jdk.vm.ci.code.ValueUtil.asRegister;
  28 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BPR;
  29 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.Annul.ANNUL;
  30 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.Annul.NOT_ANNUL;
  31 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BranchPredict.PREDICT_NOT_TAKEN;
  32 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BranchPredict.PREDICT_TAKEN;
  33 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.RCondition.Rc_nz;
  34 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.RCondition.Rc_z;
  35 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.ILLEGAL;
  36 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
  37 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.STACK;
  38 import static org.graalvm.compiler.lir.sparc.SPARCMove.loadFromConstantTable;

  39 
  40 import org.graalvm.compiler.asm.Label;
  41 import org.graalvm.compiler.asm.sparc.SPARCAddress;


  42 import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler;
  43 import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister;
  44 import org.graalvm.compiler.core.common.CompressEncoding;
  45 import org.graalvm.compiler.lir.LIRInstructionClass;
  46 import org.graalvm.compiler.lir.StandardOp.LoadConstantOp;
  47 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  48 import org.graalvm.compiler.lir.sparc.SPARCDelayedControlTransfer;
  49 import org.graalvm.compiler.lir.sparc.SPARCLIRInstruction;
  50 import org.graalvm.compiler.lir.sparc.SPARCTailDelayedLIRInstruction;
  51 
  52 import jdk.vm.ci.code.Register;
  53 import jdk.vm.ci.code.ValueUtil;
  54 import jdk.vm.ci.hotspot.HotSpotConstant;
  55 import jdk.vm.ci.meta.AllocatableValue;
  56 import jdk.vm.ci.meta.Constant;
  57 import jdk.vm.ci.sparc.SPARC;
  58 
  59 public class SPARCHotSpotMove {
  60 
  61     public static class LoadHotSpotObjectConstantInline extends SPARCLIRInstruction implements SPARCTailDelayedLIRInstruction, LoadConstantOp {
  62         public static final LIRInstructionClass<LoadHotSpotObjectConstantInline> TYPE = LIRInstructionClass.create(LoadHotSpotObjectConstantInline.class);
  63 
  64         public static final SizeEstimate SIZE = SizeEstimate.create(8);
  65         private HotSpotConstant constant;
  66         @Def({REG, STACK}) AllocatableValue result;
  67 
  68         public LoadHotSpotObjectConstantInline(HotSpotConstant constant, AllocatableValue result) {
  69             super(TYPE, SIZE);
  70             this.constant = constant;
  71             this.result = result;
  72         }
  73 
  74         @Override
  75         protected void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
  76             crb.recordInlineDataInCode(constant);
  77             if (constant.isCompressed()) {


 135         @Def({REG}) protected AllocatableValue result;
 136         @Use({REG}) protected AllocatableValue input;
 137         @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
 138 
 139         public CompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
 140             super(TYPE, SIZE);
 141             this.result = result;
 142             this.input = input;
 143             this.baseRegister = baseRegister;
 144             this.encoding = encoding;
 145             this.nonNull = nonNull;
 146         }
 147 
 148         @Override
 149         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
 150             Register inputRegister = asRegister(input);
 151             Register resReg = asRegister(result);
 152             if (encoding.hasBase()) {
 153                 Register baseReg = asRegister(baseRegister);
 154                 if (!nonNull) {
 155                     Label done = new Label();
 156                     if (inputRegister.equals(resReg)) {
 157                         BPR.emit(masm, Rc_nz, ANNUL, PREDICT_TAKEN, inputRegister, done);
 158                         masm.sub(inputRegister, baseReg, resReg);
 159                         masm.bind(done);
 160                         if (encoding.getShift() != 0) {
 161                             masm.srlx(resReg, encoding.getShift(), resReg);
 162                         }
 163                     } else {
 164                         BPR.emit(masm, Rc_z, NOT_ANNUL, PREDICT_NOT_TAKEN, inputRegister, done);
 165                         masm.mov(SPARC.g0, resReg);
 166                         masm.sub(inputRegister, baseReg, resReg);
 167                         if (encoding.getShift() != 0) {
 168                             masm.srlx(resReg, encoding.getShift(), resReg);
 169                         }
 170                         masm.bind(done);
 171                     }
 172                 } else {
 173                     masm.sub(inputRegister, baseReg, resReg);
 174                     if (encoding.getShift() != 0) {
 175                         masm.srlx(resReg, encoding.getShift(), resReg);
 176                     }
 177                 }
 178             } else {
 179                 if (encoding.getShift() != 0) {
 180                     masm.srlx(inputRegister, encoding.getShift(), resReg);
 181                 }


 182             }
 183         }
 184     }
 185 
 186     public static final class UncompressPointer extends SPARCLIRInstruction {
 187         public static final LIRInstructionClass<UncompressPointer> TYPE = LIRInstructionClass.create(UncompressPointer.class);
 188         public static final SizeEstimate SIZE = SizeEstimate.create(4);
 189 
 190         private final CompressEncoding encoding;
 191         private final boolean nonNull;
 192 
 193         @Def({REG}) protected AllocatableValue result;
 194         @Use({REG}) protected AllocatableValue input;
 195         @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
 196 
 197         public UncompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
 198             super(TYPE, SIZE);
 199             this.result = result;
 200             this.input = input;
 201             this.baseRegister = baseRegister;
 202             this.encoding = encoding;
 203             this.nonNull = nonNull;
 204         }
 205 
 206         @Override
 207         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
 208             Register inputRegister = asRegister(input);
 209             Register resReg = asRegister(result);
 210             Register baseReg = encoding.hasBase() ? asRegister(baseRegister) : null;
 211             emitUncompressCode(masm, inputRegister, resReg, baseReg, encoding.getShift(), nonNull);
 212         }
 213 
 214         public static void emitUncompressCode(SPARCMacroAssembler masm, Register inputRegister, Register resReg, Register baseReg, int shift, boolean nonNull) {
 215             Register secondaryInput;
 216             if (shift != 0) {
 217                 masm.sllx(inputRegister, shift, resReg);
 218                 secondaryInput = resReg;
 219             } else {
 220                 secondaryInput = inputRegister;
 221             }
 222 
 223             if (baseReg != null) {
 224                 if (nonNull) {
 225                     masm.add(secondaryInput, baseReg, resReg);
 226                 } else {
 227                     Label done = new Label();
 228                     BPR.emit(masm, Rc_nz, ANNUL, PREDICT_TAKEN, secondaryInput, done);
 229                     masm.add(baseReg, secondaryInput, resReg);
 230                     masm.bind(done);
 231                 }
 232             }
 233         }
 234     }
 235 
 236 }
< prev index next >