Skip to main content

Arx is a compiler built with llvm

Project description

Arx

Arx is a new programming language that uses the power of LLVM to provide multi-architecture machine target code generation. Arx aims to provide native list and tensor abstractions with a builtin runtime backed internally by IRx.

Arx is a prototype that should replace the current Arx compiler in c++.

If you want more information about ArxLang, please check the original project in c++: https://github.com/arxlang/arx

Link Modes

Arx supports explicit executable link modes:

arx program.x --link-mode auto    # default, use toolchain default
arx program.x --link-mode pie     # force PIE executable
arx program.x --link-mode no-pie  # force non-PIE executable

Troubleshooting (PIE / Colab / Conda)

If you hit an error like:

relocation R_X86_64_32 ... can not be used when making a PIE object

use:

arx program.x --link-mode no-pie

This typically happens on environments where the linker defaults to PIE while objects were not compiled in a PIE-compatible mode.

Testing

Arx now exposes list[...] and tensor[...] as distinct public collection forms:

fn pick(grid: tensor[i32, 2, 2]) -> i32:
  return grid[1, 0]

fn main() -> i32:
  var grid: tensor[i32, 2, 2] = [[1, 2], [3, 4]]
  var ids: list[i32] = [5, 6, 7, 8]
  return pick(grid) + ids[2]

Use:

  • list[T] for generic collection values
  • tensor[T, N] and tensor[T, D1, D2, ...] for fixed-shape tensors

Tensor details stay user-facing in terms of element types, shape, dimensions, and indexing. In this phase, every Arx tensor annotation must declare at least one static shape dimension. IRx owns the Arrow C++ backed Tensor runtime and lowering. Current tensor element types are fixed-width numeric types: i8, i16, i32, i64, f32, and f64.

Arx uses Tensor for homogeneous N-dimensional data and reserves Array for one-dimensional Arrow-style data where the language exposes it. Future heterogeneous dataframe or table support will use a separate surface type.

Arx also ships a bundled pure-Arx standard library under the reserved stdlib namespace:

import math from stdlib

fn main() -> i32:
  return math.square(4)

Compiler-provided builtins stay separate from stdlib. Builtin sources live in src/arx/builtins/*.x, are bundled inside the installed arx package, and are resolved by dedicated compiler logic instead of user-project module lookup. Those bundled builtin modules are internal compiler assets, not a public stdlib-style import namespace. User code does not import builtins; builtin functions such as range(...) are available automatically.

fn main() -> none:
  print(range(0, 4)[2])

The first builtin module is generators. Its current MVP exposes range(start, stop[, step]) -> list[i32], while future overloads and yield-backed generator semantics will grow in the same area. Positive steps count up, negative steps count down, and step == 0 raises an assertion failure. For-in loops can iterate over list-valued expressions such as range(...), list literals, and list variables. Ambient builtin names such as range are injected only when not shadowed, so a local function or import with the same name overrides the builtin in that module.

Arx now supports fatal assertion statements in the language surface:

fn test_add() -> none:
  assert 1 + 1 == 2
  assert 2 + 2 == 4, "2 + 2 should be 4"

You can run compiled tests with the new arx test subcommand:

arx test
arx test tests/arx/test_math.x --list
arx test -k square
arx test -x
arx test --keep-artifacts
arx test --exclude "tests/arx/slow_*.x"

By default the runner searches tests/ for files matching test_*.x, discovers zero-argument test_* functions that return none, and executes each test in its own compiled subprocess. Test identifiers use the cwd-relative path of the source file (without the .x suffix) joined to the function name via ::, for example tests/arx/test_math::test_square, so same-named files in parallel directories stay distinct.

You can override discovery from .arxproject.toml:

[tests]
paths = ["tests", "integration"]
exclude = ["tests/experimental_*.x"]
file_pattern = "test_*.x"
function_pattern = "test_*"

CLI flags always win over [tests] settings. In v1, shared top-level support is intentionally narrow: imports, extern declarations, class declarations, and helper functions are preserved, while module-scope variable declarations and other top-level executable code are not supported yet.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arxlang-1.20.0.tar.gz (63.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arxlang-1.20.0-py3-none-any.whl (74.9 kB view details)

Uploaded Python 3

File details

Details for the file arxlang-1.20.0.tar.gz.

File metadata

  • Download URL: arxlang-1.20.0.tar.gz
  • Upload date:
  • Size: 63.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.10.20 Linux/6.17.0-1010-azure

File hashes

Hashes for arxlang-1.20.0.tar.gz
Algorithm Hash digest
SHA256 293fa682b482e882e7746ec00a97041e07c1bdc91200a2aaa5d054e1dbb3d0bb
MD5 eef848b47dddd1b5b0bf8313b3f5cffa
BLAKE2b-256 e6f7f405237a03183f83b5987385975aa9b1845f4c2277cb11bfc6f5b54de711

See more details on using hashes here.

File details

Details for the file arxlang-1.20.0-py3-none-any.whl.

File metadata

  • Download URL: arxlang-1.20.0-py3-none-any.whl
  • Upload date:
  • Size: 74.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.10.20 Linux/6.17.0-1010-azure

File hashes

Hashes for arxlang-1.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 faab8db665c4a44f341ceff0369042a032dba418379ae1d81e1197b480ac9342
MD5 a29aff32fef00fdb4785f6781463efd9
BLAKE2b-256 c3cc4bbeac0e0f49868a7d7f2fb2dd60fb57c6bf2b2bba444f186336b8262482

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page