TargetDescription.java revision 12657:6ef01bd40ce2
1251886Speter/* 2251886Speter * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. 3251886Speter * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4251886Speter * 5251886Speter * This code is free software; you can redistribute it and/or modify it 6251886Speter * under the terms of the GNU General Public License version 2 only, as 7251886Speter * published by the Free Software Foundation. 8251886Speter * 9251886Speter * This code is distributed in the hope that it will be useful, but WITHOUT 10251886Speter * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11251886Speter * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12251886Speter * version 2 for more details (a copy is included in the LICENSE file that 13251886Speter * accompanied this code). 14362181Sdim * 15362181Sdim * You should have received a copy of the GNU General Public License version 16362181Sdim * 2 along with this work; if not, write to the Free Software Foundation, 17251886Speter * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18251886Speter * 19251886Speter * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20251886Speter * or visit www.oracle.com if you need additional information or have any 21251886Speter * questions. 22251886Speter */ 23251886Speterpackage jdk.vm.ci.code; 24251886Speter 25251886Speterimport static jdk.vm.ci.meta.MetaUtil.identityHashCodeString; 26251886Speter 27362181Sdimimport jdk.vm.ci.meta.JavaKind; 28362181Sdim 29362181Sdim/** 30251886Speter * Represents the target machine for a compiler, including the CPU architecture, the size of 31251886Speter * pointers and references, alignment of stacks, caches, etc. 32251886Speter */ 33251886Speterpublic class TargetDescription { 34251886Speter 35251886Speter public final Architecture arch; 36251886Speter 37251886Speter /** 38251886Speter * Specifies if this is a multi-processor system. 39362181Sdim */ 40251886Speter public final boolean isMP; 41251886Speter 42251886Speter /** 43251886Speter * Specifies if this target supports encoding objects inline in the machine code. 44251886Speter */ 45251886Speter public final boolean inlineObjects; 46251886Speter 47251886Speter /** 48362181Sdim * The machine word size on this target. 49251886Speter */ 50251886Speter public final int wordSize; 51251886Speter 52251886Speter /** 53251886Speter * The {@link JavaKind} to be used for representing raw pointers and CPU registers in Java code. 54251886Speter */ 55251886Speter public final JavaKind wordJavaKind; 56251886Speter 57251886Speter /** 58251886Speter * The stack alignment requirement of the platform. For example, from Appendix D of 59251886Speter * <a href="http://www.intel.com/Assets/PDF/manual/248966.pdf">Intel 64 and IA-32 Architectures 60251886Speter * Optimization Reference Manual</a>: 61251886Speter * 62251886Speter * <pre> 63251886Speter * "It is important to ensure that the stack frame is aligned to a 64251886Speter * 16-byte boundary upon function entry to keep local __m128 data, 65251886Speter * parameters, and XMM register spill locations aligned throughout 66251886Speter * a function invocation." 67251886Speter * </pre> 68251886Speter */ 69251886Speter public final int stackAlignment; 70251886Speter 71251886Speter /** 72251886Speter * Maximum constant displacement at which a memory access can no longer be an implicit null 73251886Speter * check. 74251886Speter */ 75251886Speter public final int implicitNullCheckLimit; 76251886Speter 77251886Speter public TargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects) { 78251886Speter this.arch = arch; 79251886Speter this.isMP = isMP; 80251886Speter this.wordSize = arch.getWordSize(); 81251886Speter this.wordJavaKind = JavaKind.fromWordSize(wordSize); 82251886Speter this.stackAlignment = stackAlignment; 83251886Speter this.implicitNullCheckLimit = implicitNullCheckLimit; 84251886Speter this.inlineObjects = inlineObjects; 85251886Speter 86251886Speter assert arch.getPlatformKind(wordJavaKind).equals(arch.getWordKind()); 87251886Speter } 88251886Speter 89251886Speter @Override 90251886Speter public final int hashCode() { 91251886Speter throw new UnsupportedOperationException(); 92251886Speter } 93251886Speter 94251886Speter @Override 95362181Sdim public final boolean equals(Object obj) { 96362181Sdim if (this == obj) { 97362181Sdim return true; 98362181Sdim } 99362181Sdim if (obj instanceof TargetDescription) { 100362181Sdim TargetDescription that = (TargetDescription) obj; 101266736Speter // @formatter:off 102266736Speter if (this.implicitNullCheckLimit == that.implicitNullCheckLimit && 103266736Speter this.inlineObjects == that.inlineObjects && 104251886Speter this.isMP == that.isMP && 105251886Speter this.stackAlignment == that.stackAlignment && 106251886Speter this.wordJavaKind.equals(that.wordJavaKind) && 107251886Speter this.wordSize == that.wordSize && 108251886Speter this.arch.equals(that.arch)) { 109251886Speter return true; 110251886Speter } 111362181Sdim // @formatter:on 112362181Sdim } 113362181Sdim return false; 114251886Speter } 115251886Speter 116251886Speter @Override 117251886Speter public String toString() { 118256055Snwhitehorn return identityHashCodeString(this); 119251886Speter } 120256055Snwhitehorn} 121251886Speter