Where is documentation for the Builtin module?

Reading through standard library source code, there are many calls to things in the Builtin module.

I would like to read documentation for those things, and if possible their implementations as well.

However, I do not currently know where to find it.

1 Like

Functions:

Also here for some builtin types:

1 Like

Note that every LLVM IR intrinsic is surfaced in the builtin module; Builtins.def only defines special handling that differs from what would otherwise happen, so it's a small piece of what is provided.

E.g., suppose we wanted to call the llvm.vector.reduce.add intrinsic to reduce a SIMD16. It's defined as:

declare i8 @llvm.vector.reduce.add.v16i8(<16 x i8> %a)

In Swift, we spell that: Builtin.int_vector_reduce_add_Vec16xInt8 (the "int" is for "intrinsic"; in general the mapping goes: replace @llvm with int, replace . with _, and, append the right type(s) as needed). But we also have to map from the surface swift types to the builtin types for this to work: Compiler Explorer. Note that there is basically nothing in the way of error messages or useful diagnostics when working with builtins. If you get something wrong, it simply doesn't compile, or the compiler might crash. Usually that's because you misspelled something, but sometimes it's because some builtin path just isn't implemented (though most of the ones you're likely to want are).

12 Likes
Terms of Service

Privacy Policy

Cookie Policy