Skip to content

Instantly share code, notes, and snippets.

@eliben
eliben / cuda.h
Created October 6, 2014 22:11
Minimal CUDA support header for parsing with Clang
/* Minimal declarations for CUDA support. Testing purposes only. */
#define __constant__ __attribute__((constant))
#define __device__ __attribute__((device))
#define __global__ extern "C" __attribute__((global))
#define __host__ __attribute__((host))
#define __shared__ __attribute__((shared))
#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
#define __forceinline__ __attribute__((always_inline))
diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp
index dc5f67b..6aa60c6 100644
--- a/lib/CodeGen/CodeGenPrepare.cpp
+++ b/lib/CodeGen/CodeGenPrepare.cpp
@@ -1640,6 +1640,7 @@ bool AddressingModeMatcher::MatchScaledValue(Value *ScaleReg, int64_t Scale,
static bool MightBeFoldableInst(Instruction *I) {
switch (I->getOpcode()) {
case Instruction::BitCast:
+ case Instruction::AddrSpaceCast:
// Don't touch identity bitcasts.
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@eliben
eliben / lexer.go
Last active January 26, 2022 04:03
TableGen lexer in Go (lexer.go and an input file)
// Lexer for the TableGen language.
package main
import (
"fmt"
"io/ioutil"
"log"
"time"
"unicode/utf8"
)
@eliben
eliben / gist:9158301
Created February 22, 2014 17:14
comment after def
def foo(): # told you
y = 2
file_input [2 children]
funcdef [5 children]
NAME('def') [lineno=1, column=0, prefix='']
NAME('foo') [lineno=1, column=4, prefix=' ']
parameters [2 children]
LPAR('(') [lineno=1, column=7, prefix='']
RPAR(')') [lineno=1, column=8, prefix='']
@eliben
eliben / gist:9158261
Created February 22, 2014 17:12
embedded comment in next prefix
Input code:
x = 1 # told you
y = 2
Breakdown of the lib2to3 parse tree. The thingies with [N children] are nodes. The rest are leaves.
file_input [3 children]
@eliben
eliben / Loop benchmark
Last active December 30, 2015 03:39
C benchmark demonstrating bizarre performance behavior of Intel CPUs
const unsigned N = 400 * 1000 * 1000;
volatile unsigned long long counter = 0;
// Don't inline the benchmarking code into main
void __attribute__((noinline)) tightloop();
void __attribute__((noinline)) loop_with_extra_call();
void tightloop() {
unsigned j;
@eliben
eliben / gist:6202493
Last active December 20, 2015 22:09
import io
from test.support import import_fresh_module
import csv
csv_other = import_fresh_module('csv', fresh=['_csv', 'csv'])
f = io.StringIO('foo\x00,bar\nbaz,42')
reader = csv.reader(f)
@eliben
eliben / gist:5797351
Created June 17, 2013 14:36
Generic regex-based lexer in Python
#-------------------------------------------------------------------------------
# lexer.py
#
# A generic regex-based Lexer/tokenizer tool.
# See the if __main__ section in the bottom for an example.
#
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
# Last modified: August 2010
#-------------------------------------------------------------------------------
====> lli
lli
AsmParser
Core
Support
Support
BitReader
Core
Support
IRReader