Skip to content

Instantly share code, notes, and snippets.

Davide Italiano dcci

Block or report user

Report or block dcci

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dcci
dcci / btree.rs
Last active Mar 1, 2017
btree interface
View btree.rs
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.
View gist:01c10b405041fa8d139a4f71aec102f7
#include <cassert>
#include <cstdint>
enum Register_count {
gpr_registers_count = 0,
fpr_registers_count,
msa_registers_count,
register_set_count
};
View gist:891cd98d80b1b95352a407d80914f7cf
#!/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 Mar 5, 2018
software foundations
View first.v
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 Mar 7, 2018
Inductively defined propositions in coq
View indprop.v
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.
View gist:da05b9308cfa3ee860248adb83fc8bac
--- 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
View gist:bdfa0713a02ced182667aecea65730b9
# 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
View go home lldb, you're drunk.
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;
View gist:6c881156fce549e5f67a781d359d9f0f
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 Nov 19, 2018
optimized out arguments
View optout.c
__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)
{
You can’t perform that action at this time.