Skip to content

Instantly share code, notes, and snippets.

Avatar

Leonard Ritter paniq

View GitHub Profile
@paniq
paniq / bdd_select.txt
Last active Mar 19, 2021
useful selection identities
View bdd_select.txt
(c f t) <> select(c,t,f) <> c?t:f <> !c&f | c&t
0 = (x 0 0) = (0 0 x) = (x x 0) = (x 0 !x)
1 = (x 1 1) = (1 x 1) = (x 1 x) = (x !x 1)
x = (x 0 1) = (1 y x) = (0 x y) = (x 0 x) = (x x 1) = (y x x)
!x = (x 1 0) = (x !x 0) = (x 1 !x)
(!a b c) = (a c b)
View uvmir_builder.sc
using import enum
using import struct
using import Rc
using import Array
using import Map
using import testing
let Id = u32
View register_alloc.sc
# register allocation algorithm idea in O(n)
by leonard ritter
based on DAG visualization here:
https://twitter.com/paniq/status/1297661746832973825
using import Array
View resize.sc
using import testing
# test alignment
inline test-alignment (T)
let size alignment =
ptrtoint (getelementptr (nullof (mutable pointer T)) 1) u64
ptrtoint (getelementptr (nullof (mutable pointer (tuple bool T))) 0 1) u64
print T size alignment
if (size != (sizeof T))
View pipetiles.sc
using import itertools
using import Set
let TILEX = 4
let TILEY = 3
let NUMTILES = (TILEX * TILEY)
let TILEBITS = 4
let TILEBITMASK = 0xf:u64
View test_bullet.sc
using import C.string
import ..tukan.use
using import tukan.bullet.C
let datadir =
.. module-dir "/../build/src/bullet/data"
local dofCount : i32
local posVarCount : i32
View SSAT.txt
// classical SSA structure
function (%1 %2)
main:
%3 = icmp %1 %2
condbr %3 branch1 branch2
branch1:
%4 = add %1 %2
br merge
branch2:
%5 = mul %1 %2
View gist:fb6aff95fb2cdf6e5fd358f3069f25ad
do
using import struct
struct T
a = 0
RcT := (Rc T)
struct Container
data : RcT
View corona_per_capita.txt
using data from https://coronavirus.jhu.edu/map.html: 3/13/2020 3:53:03 p.m.
infected population per capita^-1
US 1,268 327,200,000 258,044
japan 639 126,800,000 198,435
UK 593 66,440,000 112,040
austria 302 8,822,000 29,211
germany 3,059 82,790,000 27,064