From 2381421776858bcc982f9835cdd8b9f53cbc2db4 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 31 Dec 2025 20:34:10 -0800 Subject: [PATCH 01/32] add copyright headers and check script --- .gitignore | 4 +- README.md | 4 ++ parse_powerisa_pdf/parse_powerisa_pdf.py | 2 + parse_powerisa_pdf/quad_tree.py | 2 + parse_powerisa_pdf/set_by_id.py | 2 + pyproject.toml | 2 + scripts/check-copyright.sh | 63 ++++++++++++++++++++++++ 7 files changed, 78 insertions(+), 1 deletion(-) create mode 100755 scripts/check-copyright.sh diff --git a/.gitignore b/.gitignore index 50e4eb1..59baa47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# See Notices.txt for copyright information /.venv /.vscode *.egg-info __pycache__ *.log -/powerisa-instructions.xml \ No newline at end of file +/powerisa-instructions.xml diff --git a/README.md b/README.md index f8fae5d..7fd652f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ + parser for the OPF PowerISA 3.1C pdf to attempt to extract all instructions' pseudo-code including subscripts/superscripts and other formatting Usage: diff --git a/parse_powerisa_pdf/parse_powerisa_pdf.py b/parse_powerisa_pdf/parse_powerisa_pdf.py index c7187d1..a4afd09 100755 --- a/parse_powerisa_pdf/parse_powerisa_pdf.py +++ b/parse_powerisa_pdf/parse_powerisa_pdf.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# See Notices.txt for copyright information from __future__ import annotations from collections import defaultdict from collections.abc import Generator, Iterable, Iterator, Callable diff --git a/parse_powerisa_pdf/quad_tree.py b/parse_powerisa_pdf/quad_tree.py index 34343e8..bee9d76 100644 --- a/parse_powerisa_pdf/quad_tree.py +++ b/parse_powerisa_pdf/quad_tree.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# See Notices.txt for copyright information from __future__ import annotations from typing import Callable, Generic, Iterable, Iterator, TypeVar from math import frexp, isfinite, isnan, ldexp diff --git a/parse_powerisa_pdf/set_by_id.py b/parse_powerisa_pdf/set_by_id.py index 444741b..969f8d7 100644 --- a/parse_powerisa_pdf/set_by_id.py +++ b/parse_powerisa_pdf/set_by_id.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# See Notices.txt for copyright information from collections import abc from typing import Callable, Generic, Iterable, Iterator, Protocol, TypeAlias, TypeVar, overload diff --git a/pyproject.toml b/pyproject.toml index c2ec3e0..68c4029 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# See Notices.txt for copyright information [build-system] requires = ["setuptools >= 61.0"] build-backend = "setuptools.build_meta" diff --git a/scripts/check-copyright.sh b/scripts/check-copyright.sh new file mode 100755 index 0000000..640fb4b --- /dev/null +++ b/scripts/check-copyright.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-3.0-or-later +# See Notices.txt for copyright information +set -e + +function fail() +{ + local error="$1" + echo "error: $error" >&2 + exit 1 +} + +function fail_file() +{ + local file="$1" line="$2" error="$3" + fail "$file:$((line + 1)): $error" +} + +function check_file() +{ + local file="$1" regexes=("${@:2}") + local lines + mapfile -t lines < "$file" + if (("${#lines[@]}" == 0)); then + return # empty file, no copyright needed + fi + local line + for line in "${!regexes[@]}"; do + eval '[[ "${lines[i]}" =~ '"${regexes[i]}"' ]]' || + fail_file "$file" "$line" "doesn't match regex: ${regexes[i]}" + done +} + +POUND_HEADER=('^"# SPDX-License-Identifier: LGPL-3.0-or-later"$' '^"# See Notices.txt for copyright information"$') +MD_HEADER=('^" parser for the OPF PowerISA 3.1C pdf to attempt to extract all instructions' pseudo-code including subscripts/superscripts and other formatting +# Using the new Rust code: + +Usage: +* Download the OPF PowerISA 3.1C pdf (yes you need that exact version) from + +* Install Rust -- you need version 1.89.0 or later. + + Getting it from https://rustup.rs/ is recommended. + +* Compile and run: + + ```bash + cargo run -- path/to/downloaded/OPF_PowerISA_v3.1C.pdf > out.log + ``` + +* This will spit out lots of errors and then successfully create + the output file -- `powerisa-instructions.xml` in the current directory. + +# Using the old Python code: + Usage: * Download the OPF PowerISA 3.1C pdf (yes you need that exact version) from * Obtain CPython 3.11 (the default `python3` in [Debian Bookworm](https://www.debian.org/releases/bookworm/)) From 38a1fb328bd44f26389c28fbf66716154f4113dc Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 6 Jan 2026 16:13:36 -0800 Subject: [PATCH 32/32] add build dependencies to readme --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9fba609..f589559 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,15 @@ Usage: Getting it from https://rustup.rs/ is recommended. +* Install required build dependencies: + + On Debian 12: + + ```bash + sudo apt update + sudo apt install build-essential clang unzip + ``` + * Compile and run: ```bash