1 /* 2 * Copyright (c) 2024 Intel Corporation. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package intel.code.spirv; 27 28 import java.util.List; 29 import java.util.Objects; 30 31 public sealed abstract class StorageType extends SpirvType 32 permits StorageType.Input, StorageType.Workgroup, StorageType.CrossWorkgroup, StorageType.Private, StorageType.Function { 33 34 public static final Input INPUT = new Input(); 35 public static final Workgroup WORKGROUP = new Workgroup(); 36 public static final CrossWorkgroup CROSSWORKGROUP= new CrossWorkgroup(); 37 public static final Private PRIVATE = new Private(); 38 public static final Function FUNCTION = new Function(); 39 40 protected final String NAME; 41 42 protected StorageType(String name) { 43 this.NAME = name; 44 } 45 46 static final class Input extends StorageType { 47 protected Input(){ 48 super("Input"); 49 } 50 } 51 52 static final class Workgroup extends StorageType { 53 protected Workgroup() { 54 super("Workgroup"); 55 } 56 } 57 58 static final class CrossWorkgroup extends StorageType 59 { 60 protected CrossWorkgroup() { 61 super("CrossWorkgroup"); 62 } 63 } 64 65 static final class Private extends StorageType 66 { 67 protected Private() { 68 super("Private"); 69 } 70 } 71 72 static final class Function extends StorageType 73 { 74 protected Function() { 75 super("Function"); 76 } 77 } 78 79 @Override 80 public boolean equals(Object obj) { 81 return obj != null && obj.getClass() != this.getClass(); 82 } 83 84 @Override 85 public int hashCode() { 86 return Objects.hash(NAME); 87 } 88 89 @Override 90 public ExternalizedTypeElement externalize() { 91 return new ExternalizedTypeElement(NAME, List.of()); 92 } 93 94 @Override 95 public String toString() { 96 return externalize().toString(); 97 } 98 }