• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
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
5
6# Script for defining a new op using SPIR-V spec from the Internet.
7#
8# Run as:
9# ./define_inst.sh <filename> <baseclass> (<opname>)*
10
11# <filename> is required, which is the file name of MLIR SPIR-V op definitions
12# spec.
13# <baseclass> is required. It will be the direct base class the newly defined
14# op will drive from.
15# If <opname> is missing, this script updates existing ones in <filename>.
16
17# For example:
18# ./define_inst.sh SPIRVArithmeticOps.td ArithmeticBinaryOp OpIAdd
19# ./define_inst.sh SPIRVLogicalOps.td LogicalOp OpFOrdEqual
20set -e
21
22file_name=$1
23baseclass=$2
24
25case $baseclass in
26  Op | ArithmeticBinaryOp | ArithmeticUnaryOp | LogicalBinaryOp | LogicalUnaryOp | CastOp | ControlFlowOp | StructureOp | AtomicUpdateOp | AtomicUpdateWithValueOp)
27  ;;
28  *)
29    echo "Usage : " $0 "<filename> <baseclass> (<opname>)*"
30    echo "<filename> is the file name of MLIR SPIR-V op definitions spec"
31    echo "<baseclass> must be one of " \
32      "(Op|ArithmeticBinaryOp|ArithmeticUnaryOp|LogicalBinaryOp|LogicalUnaryOp|CastOp|ControlFlowOp|StructureOp|AtomicUpdateOp)"
33    exit 1;
34  ;;
35esac
36
37shift
38shift
39
40current_file="$(readlink -f "$0")"
41current_dir="$(dirname "$current_file")"
42
43python3 ${current_dir}/gen_spirv_dialect.py \
44  --op-td-path \
45  ${current_dir}/../../include/mlir/Dialect/SPIRV/${file_name} \
46  --inst-category $baseclass --new-inst "$@"
47
48${current_dir}/define_opcodes.sh "$@"
49
50