Standard library · Compiler and tools

llvm/triple

The data layout and target features worked out from a triple, with no LLVM needed.

import llvm.triple
On this page
  1. Functions

A target triple, such as x86_64-unknown-linux-gnu, names the architecture, the vendor, the operating system and the environment. Without linking against LLVM, this package gives from it what a compiler needs before it generates code, such as the pointer size and the data layout.

Functions

HostDatalayout

func HostDatalayout(): str
The data layout of the host machine.
llvm-triple-Layout.salam
import llvm.triple

func main:
    each target in ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "aarch64-apple-darwin", "x86_64-pc-windows-msvc", "i686-w64-windows-gnu", "wasm32-unknown-wasi"]:
        println target, triple.PointerBits(target), triple.IsWindows(target), triple.IsGlibc(target)
        dl := triple.Datalayout(target)
        if dl.len() > 0:
            println "  ", dl
        else:
            println "  unknown; LLVM works it out itself"
        end
    end
    println triple.HostDatalayout().len() > 0
end
Outputx86_64-unknown-linux-gnu 64 false true e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128 aarch64-unknown-linux-musl 64 false false e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128 aarch64-apple-darwin 64 false false e-m:o-i64:64-i128:128-n32:64-S128 x86_64-pc-windows-msvc 64 true false e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128 i686-w64-windows-gnu 32 true false unknown; LLVM works it out itself wasm32-unknown-wasi 32 false false unknown; LLVM works it out itself true

Datalayout

func Datalayout(t: str): str
The LLVM data layout string for the triple: the byte order, the pointer size and the alignment of the types; empty for an unknown target.

The example for this item is shown with the ones above: llvm-triple-Layout.salam

PointerBits

func PointerBits(t: str): int
The pointer size of the target in bits: 32 or 64.

The example for this item is shown with the ones above: llvm-triple-Layout.salam

IsWindows

func IsWindows(t: str): bool
The target is Windows.

The example for this item is shown with the ones above: llvm-triple-Layout.salam

IsGlibc

func IsGlibc(t: str): bool
The target is Linux with glibc, not musl.

The example for this item is shown with the ones above: llvm-triple-Layout.salam