2 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 # See https://llvm.org/LICENSE.txt for license information.
4 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 # Script for defining a new op using SPIR-V spec from the Internet.
9 # ./define_inst.sh <filename> <baseclass> (<opname>)*
11 # <filename> is required, which is the file name of MLIR SPIR-V op definitions
13 # <baseclass> is required. It will be the direct base class the newly defined
15 # If <opname> is missing, this script updates existing ones in <filename>.
18 # ./define_inst.sh SPIRVArithmeticOps.td ArithmeticBinaryOp OpIAdd
19 # ./define_inst.sh SPIRVLogicalOps.td LogicalOp OpFOrdEqual
26 Op | ArithmeticBinaryOp | ArithmeticUnaryOp \
27 | LogicalBinaryOp | LogicalUnaryOp \
28 | CastOp | ControlFlowOp | StructureOp \
29 | AtomicUpdateOp | AtomicUpdateWithValueOp \
30 | KhrVendorOp | ExtVendorOp | IntelVendorOp | NvVendorOp
)
33 echo "Usage : " $0 "<filename> <baseclass> (<opname>)*"
34 echo "<filename> is the file name of MLIR SPIR-V op definitions spec"
35 echo "<baseclass> must be one of " \
36 "(Op|ArithmeticBinaryOp|ArithmeticUnaryOp|LogicalBinaryOp|LogicalUnaryOp|CastOp|ControlFlowOp|StructureOp|AtomicUpdateOp|KhrVendorOp|ExtVendorOp|IntelVendorOp|NvVendorOp)"
44 current_file
="$(readlink -f "$0")"
45 current_dir
="$(dirname "$current_file")"
47 python3
${current_dir}/gen_spirv_dialect.py \
49 ${current_dir}/..
/..
/include
/mlir
/Dialect
/SPIRV
/IR
/${file_name} \
50 --inst-category $baseclass --new-inst "$@"
52 ${current_dir}/define_opcodes.sh
"$@"