xref: /llvm-project/mlir/utils/spirv/define_opcodes.sh (revision 4234292ecf4902ad53286652acc3969c6758fed0)
1#!/bin/bash
2
3# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4# See https://llvm.org/LICENSE.txt for license information.
5# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7# Script for defining map for opname to opcode using SPIR-V spec from the
8# Internet
9#
10# Run as:
11# ./define_opcode.sh (<op-name>)*
12#
13# For example:
14# ./define_opcode.sh OpTypeVoid OpTypeFunction
15#
16# If no op-name is specified, the existing opcodes are updated
17#
18# The 'instructions' list of spirv.core.grammar.json contains all instructions
19# in SPIR-V
20
21set -e
22
23current_file="$(readlink -f "$0")"
24current_dir="$(dirname "$current_file")"
25
26python3 ${current_dir}/gen_spirv_dialect.py \
27  --base-td-path ${current_dir}/../../include/mlir/Dialect/SPIRV/IR/SPIRVBase.td \
28  --new-opcode $@
29