/usr/share/julia/test/llvmcall.jl is in julia-common 0.4.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # This file is a part of Julia. License is MIT: http://julialang.org/license
using Base.llvmcall
#function add1234(x::Tuple{Int32,Int32,Int32,Int32})
# llvmcall("""%3 = add <4 x i32> %1, %0
# ret <4 x i32> %3""",
# Tuple{Int32,Int32,Int32,Int32},
# Tuple{Tuple{Int32,Int32,Int32,Int32},
# Tuple{Int32,Int32,Int32,Int32}},
# (Int32(1),Int32(2),Int32(3),Int32(4)),
# x)
#end
#
#function add1234(x::NTuple{4,Int64})
# llvmcall("""%3 = add <4 x i64> %1, %0
# ret <4 x i64> %3""",NTuple{4,Int64},
# Tuple{NTuple{4,Int64},NTuple{4,Int64}},
# (Int64(1),Int64(2),Int64(3),Int64(4)),
# x)
#end
#
function add1234(x::Tuple{Int32,Int32,Int32,Int32})
llvmcall("""%3 = extractvalue [4 x i32] %0, 0
%4 = extractvalue [4 x i32] %0, 1
%5 = extractvalue [4 x i32] %0, 2
%6 = extractvalue [4 x i32] %0, 3
%7 = extractvalue [4 x i32] %1, 0
%8 = extractvalue [4 x i32] %1, 1
%9 = extractvalue [4 x i32] %1, 2
%10 = extractvalue [4 x i32] %1, 3
%11 = add i32 %3, %7
%12 = add i32 %4, %8
%13 = add i32 %5, %9
%14 = add i32 %6, %10
%15 = insertvalue [4 x i32] undef, i32 %11, 0
%16 = insertvalue [4 x i32] %15, i32 %12, 1
%17 = insertvalue [4 x i32] %16, i32 %13, 2
%18 = insertvalue [4 x i32] %17, i32 %14, 3
ret [4 x i32] %18""",Tuple{Int32,Int32,Int32,Int32},
Tuple{Tuple{Int32,Int32,Int32,Int32},Tuple{Int32,Int32,Int32,Int32}},
(Int32(1),Int32(2),Int32(3),Int32(4)),
x)
end
@test add1234(map(Int32,(2,3,4,5))) === map(Int32,(3,5,7,9))
#@test add1234(map(Int64,(2,3,4,5))) === map(Int64,(3,5,7,9))
# Test whether llvmcall escapes the function name correctly
baremodule PlusTest
using Base.llvmcall
using Base.Test
using Base
function +(x::Int32, y::Int32)
llvmcall("""%3 = add i32 %1, %0
ret i32 %3""",
Int32,
Tuple{Int32, Int32},
x,
y)
end
@test Int32(1) + Int32(2) == Int32(3)
end
# issue #11800
@test eval(Expr(:call,Core.Intrinsics.llvmcall,
"""%3 = add i32 %1, %0
ret i32 %3""", Int32, Tuple{Int32, Int32},
Int32(1), Int32(2))) == 3
|