Skip to content

Instantly share code, notes, and snippets.

View MrSmith33's full-sized avatar

Andrey Penechko MrSmith33

View GitHub Profile
@MrSmith33
MrSmith33 / fannkuch.vx
Last active January 7, 2021 15:37
Vox programs
// vox fannkuch.vx C:\Windows\System32\kernel32.dll
// https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/fannkuchredux.html
void main() {
i32 n = 12;
Result res = fannkuch(n);
println("fannkuch(", n, ") = ", res.sum, " ", res.maxflips);
ExitProcess(0);
}
import std;
struct Node
{
int value;
Node* next;
}
Node* reverseList(Node* head)
{
intervals formatInt
p 0 rax [rax]: [40; 41) [86; 88) [108; 112)
p 1 rcx [rcx]: [1; 2) [30; 41)
p 2 rdx [rdx]: [1; 4) [32; 41) [84; 90) [106; 110)
p 4 rsp [rsp]: [36; 44)
p 8 r8 [r8]: [1; 6) [34; 41)
p 9 r9 [r9]: [1; 8) [36; 41)
p 10 r10 [r10]: [40; 41)
p 11 r11 [r11]: [40; 41)
void tran_thong(i32 xstart, i32 ystart, i32 xend, i32 yend, void function(void*, i32, i32) callback, void* userData)
{
i32 x = xstart;
i32 y = ystart;
i32 deltax;
i32 signdx;
if (xend >= xstart) {
deltax = xend - xstart;
signdx = 1;
@MrSmith33
MrSmith33 / RL_tutorial_2019.har
Created June 24, 2019 08:09
Roguelike Tutorial 2019 compiled with tiny_jit compiler
--- <cli_args>
main.d sdl.d sdlimage.d kernel32.d C:\Windows\System32\kernel32.dll SDL2.dll SDL2_image.dll
--- main.d
import sdl;
import sdlimage;
import kernel32;
enum scale = 2;
enum map_width = 10;
enum map_height = 10;
15 100 1к 10к 100к 1М 10M
TCC 0.9.27 8.5 8.6 8.7 12 48 426 8749
tiny_jit 19 20 21 30 135 1172 11600
MSVC 2017 82 82 90 114 503 45000 2116000
DMD 2.083 94 95 98 141 594 5510 OOM
Clang 7.0.1 107 109 123 290 2000 18500 183000
Go 1.12.4 156 154 171 349 1921 18096 318963
Rust 1.34.1 165 169 197 516 3896 39260 852222
GCC 8.3.0 196 199 241 682 5718 199000 26920000
GCC 4.8.3 125 130 178 665 6420 269000 ICE
@MrSmith33
MrSmith33 / dmd_bug.d
Created October 10, 2018 08:38
Error: CTFE internal error: ErrorExp
import std.array : empty;
import std.string : format;
import std.typecons : Flag, Yes, No;
import std.stdio : writeln, write, writef, writefln, stdout;
import std.format : formattedWrite, FormatSpec;
import std.range : repeat;
import std.range : chain;
import std.bitmanip : bitfields;
import std.algorithm : min, max, sort, swap;
import std.stdio;
#!/bin/bash
num_steps=100
tasks_per_man=10
let num_managers=$num_steps/$tasks_per_man
int_from=-100
int_to=100
awk -v xmin="$int_from" -v xmax="$int_to" -v num_steps="$num_steps" 'BEGIN {dx=(xmax-xmin)/num_steps; for (i = xmin; i < xmax; i+=dx) print i" "i+dx }' > ranges.txt
g++ integral.cxx -oexe
# res - results for individual tasks
@MrSmith33
MrSmith33 / pointer indexing.d
Created April 17, 2018 12:10
Code generated by indexing pointer
// Source
i32 test(i32* array, i32 index) {
return array[index]; // read from array
}
// IR
function i32 $test () {
| @start:0 instr[0..6]
1| %0 = ptr o_param uses [ ptr %3]
2| %1 = i32 o_param uses [ i64 %2]