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.23.1.tar.gz (68.4 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.23.1-py3-none-any.whl (80.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: arxlang-1.23.1.tar.gz
  • Upload date:
  • Size: 68.4 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.23.1.tar.gz
Algorithm Hash digest
SHA256 c1422879e649b4775ccdae64e5f6ffbbaaea580213b67ad7f20c929579d62ed9
MD5 fbe8a5e059a7317141680e1dadb9e938
BLAKE2b-256 cad3c65c0c0302a74b00bfe64b9442547c46bb810c65d67001c84f8f53ff6835

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arxlang-1.23.1-py3-none-any.whl
  • Upload date:
  • Size: 80.5 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.23.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05ddad44abb121582747db40fd213655a81bcf82880f0fe895236ad64dfbb34f
MD5 576cbcd7cc4fa4b1e3c7c5114057b611
BLAKE2b-256 263b4f04c65bac310e0598fe85558e540b83eed5c118c70c38ceaf679954a947

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