001/* 002 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.compiler.common.type; 024 025import jdk.internal.jvmci.common.*; 026import jdk.internal.jvmci.meta.*; 027 028import com.oracle.graal.compiler.common.spi.*; 029 030/** 031 * Type describing pointers to raw memory. This stamp is used for example for direct pointers to 032 * fields or array elements. 033 */ 034public class RawPointerStamp extends AbstractPointerStamp { 035 036 protected RawPointerStamp() { 037 super(false, false); 038 } 039 040 @Override 041 public LIRKind getLIRKind(LIRKindTool tool) { 042 return tool.getWordKind(); 043 } 044 045 @Override 046 protected AbstractPointerStamp copyWith(boolean newNonNull, boolean newAlwaysNull) { 047 // RawPointerStamp is a singleton 048 assert newNonNull == nonNull() && newAlwaysNull == alwaysNull(); 049 return this; 050 } 051 052 @Override 053 public Stamp meet(Stamp other) { 054 assert isCompatible(other); 055 return this; 056 } 057 058 @Override 059 public Stamp improveWith(Stamp other) { 060 return this; 061 } 062 063 @Override 064 public Stamp join(Stamp other) { 065 assert isCompatible(other); 066 return this; 067 } 068 069 @Override 070 public Stamp unrestricted() { 071 return this; 072 } 073 074 @Override 075 public Stamp empty() { 076 // there is no empty pointer stamp 077 return this; 078 } 079 080 @Override 081 public boolean hasValues() { 082 return true; 083 } 084 085 @Override 086 public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { 087 throw JVMCIError.shouldNotReachHere("pointer has no Java type"); 088 } 089 090 @Override 091 public Stamp constant(Constant c, MetaAccessProvider meta) { 092 return this; 093 } 094 095 @Override 096 public boolean isCompatible(Stamp other) { 097 return other instanceof RawPointerStamp; 098 } 099 100 @Override 101 public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) { 102 throw JVMCIError.shouldNotReachHere("can't read raw pointer"); 103 } 104 105 @Override 106 public String toString() { 107 return "void*"; 108 } 109}