Skip to content

Commit

Permalink
pythonGH-118487: Add Black to .pre-commit-config.yaml for JIT files (
Browse files Browse the repository at this point in the history
  • Loading branch information
savannahostrowski authored May 3, 2024
1 parent dd8f05f commit cb57a52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ repos:
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
files: ^Tools/clinic/|Lib/test/test_clinic.py

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
name: Run Black on Tools/jit/
files: ^Tools/jit/
language_version: python3.12

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand Down
11 changes: 9 additions & 2 deletions Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,20 @@ async def _compile(
args_ll = args + [
# -fomit-frame-pointer is necessary because the GHC calling
# convention uses RBP to pass arguments:
"-S", "-emit-llvm", "-fomit-frame-pointer", "-o", f"{ll}", f"{c}"
"-S",
"-emit-llvm",
"-fomit-frame-pointer",
"-o",
f"{ll}",
f"{c}",
]
await _llvm.run("clang", args_ll, echo=self.verbose)
ir = ll.read_text()
# This handles declarations, definitions, and calls to named symbols
# starting with "_JIT_":
ir = re.sub(r"(((noalias|nonnull|noundef) )*ptr @_JIT_\w+\()", r"ghccc \1", ir)
ir = re.sub(
r"(((noalias|nonnull|noundef) )*ptr @_JIT_\w+\()", r"ghccc \1", ir
)
# This handles calls to anonymous callees, since anything with
# "musttail" needs to use the same calling convention:
ir = ir.replace("musttail call", "musttail call ghccc")
Expand Down

0 comments on commit cb57a52

Please sign in to comment.