From ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Mon, 12 Oct 2026 08:46:23 +0330 Subject: a --- tests/programs/cabi_o3.zc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/programs/cabi_o3.zc (limited to 'tests/programs/cabi_o3.zc') diff --git a/tests/programs/cabi_o3.zc b/tests/programs/cabi_o3.zc new file mode 100644 index 0000000..5c9a55a --- /dev/null +++ b/tests/programs/cabi_o3.zc @@ -0,0 +1,30 @@ +// native calls from o3 code: lifted into the region as micro-ops, called directly by llvm +extern double sqrt(double); +extern double pow(double, double); +extern double fma(double, double, double); +extern int snprintf9(word *buf, long cap, str fmt, long a, long b, long c, long d, long e, long f) = "snprintf"; +extern long labs(long); + +fn put_f(x) { asm { x @ #1220 } return 0; } + +o3 float norm(int n) { + float acc = 0.0; + for (int i = 1; i <= n; i++) acc = acc + sqrt(i * 1.0) + fma(1.0, 2.0, 0.5); + return acc; +} +o3 int absum(int n) { + int t = 0; + for (int i = 0; i < n; i++) t = t + labs(i - 50); + return t; +} +fn main() { + let buf[16]; + let i = 0; + put_f(norm(100)); put_c(32); + put_f(pow(2.0, 0.5)); put_c(32); + put_n(absum(100)); put_c(10); + put_n(snprintf9(buf, 100, b"%ld-%ld-%ld-%ld-%ld-%ld", 1, 2, 3, 4, 5, 6)); put_c(32); + while (i < 11) { put_c(ld8(addr_b(buf) + i)); i++; } + put_c(10); + return 0; +} -- cgit v1.2.3