Skip to content

Instantly share code, notes, and snippets.

James Miller Aatch

Block or report user

Report or block Aatch

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
View after.ll
define void @test(%"Wrapper<Foo>"* nonnull, void (i8*)** noalias nocapture nonnull readonly) unnamed_addr #0 {
entry-block:
%2 = getelementptr inbounds void (i8*)*, void (i8*)** %1, i64 2
%3 = bitcast void (i8*)** %2 to i64*
%4 = load i64, i64* %3, align 8, !invariant.load !0
%5 = add i64 %4, 15
%6 = sub i64 0, %4
%7 = and i64 %5, %6
%8 = bitcast %"Wrapper<Foo>"* %0 to i8*
%9 = getelementptr i8, i8* %8, i64 %7
View thing.pde
import processing.pdf.*;
import java.util.Collection;
import java.util.Map;
float[] sizes;
float[] distortions;
float FREQUENCY = 5;
int mindiameter = 100;
View after.ll
define i32 @foo() unnamed_addr #0 {
entry-block:
%a = alloca i32
%temp0 = alloca {}
%temp3 = alloca {}
br label %start
start: ; preds = %entry-block
store i32 0, i32* %a
br label %bb2
View neighbors_opt.rs
use std::collections::HashSet;
use std::hash::BuildHasherDefault;
use std::default::Default;
use std::hash::Hasher;
pub struct FnvHasher(u64);
impl Default for FnvHasher {
#[inline]
View immediate.ll
define void @test() unnamed_addr #0 {
entry-block:
br label %start
start: ; preds = %entry-block
%0 = call i32 @bar()
br label %bb2
end: ; preds = %bb3
ret void
View lexer.rs
extern crate smallvec;
use std::collections::VecDeque;
use std::io::Read;
use smallvec::SmallVec;
pub type LexResult<T> = std::result::Result<T, Error>;
/**
@Aatch
Aatch / gist:8cea53541fc10eee41a4
Created May 31, 2015
Ramp Benchmarks 2015-06-01
View gist:8cea53541fc10eee41a4
test int::test::bench_add_1000_10 ... bench: 268 ns/iter (+/- 4)
test int::test::bench_add_1000_1000 ... bench: 1666 ns/iter (+/- 131)
test int::test::bench_add_100_100 ... bench: 205 ns/iter (+/- 33)
test int::test::bench_add_10_10 ... bench: 51 ns/iter (+/- 41)
test int::test::bench_add_1_1 ... bench: 39 ns/iter (+/- 33)
test int::test::bench_div_1000_1000 ... bench: 2359 ns/iter (+/- 4169)
test int::test::bench_div_10_10 ... bench: 58 ns/iter (+/- 135)
test int::test::bench_div_1_1 ... bench: 62 ns/iter (+/- 26)
test int::test::bench_div_20_2 ... bench: 226 ns/iter (+/- 30)
test int::test::bench_div_250_250 ... bench: 117 ns/iter (+/- 1094)
@Aatch
Aatch / if_cfg.rs
Last active Aug 29, 2015
Handy macro for complex conditional compilation
View if_cfg.rs
// Feel free to copy and modify this code if it's useful to you.
macro_rules! if_cfg {
($(#[cfg($cfg:meta)] $it:item)+ fallback: $els:item) => (
$(#[cfg($cfg)] $it)+
#[cfg(not(any($($cfg),*)))] $els
)
}
if_cfg {
#[cfg(target_arch="x86")]
View bad.rs
fn test() {
let x : [u8, ..256];
let val = get_val();
if val == 0 {
x = [1, ..256];
return x;
} else if val == 3 {
x = [3, ..256];
return x;
@Aatch
Aatch / gist:8466307
Created Jan 17, 2014
Surface Simplification with Quadric Error Metrics - for BlackMoon
View gist:8466307
; This is written pseudo-code, so hopefully should be fairly self-evident.
;
; A few notes about the general maths which I think will be needed:
;
; Matrices use what is called a "row-major" convention for sizes/indexes,
; this just means that a 2x3 matrix has 2 rows and 3 columns, it also
; means that for a matrix, M, M[1][2] is the number in the second column
; in the first row (I will also use base-1 indexing, since it better
; matches mathematical convention)
;
You can’t perform that action at this time.