Open
Description
MWE:
using LLVM
using LLVM.Interop
function search(v, key)
low = 0
high = length(v)
@inbounds while low ≤ high
mid = round((high + low)÷2)
middle = v[mid]
if middle == key; return(mid); end
new_low = mid
new_high = mid
low, high =
@asmcall("""cmp \$4, \$5;
cmovae \$2, \$0;
cmovb \$3, \$1;""",
"=r,=r,r,r,r,r,0,1",
Tuple{Int,Int},
Tuple{Int,Int,Int,Int,Int,Int},
low, high, new_low, new_high, middle, key)
end
end
ERROR: Failed to parse LLVM assembly:
<string>:7:23: error: number of output constraints does not match number of return struct elements
%6 = call [2 x i64] asm "cmp $4, $5;\0Acmovae $2, $0;\0Acmovb $3, $1;", "=r,=r,r,r,r,r,0,1"(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5)
Note the [2 x i64]
in there; LLVM expects { i64, i64 }
, so we should be able to invoke julia_type_to_llvm
with llvmcall=true
(this is currently not exported).