1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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;
}
|