brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · eb37cef Raw
54 lines · bash
1#!/bin/bash2# 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-exception5 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 definitions12# spec.13# <baseclass> is required. It will be the direct base class the newly defined14# 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 OpIAdd19# ./define_inst.sh SPIRVLogicalOps.td LogicalOp OpFOrdEqual20set -e21 22file_name=$123baseclass=$224 25case $baseclass in26  Op | ArithmeticBinaryOp | ArithmeticUnaryOp \27     | LogicalBinaryOp | LogicalUnaryOp \28     | CastOp | ControlFlowOp | StructureOp \29     | AtomicUpdateOp | AtomicUpdateWithValueOp \30     | KhrVendorOp | ExtVendorOp | IntelVendorOp | NvVendorOp )31  ;;32  *)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)"37    exit 1;38  ;;39esac40 41shift42shift43 44current_file="$(readlink -f "$0")"45current_dir="$(dirname "$current_file")"46 47python3 ${current_dir}/gen_spirv_dialect.py \48  --op-td-path \49  ${current_dir}/../../include/mlir/Dialect/SPIRV/IR/${file_name} \50  --inst-category $baseclass --new-inst "$@"51 52${current_dir}/define_opcodes.sh "$@"53 54