| 1 | const std = @import("std"); |
| 2 | const expectEqual = std.testing.expectEqual; |
| 3 | |
| 4 | comptime { |
| 5 | asm ( |
| 6 | \\.global my_func; |
| 7 | \\.type my_func, @function; |
| 8 | \\my_func: |
| 9 | \\ lea (%rdi,%rsi,1),%eax |
| 10 | \\ retq |
| 11 | ); |
| 12 | } |
| 13 | |
| 14 | extern fn my_func(a: i32, b: i32) i32; |
| 15 | |
| 16 | test "global assembly" { |
| 17 | try expectEqual(46, my_func(12, 34)); |
| 18 | } |
| 19 | |
| 20 | // test |
| 21 | // target=x86_64-linux |
| 22 | // llvm=true |