Skip to content

Instantly share code, notes, and snippets.

@dcci
dcci / btree.rs
Last active March 1, 2017 00:25
btree interface
use std::marker::PhantomData;
/// A B-tree data structure which nodes are allocated from a pool.
pub struct BTree<K, V> {
index : u32,
unused1: PhantomData<K>,
unused2: PhantomData<V>
}
// A Node reference is a direct index to an element of the pool.
#include <cassert>
#include <cstdint>
enum Register_count {
gpr_registers_count = 0,
fpr_registers_count,
msa_registers_count,
register_set_count
};
#!/bin/bash
# git bisect start
# git bisect good <rev>
# git bisect bad <rev>
# git bisect run [script]
cd /home/davide/work/llvm-monorepo/build
ninja opt lli || exit 125 #125 tells git-bisect to skip
ulimit -t 5 && /home/davide/work/llvm-monorepo/build/bin/opt /home/davide/work/llvm-monorepo/build/bin/foo.ll -O3 | /home/davide/work/llvm-monorepo/build/bin/lli
[[ $? == 0 ]] && exit 0
@dcci
dcci / first.v
Last active March 5, 2018 01:09
software foundations
Check 3 = 3.
Check forall n m : nat, n + m = m + n.
Definition is_three (n : nat) : Prop :=
n = 3.
Definition injective {A B} (f : A -> B) :=
forall x y : A, f x = f y -> x = y.
Lemma succ_inj : injective S.
@dcci
dcci / indprop.v
Created March 7, 2018 04:01
Inductively defined propositions in coq
Inductive ev : nat -> Prop :=
| ev_0 : ev 0
| ev_SS : forall n : nat, ev n -> ev (S (S n)).
Theorem ev_4 : ev 4.
Proof.
apply ev_SS.
apply ev_SS.
apply ev_0.
--- pat.diff 2018-03-12 14:53:39.000000000 -0700
+++ pat2.diff 2018-03-12 14:54:14.000000000 -0700
@@ -15,25 +15,25 @@
decl: var intField: Int for 'intField' usr=s:14swift_ide_test8Myclass1C8intFieldSivp
decl: init() for '' usr=s:14swift_ide_test8Myclass1CACycfc
decl: func f1() for 'f1' usr=s:14swift_ide_test2f1yyF
-decl: func f1() for 's1ins' usr=s:14swift_ide_test2f1yyF5s1insL_AA9Mystruct1Vvp
+decl: var s1ins: Mystruct1 for 's1ins' usr=s:14swift_ide_test2f1yyF5s1insL_AA9Mystruct1Vvp
type: Mystruct1 for 's1ins' mangled=$S14swift_ide_test9Mystruct1VD
type: Int for 'intField' mangled=$SSiD
# Python reference http://lldb.llvm.org/python-reference.html
import lldb
def main():
dbg = lldb.SBDebugger.Create()
target = dbg.CreateTarget("a.out")
if not target:
print("Can't create target!")
return 1
davide@Davidinos-Mac-Pro ~/w/l/b/bin> ./clang ./pat.c -o pat -O1 -g
davide@Davidinos-Mac-Pro ~/w/l/b/bin> cat pat.c
int f(int x) {
asm("");
return 0;
}
__attribute__((noinline))
int g(int x) {
return x;
func f1() -> Int32 {
let x : Int32 = Int32.max
let y : Int32 = 42
return x + y
}
func f2(_ b : Bool) -> Int32 {
let verylarge : Int32 = Int32.max
@dcci
dcci / optout.c
Last active November 19, 2018 02:11
optimized out arguments
__attribute__((noinline))
int fn1 (long int x, long int y, long int z) {
int l = x * 2;
int q = y * z;
return l + q;
}
__attribute__((noinline)) long int
fn2 (long int a, long int b, long int c)
{