Skip to content

Instantly share code, notes, and snippets.

View MatzeB's full-sized avatar

Matthias Braun MatzeB

  • Menlo Park, USA
View GitHub Profile
@MatzeB
MatzeB / gist:9a578040fa0fe599ade7d9a6d9cb1766
Created November 4, 2023 00:01
Install cparser/libfirm and view a graph
# CParser
$ git clone --recursive https://github.com/libfirm/cparser.git
$ cd cparser
$ make
$ cat ~/test.c
int foobar(int a, int b) {
return a + b;
}
$ build/debug/cparser -S -o - ~/test.c -fdump-all-phases
# This will create lots of *.vcg files in the current directory
+ source config.sh
++ PYTHON=/home/matthiasb/compiling/tf_venv/bin/python
++ OBJ_BASE_DIR=/home/matthiasb/perfexp/luafoo
++ LLVM_DIR=/home/matthiasb/dev/llvm/tfbuild
++ RA_CORPUS=build/ra_corpus
++ RA_DEFAULT_TRACE=build/ra_default_trace
++ RA_DEFAULT_VOCAB=compiler_opt/rl/regalloc/vocab/
+++ pwd
++ RA_WARMSTART_OUTPUT_DIR=/home/matthiasb/compiling/ml-compiler-opt/build/ra_warmstart
+++ pwd
#!/usr/bin/env python2.7
#
# Swiss army knife to compare A/B benchmarking results. Mostly used to read
# test-suite result .csv files, but has grown readers for other formats by now.
import pandas as pd
import sys
import os.path
import re
import numbers
import argparse
/// SUBREG_TO_REG - Assert the value of bits in a super register.
/// The result of this instruction is the value of the second operand inserted
/// into the subregister specified by the third operand. All other bits are
/// assumed to be equal to the bits in the immediate integer constant in the
/// first operand. This instruction just communicates information; No code
/// should be generated.
/// This is typically used after an instruction where the write to a subregister
/// implicitely cleared the bits in the super registers.
mkdir /tmp/preprocessed
for i in MultiSource/Benchmarks/mediabench/gsm/toast/*.c SingleSource/Benchmarks/Adobe-C++/loop_unroll.cpp; do
clang -E $i -o /tmp/preprocessed/$(basename $i).i
done
# spacegoo game engine tweaked to allow future predictions on the game client
from copy import deepcopy
from math import ceil, sqrt
def distance(self, other):
xdiff = self.x-other.x
ydiff = self.y-other.y
return int(ceil(sqrt(xdiff*xdiff + ydiff*ydiff)))
def combine_fleets(fleet1, fleet2):