From 8282f3be960137e74c44827aea2436d3ff9fec30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 17 Oct 2024 01:48:37 +0200 Subject: [PATCH] std.Target: Add doc comments for Cpu.Arch.generic() and baseline(). --- lib/std/Target.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/std/Target.zig b/lib/std/Target.zig index def304bc6c..b17cb81fbf 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -1785,6 +1785,9 @@ pub const Cpu = struct { }; } + /// Returns the most bare-bones CPU model that is valid for `arch`. Note that this function + /// can return CPU models that are understood by LLVM, but *not* understood by Clang. If + /// Clang compatibility is important, consider using `baseline` instead. pub fn generic(arch: Arch) *const Model { const S = struct { const generic_model = Model{ @@ -1835,6 +1838,14 @@ pub const Cpu = struct { }; } + /// Returns a conservative CPU model for `arch` that is expected to be compatible with the + /// vast majority of hardware available. This function is guaranteed to return CPU models + /// that are understood by both LLVM and Clang, unlike `generic`. + /// + /// For certain `os` values, this function will additionally bump the baseline higher than + /// the baseline would be for `arch` in isolation; for example, for `aarch64-macos`, the + /// baseline is considered to be `apple_m1`. To avoid this behavior entirely, pass + /// `Os.Tag.freestanding`. pub fn baseline(arch: Arch, os: Os) *const Model { return switch (arch) { .arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline,