Skip to content

LLVM Stage 1#60

Merged
zimri-leisher merged 32 commits into
develfrom
56-llvm-stage-1
Jun 30, 2026
Merged

LLVM Stage 1#60
zimri-leisher merged 32 commits into
develfrom
56-llvm-stage-1

Conversation

@zimri-leisher

@zimri-leisher zimri-leisher commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator
Related Issue(s) #56
Has Unit Tests (y/n)
Documentation Included (y/n)

Change Description

  • Add new LLVM codegen covering arithmetic, if statements, assertions and exits
  • Add --emit option for switching between fpybin, fpyasm, wasm, wat and llvm-ir
  • Pull in spacewasm submodule, make a spacewasm_runner crate which is a thin wrapper around SpaceWASM that lets us run sequences on it
  • Add --wasm flag to switch between running on Python model backend and WASM backend for tests
  • All tests in test_arithmetic pass with --wasm
  • Some arithmetic semantics have been changed to match WASM or be more consistent internally
  • abs behavior changed to match LLVM
    • This uses a new FABS and IABS op
  • Modulo is now internally consistent with floor div
    • This requires a new FFLOOR op
  • exit builtin takes an I32, all error codes are in I32 now
  • Use exception raising instead of returning for compile errors in some places
  • Move dictionary initialization out of compiler.py into state.py
  • Refactor compiler.py functions to be more modular
  • Move all symbol related classes into new symbols.py
  • Programmatically raised errors are now differentiated from errors of the backend (overflows, etc)

Misc changes

  • Add error msgs to time funcs if they fail
  • Directive id 78 reserved for POP_SERIALIZABLE
  • Fix a bug in elision of certain expressions with side effects

@zimri-leisher zimri-leisher changed the base branch from main to devel June 14, 2026 16:29
Comment thread src/fpy/codegen_llvm.py
if not _llvm_targets_initialized:
llvm.initialize_all_targets()
llvm.initialize_all_asmprinters()
_llvm_targets_initialized = True
Comment thread src/fpy/macros.py
Comment on lines +19 to +33
from fpy.types import (
INTERNAL_STRING,
LOG_SEVERITY,
NOTHING,
TIME,
TIME_BASE,
BOOL,
U8,
U16,
U32,
I64,
F64,
FpyValue,
FpyType,
)
from fpy.types import U32

from fpy.model import DirectiveErrorCode
import fpy.test_helpers as test_helpers
Comment thread src/fpy/macros.py Fixed
@zimri-leisher zimri-leisher changed the title 56 llvm stage 1 LLVM Stage 1 Jun 30, 2026
@zimri-leisher zimri-leisher marked this pull request as ready for review June 30, 2026 18:00
Comment thread src/fpy/main.py
exit(1)
if error_code != 0:
print("Sequence exited with error code " + str(error_code))
exit(error_code)
Comment thread test/fpy/test_wasm.py
assert run_seq_wasm(f"assert 1 == 2{suffix}\n") == expected


class TestWasmExit:
Comment thread src/fpy/codegen_llvm.py

from fpy.error import BackendError
from fpy.model import DirectiveErrorCode
from fpy.state import CompileState
Comment thread src/fpy/codegen_llvm.py
)
from fpy.bytecode.directives import ErrorCodeType
from fpy.types import FpyValue, is_instance_compat
from fpy.visitors import STOP_DESCENT, Emitter, TopDownVisitor
Comment thread src/fpy/macros.py
ends the whole sequence from any call depth (code 0 is a normal exit,
nonzero a fault).
"""
from fpy.codegen_llvm import emit_host_exit
Comment thread src/fpy/state.py
from fpy.dictionary import json_default_to_fpy_value, load_dictionary
from fpy.error import CompileError, DictionaryError
from fpy.ir import Ir, IrLabel
from fpy.macros import MACROS
@zimri-leisher zimri-leisher merged commit fc61b79 into devel Jun 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants