Skip to content

Instantly share code, notes, and snippets.

View lenary's full-sized avatar

Sam Elliott lenary

View GitHub Profile
@pizlonator
pizlonator / pizlossafull.md
Last active April 24, 2025 17:05
How I implement SSA form

This document explains how I would implement an SSA-based compiler if I was writing one today.

This document is intentionally opinionated. It just tells you how I would do it. This document is intended for anyone who has read about SSA and understands the concept, but is confused about how exactly to put it into practice. If you're that person, then I'm here to show you a way to do it that works well for me. If you're looking for a review of other ways to do it, I recommend this post.

My approach works well when implementing the compiler in any language that easily permits cyclic mutable data structures. I know from experience that it'll work great in C++, C#, or Java. The memory management of this approach is simple (and I'll explain it), so you won't have to stress about use after frees.

I like my approach because it leads to an ergonomic API by minimizing the amount of special cases you have to worry about. Most of the compiler is analyses and transformations ov

@pizlonator
pizlonator / pizlossa.md
Last active February 27, 2025 05:26
Pizlo SSA Form (short version)

Here's a much more complete description of how I do SSA, beyond just how I do Phis.

This describes how I do SSA form, which avoids the need to have any coupling between CFG data structures and SSA data structures.

Let's first define a syntax for SSA and some terminology. Here's an example SSA node:

A = Add(B, C)

In reality, this will be a single object in your in-memory representation, and the names are really addresses of those objects. So, this node has an "implicit variable" called A; it's the variable that is implicitly assigned to when you execute the node. If you then do:

@timothyham
timothyham / ipv6guide.md
Last active April 24, 2025 05:24
A Short IPv6 Guide for Home IPv4 Admins

A Short IPv6 Guide for Home IPv4 Admins

This guide is for homelab admins who understand IPv4s well but find setting up IPv6 hard or annoying because things work differently. In some ways, managing an IPv6 network can be simpler than IPv4, one just needs to learn some new concepts and discard some old ones.

Let’s begin.

First of all, there are some concepts that one must unlearn from ipv4:

Concept 1

Introduction

This document provides a detailed exploration of how C++ standard library headers are used when building, testing, and using the LLVM libc++ library. It covers the different types of headers involved, the main header layouts used, and the importance of include paths and how they are constructed. It also dives into the specific include paths used in key scenarios on Linux and Apple platforms. The goal is to explain the key concepts and complexities around libc++ headers to support informed decision making about the library's header layout.

The Headers

There are several types of headers involved in the libc++ library:

@matteyeux
matteyeux / f.md
Last active March 22, 2025 18:47
macOS and iOS Security Internals Advent Calendar
@rrika
rrika / unscramble.py
Created September 5, 2023 20:54
ME: please show me the tweets in the order that they were liked COMPUTER: thats too hard. heres some tweets i think are good.
class Node:
capacity = 10
def __init__(self, index, count):
self.index = index
self.count = count
self.children = []
def __iter__(self):
return iter(self.children)
def __len__(self):
return len(self.children)
@Endilll
Endilll / clang+gcc+xcode.txt
Last active July 25, 2023 13:22
C++ compiler version history
Clang GCC Xcode
2023.03.17 16.0.0
2022.09.06 15.0.0
2022.03.25 14.0.0
2021.10.04 13.0.0
2021.06.01 9.4
2021.04.14 12.0.0
2020.10.12 11.0.0
2020.03.24 10.0.0
2020.03.04 8.4
@abey79
abey79 / dpx2x00.toml
Last active November 28, 2021 22:50
Roland DPX-2x00 config for vpype
# Notes from https://webmanual.rolanddg.com/contents/manuals/DPX-3700A+2700A_USE_E_R8.pdf
# * we use the default "DPX" origin system
# * paper_size: set to value from the X/Y columns (p.17)
# * for A3+ (where Xmm is paper long edge in mm and Ymm is paper short edge in mm):
# - x_range = (-Xmm * 20 - 480, Xmm * 20 - 480)
# - y_range = (-Ymm * 20, Ymm * 20
# * for A4:
# - x_range = (-Xmm * 20, Xmm * 20)
# - y_range = (-Ymm * 20 - 480, Ymm * 20 - 480)
# * origin_location: set to (-LLx, URy) from table on p. 17

Monads and delimited control are very closely related, so it isn’t too hard to understand them in terms of one another. From a monadic point of view, the big idea is that if you have the computation m >>= f, then f is m’s continuation. It’s the function that is called with m’s result to continue execution after m returns.

If you have a long chain of binds, the continuation is just the composition of all of them. So, for example, if you have

m >>= f >>= g >>= h

then the continuation of m is f >=> g >=> h. Likewise, the continuation of m >>= f is g >=> h.