Skip to content

Instantly share code, notes, and snippets.

function preprint(io::IO, output)
s = Base.LineEdit._state
ps = s.mode_state[s.current_mode]
buf = Base.LineEdit.buffer(ps)
pos = position(buf)
l_buf = count(c -> c=='\n', String(buf))
l_out = count(c -> c=="\n", output)
Base.LineEdit.move_input_start(s)
@ihnorton
ihnorton / recursive_type_abuse_macro.jl
Created September 2, 2015 14:56
recursive_type_abuse_macro.jl
macro RecurTypes(block)
(block.head == :block || error("RecurTypes must be defined in a begin...end block"))
defs = filter(ex -> (ex.head == :type || ex.head == :line ||
error("All arguments to RecurTypes must be type...end declarations");
ex.head == :type),
block.args)
topnames = map(ex -> ex.args[2], defs)
redotypes = Any[]
for def in defs
let newtypes = Any[]
diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm
index 701dfca..4b6ee7e 100644
--- a/src/julia-syntax.scm
+++ b/src/julia-syntax.scm
@@ -1062,6 +1062,17 @@
(break ,bb)))
+++ b/src/julia-syntax.scm
@@ -1062,6 +1062,17 @@
(break ,bb)))
(else (map (lambda (x) (replace-return x bb ret retval)) e))))
julia> @code_llvm Base._atexit()
define void @julia__atexit_21387() {
top:
%0 = alloca [6 x %jl_value_t*], align 4
%.sub12 = bitcast [6 x %jl_value_t*]* %0 to %jl_value_t**
%1 = getelementptr [6 x %jl_value_t*]* %0, i32 0, i32 2
%2 = getelementptr [6 x %jl_value_t*]* %0, i32 0, i32 4
%3 = bitcast [6 x %jl_value_t*]* %0 to i32*
store i32 8, i32* %3, align 4
@ihnorton
ihnorton / .gitignore
Last active August 29, 2015 14:22
test foo
ompdldie
*.so
*.dll
*.shlib
@ihnorton
ihnorton / ex.md
Last active August 29, 2015 14:19
more testing for 10394

Further-reduced example function and IR (identical between 3.3 and 3.6):

julia> elty = Complex{Float64}; x = ones(elty,10); p = -1
julia> function gv(p)
               av = float(abs(1.0+0.0im))
               T = Float64
               pp::promote_type(Float64, T) = p

               sum::Float64 = av^pp
       end
```
julia> df(n) = ccall((:dofoo, "C:/dev/jl36-cyg/src/libt.dll"),
Void,
(Ptr{Uint8},), &n)
df (generic function with 2 methods)
julia> @code_llvm df(n)
; Function Attrs: uwtable
define void @julia_df_89930(i64) #0 {
@ihnorton
ihnorton / Ref{T}
Created March 31, 2015 02:44
llvm 3.6
julia> f(trans,m,n,alpha,A,lda,X,incx,beta,Y,incy)=
ccall((:dgemv64_, "libopenblas"), Void,
(Ref{Uint8}, Ref{Int}, Ref{Int},
Ref{Float64}, Ref{Float64}, Ref{Int}, Ref{Float64},
Ref{Int},
Ref{Float64}, Ref{Float64}, Ref{Int}),
trans, m, n, alpha, A, lda, X, incx, beta, Y, incy)
f (generic function with 1 method)
@ihnorton
ihnorton / Ref{T}
Created March 31, 2015 02:41
llvm3.3
julia> f(trans,m,n,alpha,A,lda,X,incx,beta,Y,incy)=
ccall((:dgemv64_, "libopenblas"), Void,
(Ref{Uint8}, Ref{Int}, Ref{Int},
Ref{Float64}, Ref{Float64}, Ref{Int}, Ref{Float64},
Ref{Int},
Ref{Float64}, Ref{Float64}, Ref{Int}),
trans, m, n, alpha, A, lda, X, incx, beta, Y, incy)
f (generic function with 1 method)
@ihnorton
ihnorton / gist:c7c959285a4fcecc2c23
Last active August 29, 2015 14:17
ccall gemv example
A = [1.0 0.0; 0.0 1.0]; lda = 2; X = [ 1.0 1.0 ]; incx = 1;
beta = 0.0; Y = [0.0 0.0]; incy=1
trans = 'N'; m = 2; n = 2; alpha = 1.0;
ccall((:dgemv64_, "libopenblas"), cdecl, Void,
(Ptr{Uint8}, Ptr{Int}, Ptr{Int},
Ptr{Float64}, Ptr{Float64}, Ptr{Int}, Ptr{Float64},
Ptr{Int},
Ptr{Float64}, Ptr{Float64}, Ptr{Int}),
&trans, &m, &n, &alpha, A, &lda, X, &incx, &beta, Y, &incy)