Skip to content

Instantly share code, notes, and snippets.

View lirenlin's full-sized avatar

Renlin Li lirenlin

View GitHub Profile
@lirenlin
lirenlin / gist:ea897903eb8c98599c40e1e79416e7ce
Last active October 10, 2018 07:54
vim count lines in selected range
https://stackoverflow.com/questions/7262536/vim-count-lines-in-selected-range
In visual mode, press gC-g
Typical output:
Selected 7 of 22 Lines; 8 of 32 Words; 201 of 491 Chars; 201 of 497 Bytes-- VISUAL LINE --
LowerExtractVectorElement, generate subreg from origianl BIG/vector register.
combine subreg into multiple subregs which is suitable for an instruction. (swizzle)
combine instructions with compatible swizzle modifiers (modifier forwarding)
swizzle extend + arithmetic swizzle = arithmetic swizzle + extend
@lirenlin
lirenlin / gist:8c6d7fd4117db9ef9c4a45bfd78671eb
Created September 25, 2018 15:01
git: abort commit in while writing commit message
Saving the file with no contents will abort any commit.
https://stackoverflow.com/questions/40906322/how-to-abort-git-commit-amend
1, cq, quite vim with an error code.
2, delete all content
3, comment out content with #
@lirenlin
lirenlin / gist:1b1b7855285bdef8e745e1f0320a4989
Created September 23, 2018 21:08
compiler lattice theory
https://math.stackexchange.com/questions/1545633/how-to-identify-lattice-in-given-hasse-diagrams
http://blog.ezyang.com/2011/04/hoopl-dataflow-lattices/
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-820-fundamentals-of-program-analysis-fall-2015/lecture-notes/MIT6_820F15_L17.pdf
http://www.itu.dk/people/brabrand/static.pdf
https://www.google.co.uk/search?q=these+partial+orders+are+not+lattices&safe=strict&client=ubuntu&hs=OZs&source=lnms&tbm=isch&sa=X&ved=0ahUKEwj3spLc8dHdAhXmLcAKHWtAC2QQ_AUIDigB&biw=1356&bih=911#imgrc=vctJzNgpsjyfEM:
@lirenlin
lirenlin / gist:a20d4b65f56bcf6499806bb069eb1511
Created September 23, 2018 18:54
compiler fixed-point algorithm
work list algorithm
The subset construction is an example of a fixed-point computation, a par-
ticular style of computation that arises regularly in computer science.
These computations are characterized by the iterated application of a monotone
function to some collection of sets drawn from a domain whose structure is
known. These computations terminate when they reach a state where further
iteration produces the same answer—a “fixed point” in the space of succes-
sive iterates. Fixed-point computations play an important and recurring role
@lirenlin
lirenlin / gist:4912a00ef310acb16590b351c132af86
Created September 22, 2018 11:02
compiler loop optimization
loop rotate: loop canonicalization, LICM, simplifying trip count expressions.
loop inversion: loop inversion allows safe loop-invariant code motion.
https://en.wikipedia.org/wiki/Loop_inversion
loop splitting, loop peeling
https://en.wikipedia.org/wiki/Loop_splitting
Loop unswitching
https://en.wikipedia.org/wiki/Loop_unswitching
clang front end static checker that, functions are properly called in given context.
e.g. some functions API cannot be called in ISR
OR functions called in ISR are user defined, but too long.
static code analysier, but C is too hard to process.
@lirenlin
lirenlin / gist:7a7f2fdb6e91a787660f8abda282ec70
Created September 14, 2018 14:29
vim shortcut for word pattern count
"shortcut for word pattern count, regex is supported
command! -narg=1 CNT execute '%s%<args>%%gn'
Color color = StringSwitch<Color>(argv[i])
.Case("red", Red)
.Case("orange", Orange)
.Case("yellow", Yellow)
.Case("green", Green)
.Case("blue", Blue)
.Case("indigo", Indigo)
.Cases("violet", "purple", Violet)
.Default(UnknownColor);
//===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//===----------------------------------------------------------------------===//
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/MapVector.h"