Skip to content

Instantly share code, notes, and snippets.

================================================================================
memref explained through C
================================================================================
Docs: https://mlir.llvm.org/docs/Dialects/MemRef/
SUMMARY
-------
memref = fat pointer (data pointer + shape + strides)
memref.cast = erase/assert static size. Same pointer, same data.
# /// script
# dependencies = ["exo-lang", "numpy"]
# ///
from __future__ import annotations
import ctypes
import subprocess
import tempfile
from pathlib import Path
# /// script
# dependencies = ["exo-lang"]
# ///
from __future__ import annotations
import ctypes
import subprocess
import tempfile
from pathlib import Path
@sueszli
sueszli / hello-docker.asm
Last active February 21, 2026 23:47
x86 backend for xdsl
; $ docker run --rm --platform linux/amd64 -v "$PWD":/app -w /app alpine sh -c "apk add nasm binutils && nasm -f elf64 hello-docker.asm -o hello.o && ld hello.o -o hello && ./hello"
global _start
section .text
_start:
mov rax, 1 ; write(
mov rdi, 1 ; STDOUT_FILENO,
mov rsi, msg ; "Hello, world!\n",
@sueszli
sueszli / run.py
Last active February 17, 2026 13:24
waymark quickstart
# /// script
# requires-python = "==3.12"
# dependencies = ["waymark"]
#
# [tool.uv.sources]
# waymark = { path = "python", editable = true }
# ///
import asyncio
import os
@sueszli
sueszli / demo.py
Last active February 16, 2026 16:43
# /// script
# dependencies = [
# "pytest",
# "pytest-asyncio",
# "waymark",
# ]
# ///
import asyncio
import os
# /// script
# dependencies = [
# "pytest",
# "pytest-asyncio",
# "waymark",
# ]
# ///
import asyncio
import sys
#!/bin/bash
set -euox pipefail
CONTAINER=pg
docker rm -f $CONTAINER 2>/dev/null || true
docker run -d --name $CONTAINER --rm -e POSTGRES_PASSWORD=pass postgres:17-alpine >/dev/null
until docker exec $CONTAINER pg_isready >/dev/null 2>&1; do :; done; sleep 1
# run stuff
docker exec $CONTAINER psql -U postgres -c "CREATE TABLE fruits (fruit TEXT);"
import csv
from xdsl.dialects import llvm
def get_overflow_flags():
# nsw, nuw
flags = [f.value for f in llvm.OverflowFlag]
# "none", individual flags, and "nsw, nuw" just to show combination works basically
return ["none"] + flags + ["nsw, nuw"]
@sueszli
sueszli / experiment.py
Last active February 9, 2026 16:20
visibility of `unnamed_addr` and `visibility_` when using `mlir-opt`.
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "polars",
# ]
# ///
import itertools
import re
import subprocess