Skip to content

Commit d8d9059

Browse files
authored
Merge pull request #141 from maleadt/tb/asmcall_tuple
asmcall: specify return type as an expression.
2 parents e2cc665 + ff24d62 commit d8d9059

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/interop/asmcall.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ arguments as a tuple-type in `argtyp`.
3838
:(@asmcall)
3939

4040
macro asmcall(asm::String, constraints::String, side_effects::Bool,
41-
rettyp::Symbol=:(Nothing), argtyp::Expr=:(Tuple{}), args...)
41+
rettyp::Union{Expr,Symbol}=:(Nothing), argtyp::Expr=:(Tuple{}), args...)
4242
asm_val = Val{Symbol(asm)}()
4343
constraints_val = Val{Symbol(constraints)}()
4444
return esc(:(LLVM.Interop._asmcall($asm_val, $constraints_val,
@@ -48,12 +48,12 @@ end
4848

4949
# shorthand: no side_effects
5050
macro asmcall(asm::String, constraints::String,
51-
rettyp::Symbol=:(Nothing), argtyp::Expr=:(Tuple{}), args...)
51+
rettyp::Union{Expr,Symbol}=:(Nothing), argtyp::Expr=:(Tuple{}), args...)
5252
esc(:(LLVM.Interop.@asmcall $asm $constraints false $rettyp $argtyp $(args...)))
5353
end
5454

5555
# shorthand: no side_effects or constraints
5656
macro asmcall(asm::String,
57-
rettyp::Symbol=:(Nothing), argtyp::Expr=:(Tuple{}), args...)
57+
rettyp::Union{Expr,Symbol}=:(Nothing), argtyp::Expr=:(Tuple{}), args...)
5858
esc(:(LLVM.Interop.@asmcall $asm "" $rettyp $argtyp $(args...)))
5959
end

test/interop.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ c3() = @asmcall("nop", "", false, Nothing, Tuple{})
8383
d1(a) = @asmcall("bswap \$0", "=r,r", Int32, Tuple{Int32}, a)
8484
@test d1(Int32(1)) == Int32(16777216)
8585

86+
# multiple output registers
87+
88+
e1() = @asmcall("mov \$\$1, \$0; mov \$\$2, \$1;", "=r,=r", Tuple{Int32,Int64})
89+
@test e1() == (Int32(1), Int64(2))
90+
8691
end
8792

8893

0 commit comments

Comments
 (0)