import "cffc.hff"; import "common.hff"; static const targs []const Targ = { { "amd64-sysv", .ptrsize: 8, .intsize: 4, .i64align: 8, .longsize: 8, .longalign: 8, .llongsize: 8, .llongalign: 8, .sizesize: 8, .f64align: 8, .valistsize: 24, .valistalign: 8, .valistllvmty: "{ i32, i32, i8*, i8* }", .charsigned: #t, .shortenum: #f, } }; extern static g_targ Targ = {}; extern fn targ_ini(name *const u8) bool { foreach(targ, i, targs[0::]) { if streq(name, targ.name) { g_targ = targs[i]; return #t; } } return #f; } extern fn triple2targ(triple *const u8) *const u8 { let arch = (do let delim = strstr(triple, "-"); delim ? triple[0::delim - triple] : spanz(triple); ); let rest = arch.#ptr + arch.#len; defmacro archp(s) [ (strncmp(s, arch.#ptr, arch.#len) == 0) ] defmacro restp(s) [ (strstr(rest, s) != #null) ] switch { case archp("x86_64") and !restp("windows"); return "amd64-sysv"; } return #null; }