lib/systems/parse: make isCompatible description clearer and more useful

Stating that CPUs and the isCompatible relation forms a category (or
preorder) is correct but overtly technical.  We can state it more
clearly for readers unfamiliar with mathematics while retaining some
keywords to be useful to technical readers.
This commit is contained in:
Ben Siraphob 2021-02-22 16:29:47 +07:00 committed by Jonathan Ringer
parent 006d7f80eb
commit f986333023

View file

@ -121,15 +121,20 @@ rec {
js = { bits = 32; significantByte = littleEndian; family = "js"; }; js = { bits = 32; significantByte = littleEndian; family = "js"; };
}; };
# Determine where two CPUs are compatible with each other. That is, # Determine when two CPUs are compatible with each other. That is,
# can we run code built for system b on system a? For that to # can code built for system B run on system A? For that to happen,
# happen, then the set of all possible possible programs that system # the programs that system B accepts must be a subset of the
# b accepts must be a subset of the set of all programs that system # programs that system A accepts.
# a accepts. This compatibility relation forms a category where each #
# CPU is an object and each arrow from a to b represents # We have the following properties of the compatibility relation,
# compatibility. CPUs with multiple modes of Endianness are # which must be preserved when adding compatibility information for
# isomorphic while all CPUs are endomorphic because any program # additional CPUs.
# built for a CPU can run on that CPU. # - (reflexivity)
# Every CPU is compatible with itself.
# - (transitivity)
# If A is compatible with B and B is compatible with C then A is compatible with C.
# - (compatible under multiple endianness)
# CPUs with multiple modes of endianness are pairwise compatible.
isCompatible = a: b: with cpuTypes; lib.any lib.id [ isCompatible = a: b: with cpuTypes; lib.any lib.id [
# x86 # x86
(b == i386 && isCompatible a i486) (b == i386 && isCompatible a i486)