001/*
002 * Copyright (c) 2012, 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 * This stamp represents the type of the {@link Kind#Illegal} value in the second slot of
032 * {@link Kind#Long} and {@link Kind#Double} values. It can only appear in framestates or virtual
033 * objects.
034 */
035public final class IllegalStamp extends Stamp {
036
037    private IllegalStamp() {
038    }
039
040    @Override
041    public Kind getStackKind() {
042        return Kind.Illegal;
043    }
044
045    @Override
046    public LIRKind getLIRKind(LIRKindTool tool) {
047        throw JVMCIError.shouldNotReachHere("illegal stamp should not reach backend");
048    }
049
050    @Override
051    public Stamp unrestricted() {
052        return this;
053    }
054
055    @Override
056    public Stamp empty() {
057        return this;
058    }
059
060    @Override
061    public Stamp constant(Constant c, MetaAccessProvider meta) {
062        assert ((PrimitiveConstant) c).getKind() == Kind.Illegal;
063        return this;
064    }
065
066    @Override
067    public ResolvedJavaType javaType(MetaAccessProvider metaAccess) {
068        throw JVMCIError.shouldNotReachHere("illegal stamp has no Java type");
069    }
070
071    @Override
072    public Stamp meet(Stamp other) {
073        assert other instanceof IllegalStamp;
074        return this;
075    }
076
077    @Override
078    public Stamp join(Stamp other) {
079        assert other instanceof IllegalStamp;
080        return this;
081    }
082
083    @Override
084    public boolean isCompatible(Stamp stamp) {
085        return stamp instanceof IllegalStamp;
086    }
087
088    @Override
089    public String toString() {
090        return "ILLEGAL";
091    }
092
093    @Override
094    public boolean hasValues() {
095        return true;
096    }
097
098    @Override
099    public Stamp improveWith(Stamp other) {
100        assert other instanceof IllegalStamp;
101        return this;
102    }
103
104    @Override
105    public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
106        throw JVMCIError.shouldNotReachHere("can't read values of illegal stamp");
107    }
108
109    private static final IllegalStamp instance = new IllegalStamp();
110
111    static IllegalStamp getInstance() {
112        return instance;
113    }
114}