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 static jdk.vm.ci.meta.MetaUtil.*; 26 27 import jdk.vm.ci.meta.*; 28 29 /** 30 * Represents the target machine for a compiler, including the CPU architecture, the size of 31 * pointers and references, alignment of stacks, caches, etc. 32 */ 33 public class TargetDescription { 34 35 public final Architecture arch; 36 37 /** 38 * Specifies if this is a multi-processor system. 39 */ 40 public final boolean isMP; 41 42 /** 43 * Specifies if this target supports encoding objects inline in the machine code. 44 */ 45 public final boolean inlineObjects; 46 47 /** 48 * The machine word size on this target. 49 */ 50 public final int wordSize; 51 52 /** 53 * The kind to be used for representing raw pointers and CPU registers. 54 */ 55 public final JavaKind wordKind; 56 57 /** 58 * The stack alignment requirement of the platform. For example, from Appendix D of <a 59 * href="http://www.intel.com/Assets/PDF/manual/248966.pdf">Intel 64 and IA-32 Architectures 60 * Optimization Reference Manual</a>: 61 * 62 * <pre> 63 * "It is important to ensure that the stack frame is aligned to a 64 * 16-byte boundary upon function entry to keep local __m128 data, 65 * parameters, and XMM register spill locations aligned throughout 66 * a function invocation." 67 * </pre> 68 */ 69 public final int stackAlignment; 70 71 /** 72 * Maximum constant displacement at which a memory access can no longer be an implicit null 73 * check. 74 */ 75 public final int implicitNullCheckLimit; 76 77 public TargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects) { 78 this.arch = arch; 79 this.isMP = isMP; 80 this.wordSize = arch.getWordSize(); 81 this.wordKind = JavaKind.fromWordSize(wordSize); 82 this.stackAlignment = stackAlignment; 83 this.implicitNullCheckLimit = implicitNullCheckLimit; 84 this.inlineObjects = inlineObjects; 85 } 86 87 @Override 88 public final int hashCode() { 89 throw new UnsupportedOperationException(); 90 } 91 92 @Override 93 public final boolean equals(Object obj) { 94 if (this == obj) { 95 return true; 96 } 97 if (obj instanceof TargetDescription) { 98 TargetDescription that = (TargetDescription) obj; 99 // @formatter:off 100 if (this.implicitNullCheckLimit == that.implicitNullCheckLimit && 101 this.inlineObjects == that.inlineObjects && 102 this.isMP == that.isMP && 103 this.stackAlignment == that.stackAlignment && 104 this.wordKind.equals(that.wordKind) && 105 this.wordSize == that.wordSize && 106 this.arch.equals(that.arch)) { 107 return true; 108 } 109 // @formatter:on 110 } 111 return false; 112 } 113 114 @Override 115 public String toString() { 116 return identityHashCodeString(this); 117 } 118 119 public int getSizeInBytes(PlatformKind kind) { 120 return kind.getSizeInBytes(); 121 } 122 123 public LIRKind getLIRKind(JavaKind javaKind) { 124 PlatformKind platformKind = arch.getPlatformKind(javaKind); 125 if (javaKind.isObject()) { 126 return LIRKind.reference(platformKind); 127 } else { 128 return LIRKind.value(platformKind); 129 } 130 } 131 } | 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 static jdk.vm.ci.meta.MetaUtil.identityHashCodeString; 26 import jdk.vm.ci.meta.JavaKind; 27 import jdk.vm.ci.meta.LIRKind; 28 import jdk.vm.ci.meta.PlatformKind; 29 30 /** 31 * Represents the target machine for a compiler, including the CPU architecture, the size of 32 * pointers and references, alignment of stacks, caches, etc. 33 */ 34 public class TargetDescription { 35 36 public final Architecture arch; 37 38 /** 39 * Specifies if this is a multi-processor system. 40 */ 41 public final boolean isMP; 42 43 /** 44 * Specifies if this target supports encoding objects inline in the machine code. 45 */ 46 public final boolean inlineObjects; 47 48 /** 49 * The machine word size on this target. 50 */ 51 public final int wordSize; 52 53 /** 54 * The {@link JavaKind} to be used for representing raw pointers and CPU registers in Java code. 55 */ 56 public final JavaKind wordJavaKind; 57 58 /** 59 * The stack alignment requirement of the platform. For example, from Appendix D of <a 60 * href="http://www.intel.com/Assets/PDF/manual/248966.pdf">Intel 64 and IA-32 Architectures 61 * Optimization Reference Manual</a>: 62 * 63 * <pre> 64 * "It is important to ensure that the stack frame is aligned to a 65 * 16-byte boundary upon function entry to keep local __m128 data, 66 * parameters, and XMM register spill locations aligned throughout 67 * a function invocation." 68 * </pre> 69 */ 70 public final int stackAlignment; 71 72 /** 73 * Maximum constant displacement at which a memory access can no longer be an implicit null 74 * check. 75 */ 76 public final int implicitNullCheckLimit; 77 78 public TargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects) { 79 this.arch = arch; 80 this.isMP = isMP; 81 this.wordSize = arch.getWordSize(); 82 this.wordJavaKind = JavaKind.fromWordSize(wordSize); 83 this.stackAlignment = stackAlignment; 84 this.implicitNullCheckLimit = implicitNullCheckLimit; 85 this.inlineObjects = inlineObjects; 86 87 assert arch.getPlatformKind(wordJavaKind).equals(arch.getWordKind()); 88 } 89 90 @Override 91 public final int hashCode() { 92 throw new UnsupportedOperationException(); 93 } 94 95 @Override 96 public final boolean equals(Object obj) { 97 if (this == obj) { 98 return true; 99 } 100 if (obj instanceof TargetDescription) { 101 TargetDescription that = (TargetDescription) obj; 102 // @formatter:off 103 if (this.implicitNullCheckLimit == that.implicitNullCheckLimit && 104 this.inlineObjects == that.inlineObjects && 105 this.isMP == that.isMP && 106 this.stackAlignment == that.stackAlignment && 107 this.wordJavaKind.equals(that.wordJavaKind) && 108 this.wordSize == that.wordSize && 109 this.arch.equals(that.arch)) { 110 return true; 111 } 112 // @formatter:on 113 } 114 return false; 115 } 116 117 @Override 118 public String toString() { 119 return identityHashCodeString(this); 120 } 121 122 public LIRKind getLIRKind(JavaKind javaKind) { 123 PlatformKind platformKind = arch.getPlatformKind(javaKind); 124 if (javaKind.isObject()) { 125 return LIRKind.reference(platformKind); 126 } else { 127 return LIRKind.value(platformKind); 128 } 129 } 130 } |