< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.aarch64/src/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java

Print this page




  47 import static jdk.vm.ci.aarch64.AArch64.v6;
  48 import static jdk.vm.ci.aarch64.AArch64.v7;
  49 import static jdk.vm.ci.aarch64.AArch64.zr;
  50 
  51 import java.util.ArrayList;
  52 import java.util.Arrays;
  53 import java.util.Collections;
  54 import java.util.HashSet;
  55 import java.util.List;
  56 import java.util.Set;
  57 
  58 import jdk.vm.ci.aarch64.AArch64;
  59 import jdk.vm.ci.code.Architecture;
  60 import jdk.vm.ci.code.CallingConvention;
  61 import jdk.vm.ci.code.CallingConvention.Type;
  62 import jdk.vm.ci.code.Register;
  63 import jdk.vm.ci.code.RegisterAttributes;
  64 import jdk.vm.ci.code.RegisterConfig;
  65 import jdk.vm.ci.code.StackSlot;
  66 import jdk.vm.ci.code.TargetDescription;
  67 import jdk.vm.ci.common.JVMCIError;
  68 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  69 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  70 import jdk.vm.ci.meta.AllocatableValue;
  71 import jdk.vm.ci.meta.JavaKind;
  72 import jdk.vm.ci.meta.JavaType;
  73 import jdk.vm.ci.meta.LIRKind;
  74 import jdk.vm.ci.meta.PlatformKind;
  75 import jdk.vm.ci.meta.Value;
  76 
  77 public class AArch64HotSpotRegisterConfig implements RegisterConfig {
  78 
  79     private final Architecture architecture;
  80 
  81     private final Register[] allocatable;
  82 
  83     private final int maxFrameSize;
  84 
  85     /**
  86      * The caller saved registers always include all parameter registers.
  87      */


 209         // from the caller or callee perspective
 210         return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target);
 211     }
 212 
 213     @Override
 214     public Register[] getCallingConventionRegisters(Type type, JavaKind kind) {
 215         HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type;
 216         switch (kind) {
 217             case Boolean:
 218             case Byte:
 219             case Short:
 220             case Char:
 221             case Int:
 222             case Long:
 223             case Object:
 224                 return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters;
 225             case Float:
 226             case Double:
 227                 return simdParameterRegisters;
 228             default:
 229                 throw JVMCIError.shouldNotReachHere();
 230         }
 231     }
 232 
 233     private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) {
 234         AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
 235 
 236         int currentGeneral = 0;
 237         int currentSIMD = 0;
 238         int currentStackOffset = 0;
 239 
 240         for (int i = 0; i < parameterTypes.length; i++) {
 241             final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind();
 242 
 243             switch (kind) {
 244                 case Byte:
 245                 case Boolean:
 246                 case Short:
 247                 case Char:
 248                 case Int:
 249                 case Long:
 250                 case Object:
 251                     if (currentGeneral < generalParameterRegisters.length) {
 252                         Register register = generalParameterRegisters[currentGeneral++];
 253                         locations[i] = register.asValue(target.getLIRKind(kind));
 254                     }
 255                     break;
 256                 case Float:
 257                 case Double:
 258                     if (currentSIMD < simdParameterRegisters.length) {
 259                         Register register = simdParameterRegisters[currentSIMD++];
 260                         locations[i] = register.asValue(target.getLIRKind(kind));
 261                     }
 262                     break;
 263                 default:
 264                     throw JVMCIError.shouldNotReachHere();
 265             }
 266 
 267             if (locations[i] == null) {
 268                 LIRKind lirKind = target.getLIRKind(kind);
 269                 locations[i] = StackSlot.get(lirKind, currentStackOffset, !type.out);
 270                 currentStackOffset += Math.max(lirKind.getPlatformKind().getSizeInBytes(), target.wordSize);
 271             }
 272         }
 273 
 274         JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind();
 275         AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind()));
 276         return new CallingConvention(currentStackOffset, returnLocation, locations);
 277     }
 278 
 279     @Override
 280     public Register getReturnRegister(JavaKind kind) {
 281         switch (kind) {
 282             case Boolean:
 283             case Byte:
 284             case Char:




  47 import static jdk.vm.ci.aarch64.AArch64.v6;
  48 import static jdk.vm.ci.aarch64.AArch64.v7;
  49 import static jdk.vm.ci.aarch64.AArch64.zr;
  50 
  51 import java.util.ArrayList;
  52 import java.util.Arrays;
  53 import java.util.Collections;
  54 import java.util.HashSet;
  55 import java.util.List;
  56 import java.util.Set;
  57 
  58 import jdk.vm.ci.aarch64.AArch64;
  59 import jdk.vm.ci.code.Architecture;
  60 import jdk.vm.ci.code.CallingConvention;
  61 import jdk.vm.ci.code.CallingConvention.Type;
  62 import jdk.vm.ci.code.Register;
  63 import jdk.vm.ci.code.RegisterAttributes;
  64 import jdk.vm.ci.code.RegisterConfig;
  65 import jdk.vm.ci.code.StackSlot;
  66 import jdk.vm.ci.code.TargetDescription;

  67 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  68 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  69 import jdk.vm.ci.meta.AllocatableValue;
  70 import jdk.vm.ci.meta.JavaKind;
  71 import jdk.vm.ci.meta.JavaType;
  72 import jdk.vm.ci.meta.LIRKind;
  73 import jdk.vm.ci.meta.PlatformKind;
  74 import jdk.vm.ci.meta.Value;
  75 
  76 public class AArch64HotSpotRegisterConfig implements RegisterConfig {
  77 
  78     private final Architecture architecture;
  79 
  80     private final Register[] allocatable;
  81 
  82     private final int maxFrameSize;
  83 
  84     /**
  85      * The caller saved registers always include all parameter registers.
  86      */


 208         // from the caller or callee perspective
 209         return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, target);
 210     }
 211 
 212     @Override
 213     public Register[] getCallingConventionRegisters(Type type, JavaKind kind) {
 214         HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type;
 215         switch (kind) {
 216             case Boolean:
 217             case Byte:
 218             case Short:
 219             case Char:
 220             case Int:
 221             case Long:
 222             case Object:
 223                 return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters;
 224             case Float:
 225             case Double:
 226                 return simdParameterRegisters;
 227             default:
 228                 throw new InternalError("should not reach here");
 229         }
 230     }
 231 
 232     private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, TargetDescription target) {
 233         AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
 234 
 235         int currentGeneral = 0;
 236         int currentSIMD = 0;
 237         int currentStackOffset = 0;
 238 
 239         for (int i = 0; i < parameterTypes.length; i++) {
 240             final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind();
 241 
 242             switch (kind) {
 243                 case Byte:
 244                 case Boolean:
 245                 case Short:
 246                 case Char:
 247                 case Int:
 248                 case Long:
 249                 case Object:
 250                     if (currentGeneral < generalParameterRegisters.length) {
 251                         Register register = generalParameterRegisters[currentGeneral++];
 252                         locations[i] = register.asValue(target.getLIRKind(kind));
 253                     }
 254                     break;
 255                 case Float:
 256                 case Double:
 257                     if (currentSIMD < simdParameterRegisters.length) {
 258                         Register register = simdParameterRegisters[currentSIMD++];
 259                         locations[i] = register.asValue(target.getLIRKind(kind));
 260                     }
 261                     break;
 262                 default:
 263                     throw new InternalError("should not reach here");
 264             }
 265 
 266             if (locations[i] == null) {
 267                 LIRKind lirKind = target.getLIRKind(kind);
 268                 locations[i] = StackSlot.get(lirKind, currentStackOffset, !type.out);
 269                 currentStackOffset += Math.max(lirKind.getPlatformKind().getSizeInBytes(), target.wordSize);
 270             }
 271         }
 272 
 273         JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind();
 274         AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind.getStackKind()));
 275         return new CallingConvention(currentStackOffset, returnLocation, locations);
 276     }
 277 
 278     @Override
 279     public Register getReturnRegister(JavaKind kind) {
 280         switch (kind) {
 281             case Boolean:
 282             case Byte:
 283             case Char:


< prev index next >