add cpus and cpu features to zig targets

This commit is contained in:
Andrew Kelley 2020-01-21 01:48:25 -05:00
parent 0c2dde2fda
commit 5974f95cb7
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 35 additions and 5 deletions

View File

@ -1,5 +0,0 @@
Finish these thigns before merging teh branch
* zig targets
- use non-reflection based cpu detection?

View File

@ -177,6 +177,41 @@ pub fn cmdTargets(
}
try jws.endArray();
try jws.objectField("cpus");
try jws.beginObject();
inline for (@typeInfo(Target.Arch).Union.fields) |field| {
try jws.objectField(field.name);
try jws.beginObject();
const arch = @unionInit(Target.Arch, field.name, undefined);
for (arch.allCpus()) |cpu| {
try jws.objectField(cpu.name);
try jws.beginArray();
for (arch.allFeaturesList()) |feature, i| {
if (cpu.features.isEnabled(@intCast(u8, i))) {
try jws.arrayElem();
try jws.emitString(feature.name);
}
}
try jws.endArray();
}
try jws.endObject();
}
try jws.endObject();
try jws.objectField("cpuFeatures");
try jws.beginObject();
inline for (@typeInfo(Target.Arch).Union.fields) |field| {
try jws.objectField(field.name);
try jws.beginArray();
const arch = @unionInit(Target.Arch, field.name, undefined);
for (arch.allFeaturesList()) |feature| {
try jws.arrayElem();
try jws.emitString(feature.name);
}
try jws.endArray();
}
try jws.endObject();
try jws.objectField("native");
try jws.beginObject();
{