1 /* 2 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 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 package jdk.vm.ci.code; 24 25 import jdk.vm.ci.code.CallingConvention.*; 26 import jdk.vm.ci.meta.*; 27 28 /** 29 * A register configuration binds roles and {@linkplain RegisterAttributes attributes} to physical 30 * registers. 31 */ 32 public interface RegisterConfig { 33 34 /** 35 * Gets the register to be used for returning a value of a given kind. 36 */ 37 Register getReturnRegister(JavaKind kind); 38 39 /** 40 * Gets the maximum allowed size of the frame. 41 */ 42 default int getMaximumFrameSize() { 43 return Integer.MAX_VALUE; 44 } 45 46 /** 47 * Gets the register to which {@link Register#Frame} and {@link Register#CallerFrame} are bound. 48 */ 49 Register getFrameRegister(); 50 51 /** 52 * Gets the calling convention describing how arguments are passed. 53 * 54 * @param type the type of calling convention being requested 55 * @param returnType the return type (can be null for methods returning {@code void}) 56 * @param parameterTypes the types of the arguments of the call 57 * @param target the target platform 58 * @param stackOnly ignore registers 59 */ 60 CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly); 61 62 /** 63 * Gets the ordered set of registers that are can be used to pass parameters according to a 64 * given calling convention. 65 * 66 * @param type the type of calling convention 67 * @param kind specifies what kind of registers is being requested 68 * @return the ordered set of registers that may be used to pass parameters in a call conforming 69 * to {@code type} 70 */ 71 Register[] getCallingConventionRegisters(Type type, JavaKind kind); 72 73 /** 74 * Gets the set of all registers that might be used by the register allocator. 75 * 76 * To get the set of registers the register allocator is allowed to use see 77 * {@link RegisterAllocationConfig#getAllocatableRegisters()} 78 */ 79 @SuppressWarnings("javadoc") 80 Register[] getAllocatableRegisters(); 81 82 /** 83 * Filters a set of registers and returns only those that can be used by the register allocator 84 * for a value of a particular kind. 85 */ 86 Register[] filterAllocatableRegisters(PlatformKind kind, Register[] registers); 87 88 /** 89 * Gets the registers whose values must be preserved by a method across any call it makes. 90 */ 91 Register[] getCallerSaveRegisters(); 92 93 /** 94 * Gets the registers whose values must be preserved by the callee. 95 */ 96 Register[] getCalleeSaveRegisters(); 97 98 /** 99 * Gets a map from register {@linkplain Register#number numbers} to register 100 * {@linkplain RegisterAttributes attributes} for this register configuration. 101 * 102 * @return an array where an element at index i holds the attributes of the register whose 103 * number is i 104 */ 105 RegisterAttributes[] getAttributesMap(); 106 107 /** 108 * Gets the register corresponding to a runtime-defined role. 109 * 110 * @param id the identifier of a runtime-defined register role 111 * @return the register playing the role specified by {@code id} 112 */ 113 Register getRegisterForRole(int id); 114 115 /** 116 * Determines if all {@link #getAllocatableRegisters() allocatable} registers are 117 * {@link #getCallerSaveRegisters() caller saved}. 118 */ 119 boolean areAllAllocatableRegistersCallerSaved(); 120 }