1 /* 2 * Copyright (c) 2009, 2016, 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.Type; 26 import jdk.vm.ci.meta.JavaKind; 27 import jdk.vm.ci.meta.JavaType; 28 import jdk.vm.ci.meta.PlatformKind; 29 import jdk.vm.ci.meta.ValueKind; 30 31 /** 32 * A register configuration binds roles and {@linkplain RegisterAttributes attributes} to physical 33 * registers. 34 */ 35 public interface RegisterConfig { 36 37 /** 38 * Gets the register to be used for returning a value of a given kind. 39 */ getReturnRegister(JavaKind kind)40 Register getReturnRegister(JavaKind kind); 41 42 /** 43 * Gets the maximum allowed size of the frame. 44 */ getMaximumFrameSize()45 default int getMaximumFrameSize() { 46 return Integer.MAX_VALUE; 47 } 48 49 /** 50 * Gets the register used as the frame pointer. Spill slots and outgoing stack-based arguments 51 * are addressed relative to this register. 52 */ getFrameRegister()53 Register getFrameRegister(); 54 55 /** 56 * Gets the calling convention describing how arguments are passed. 57 * 58 * @param type the type of calling convention being requested 59 * @param returnType the return type (can be null for methods returning {@code void}) 60 * @param parameterTypes the types of the arguments of the call 61 * @param valueKindFactory the factory to create custom {@link ValueKind ValueKinds} 62 */ getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, ValueKindFactory<?> valueKindFactory)63 CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, ValueKindFactory<?> valueKindFactory); 64 65 /** 66 * Gets the ordered set of registers that are can be used to pass parameters according to a 67 * given calling convention. 68 * 69 * @param type the type of calling convention 70 * @param kind specifies what kind of registers is being requested 71 * @return the ordered set of registers that may be used to pass parameters in a call conforming 72 * to {@code type} 73 */ getCallingConventionRegisters(Type type, JavaKind kind)74 RegisterArray getCallingConventionRegisters(Type type, JavaKind kind); 75 76 /** 77 * Gets the set of all registers that might be used by the register allocator. 78 */ getAllocatableRegisters()79 RegisterArray getAllocatableRegisters(); 80 81 /** 82 * Filters a set of registers and returns only those that can be used by the register allocator 83 * for a value of a particular kind. 84 */ filterAllocatableRegisters(PlatformKind kind, RegisterArray registers)85 RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray registers); 86 87 /** 88 * Gets the registers whose values must be preserved by a method across any call it makes. 89 */ getCallerSaveRegisters()90 RegisterArray getCallerSaveRegisters(); 91 92 /** 93 * Gets the registers whose values must be preserved by the callee. 94 */ getCalleeSaveRegisters()95 RegisterArray getCalleeSaveRegisters(); 96 97 /** 98 * Gets a map from register {@linkplain Register#number numbers} to register 99 * {@linkplain RegisterAttributes attributes} for this register configuration. 100 * 101 * @return an array where an element at index i holds the attributes of the register whose 102 * number is i 103 */ getAttributesMap()104 RegisterAttributes[] getAttributesMap(); 105 106 /** 107 * Determines if all {@link #getAllocatableRegisters() allocatable} registers are 108 * {@link #getCallerSaveRegisters() caller saved}. 109 */ areAllAllocatableRegistersCallerSaved()110 boolean areAllAllocatableRegistersCallerSaved(); 111 } 112