iter 23.3.1: runtime ail_str_compare + IR header declaration

This commit is contained in:
2026-05-10 23:00:22 +02:00
parent 2c974e3c7e
commit 94893bfb9d
7 changed files with 62 additions and 0 deletions
+14
View File
@@ -24,3 +24,17 @@
bool ail_str_eq(const char *a, const char *b) {
return strcmp(a, b) == 0;
}
/* Three-way comparison of NUL-terminated strings. Normalises libc
* strcmp's signed-int output to exactly -1 / 0 / +1 so the codegen
* caller can branch on `icmp slt i32 result, 0` and
* `icmp eq i32 result, 0` against constants directly without
* worrying about strcmp implementations that return values outside
* {-1, 0, +1}. Heap-Str ABI milestone will replace the body with
* length-prefixed comparison without changing the signature. */
int ail_str_compare(const char *a, const char *b) {
int r = strcmp(a, b);
if (r < 0) return -1;
if (r > 0) return 1;
return 0;
}