2019-07-13 01:00:13 +08:00
|
|
|
#!/bin/bash
|
2019-12-24 01:35:36 +08:00
|
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2019-07-13 01:00:13 +08:00
|
|
|
|
|
|
|
# Script for defining a new op using SPIR-V spec from the Internet.
|
|
|
|
#
|
|
|
|
# Run as:
|
2019-12-24 05:04:34 +08:00
|
|
|
# ./define_inst.sh <filename> <baseclass> (<opname>)*
|
2019-07-13 01:00:13 +08:00
|
|
|
|
2019-10-09 20:01:07 +08:00
|
|
|
# <filename> is required, which is the file name of MLIR SPIR-V op definitions
|
|
|
|
# spec.
|
2019-12-24 05:04:34 +08:00
|
|
|
# <baseclass> is required. It will be the direct base class the newly defined
|
|
|
|
# op will drive from.
|
|
|
|
# If <opname> is missing, this script updates existing ones in <filename>.
|
2019-07-13 01:00:13 +08:00
|
|
|
|
2019-09-01 00:52:18 +08:00
|
|
|
# For example:
|
2019-12-24 05:04:34 +08:00
|
|
|
# ./define_inst.sh SPIRVArithmeticOps.td ArithmeticBianryOp OpIAdd
|
2019-10-09 20:01:07 +08:00
|
|
|
# ./define_inst.sh SPIRVLogicalOps.td LogicalOp OpFOrdEqual
|
2019-07-13 01:00:13 +08:00
|
|
|
set -e
|
|
|
|
|
2019-10-01 01:40:07 +08:00
|
|
|
file_name=$1
|
2019-12-24 05:04:34 +08:00
|
|
|
baseclass=$2
|
2019-09-01 00:52:18 +08:00
|
|
|
|
2019-12-24 05:04:34 +08:00
|
|
|
case $baseclass in
|
|
|
|
Op | ArithmeticBinaryOp | ArithmeticUnaryOp | LogicalBinaryOp | LogicalUnaryOp | CastOp | ControlFlowOp | StructureOp | AtomicUpdateOp | AtomicUpdateWithValueOp)
|
2019-09-01 00:52:18 +08:00
|
|
|
;;
|
|
|
|
*)
|
2019-12-24 05:04:34 +08:00
|
|
|
echo "Usage : " $0 "<filename> <baseclass> (<opname>)*"
|
2019-10-09 20:01:07 +08:00
|
|
|
echo "<filename> is the file name of MLIR SPIR-V op definitions spec"
|
2019-12-24 05:04:34 +08:00
|
|
|
echo "<baseclass> must be one of " \
|
|
|
|
"(Op|ArithmeticBinaryOp|ArithmeticUnaryOp|LogicalBinaryOp|LogicalUnaryOp|CastOp|ControlFlowOp|StructureOp|AtomicUpdateOp)"
|
2019-09-01 00:52:18 +08:00
|
|
|
exit 1;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2019-10-01 01:40:07 +08:00
|
|
|
shift
|
2019-09-01 00:52:18 +08:00
|
|
|
shift
|
2019-07-13 01:00:13 +08:00
|
|
|
|
|
|
|
current_file="$(readlink -f "$0")"
|
|
|
|
current_dir="$(dirname "$current_file")"
|
|
|
|
|
|
|
|
python3 ${current_dir}/gen_spirv_dialect.py \
|
2019-09-01 00:52:18 +08:00
|
|
|
--op-td-path \
|
2019-10-01 01:40:07 +08:00
|
|
|
${current_dir}/../../include/mlir/Dialect/SPIRV/${file_name} \
|
2019-12-24 05:04:34 +08:00
|
|
|
--inst-category $baseclass --new-inst "$@"
|
2019-10-01 01:40:07 +08:00
|
|
|
|
|
|
|
${current_dir}/define_opcodes.sh "$@"
|
|
|
|
|