From 409e28f9cc10d82294f8948e5a5891ae20a1ea95 Mon Sep 17 00:00:00 2001
From: Reid Spencer
LLVM supports the notion of an "intrinsic function". These functions have -well known names and semantics and are required to follow certain -restrictions. Overall, these instructions represent an extension mechanism for -the LLVM language that does not require changing all of the transformations in -LLVM to add to the language (or the bytecode reader/writer, the parser, +well known names and semantics and are required to follow certain restrictions. +Overall, these intrinsics represent an extension mechanism for the LLVM +language that does not require changing all of the transformations in LLVM to +add to the language (or the bytecode reader/writer, the parser, etc...).
Intrinsic function names must all start with an "llvm." prefix. This @@ -3594,9 +3594,20 @@ or invoke instructions: it is illegal to take the address of an intrinsic function. Additionally, because intrinsic functions are part of the LLVM language, it is required that they all be documented here if any are added.
+Some intrinsic functions can be overloaded. That is, the intrinsic represents +a family of functions that perform the same operation but on different data +types. This is most frequent with the integer types. Since LLVM can represent +over 8 million different integer types, there is a way to declare an intrinsic +that can be overloaded based on its arguments. Such intrinsics will have the +names of the arbitrary types encoded into the intrinsic function name, each +preceded by a period. For example, the llvm.ctpop function can take an +integer of any width. This leads to a family of functions such as +i32 @llvm.ctpop.i8(i8 %val) and i32 @llvm.ctpop.i29(i29 %val). +
-To learn how to add an intrinsic function, please see the Extending LLVM Guide. + +
To learn how to add an intrinsic function, please see the +Extending LLVM Guide.
This is an overloaded intrinsic function. You can use bswap on any integer +type that is an even number of bytes (i.e. BitWidth % 16 == 0). Note the suffix +that includes the type for the result and the operand.
- declare i16 @llvm.bswap.i16(i16 <id>) - declare i32 @llvm.bswap.i32(i32 <id>) - declare i64 @llvm.bswap.i64(i64 <id>) + declare i16 @llvm.bswap.i16.i16(i16 <id>) + declare i32 @llvm.bswap.i32.i32(i32 <id>) + declare i64 @llvm.bswap.i64.i32(i64 <id>)
-The 'llvm.bwsap' family of intrinsics is used to byteswap a 16, 32 or -64 bit quantity. These are useful for performing operations on data that is not -in the target's native byte order. +The 'llvm.bwsap' family of intrinsics is used to byteswap integer +values with an even number of bytes (positive multiple of 16 bits). These are +useful for performing operations on data that is not in the target's native +byte order.
-The llvm.bswap.16 intrinsic returns an i16 value that has the high +The llvm.bswap.16.i16 intrinsic returns an i16 value that has the high and low byte of the input i16 swapped. Similarly, the llvm.bswap.i32 intrinsic returns an i32 value that has the four bytes of the input i32 swapped, so that if the input bytes are numbered 0, 1, 2, 3 then the returned -i32 will have its bytes in 3, 2, 1, 0 order. The llvm.bswap.i64 -intrinsic extends this concept to 64 bits. +i32 will have its bytes in 3, 2, 1, 0 order. The llvm.bswap.i48.i48, +llvm.bswap.i64.i64 and other intrinsics extend this concept to +additional even-byte lengths (6 bytes, 8 bytes and more, respectively).
This is an overloaded intrinsic. You can use llvm.ctpop on any integer bit +width. Not all targets support all bit widths however.
- declare i8 @llvm.ctpop.i8 (i8 <src>) - declare i16 @llvm.ctpop.i16(i16 <src>) + declare i32 @llvm.ctpop.i8 (i8 <src>) + declare i32 @llvm.ctpop.i16(i16 <src>) declare i32 @llvm.ctpop.i32(i32 <src>) - declare i64 @llvm.ctpop.i64(i64 <src>) + declare i32 @llvm.ctpop.i64(i64 <src>) + declare i32 @llvm.ctpop.i256(i256 <src>)
This is an overloaded intrinsic. You can use llvm.ctlz on any +integer bit width. Not all targets support all bit widths however.
- declare i8 @llvm.ctlz.i8 (i8 <src>) - declare i16 @llvm.ctlz.i16(i16 <src>) + declare i32 @llvm.ctlz.i8 (i8 <src>) + declare i32 @llvm.ctlz.i16(i16 <src>) declare i32 @llvm.ctlz.i32(i32 <src>) - declare i64 @llvm.ctlz.i64(i64 <src>) + declare i32 @llvm.ctlz.i64(i64 <src>) + declare i32 @llvm.ctlz.i256(i256 <src>)
This is an overloaded intrinsic. You can use llvm.cttz on any +integer bit width. Not all targets support all bit widths however.
- declare i8 @llvm.cttz.i8 (i8 <src>) - declare i16 @llvm.cttz.i16(i16 <src>) + declare i32 @llvm.cttz.i8 (i8 <src>) + declare i32 @llvm.cttz.i16(i16 <src>) declare i32 @llvm.cttz.i32(i32 <src>) - declare i64 @llvm.cttz.i64(i64 <src>) + declare i32 @llvm.cttz.i64(i64 <src>) + declare i32 @llvm.cttz.i256(i256 <src>)