# Changeset View

Changeset View

# Standalone View

Standalone View

# llvm/trunk/docs/LangRef.rst

- This file is larger than 256 KB, so syntax highlighting is disabled by default.

Show First 20 Lines • Show All 13083 Lines • ▼ Show 20 Line(s) | |||||

13084 | 13084 | | |||

13085 | The '``llvm.smul.fix``' family of intrinsic functions perform signed | 13085 | The '``llvm.smul.fix``' family of intrinsic functions perform signed | ||

13086 | fixed point multiplication on 2 arguments of the same scale. | 13086 | fixed point multiplication on 2 arguments of the same scale. | ||

13087 | 13087 | | |||

13088 | Arguments | 13088 | Arguments | ||

13089 | """""""""" | 13089 | """""""""" | ||

13090 | 13090 | | |||

13091 | The arguments (%a and %b) and the result may be of integer types of any bit | 13091 | The arguments (%a and %b) and the result may be of integer types of any bit | ||

13092 | width, but they must have the same bit width. ``%a`` and ``%b`` are the two | 13092 | width, but they must have the same bit width. The arguments may also work with | ||

13093 | int vectors of the same length and int size. ``%a`` and ``%b`` are the two | ||||

13093 | values that will undergo signed fixed point multiplication. The argument | 13094 | values that will undergo signed fixed point multiplication. The argument | ||

13094 | ``%scale`` represents the scale of both operands, and must be a constant | 13095 | ``%scale`` represents the scale of both operands, and must be a constant | ||

13095 | integer. | 13096 | integer. | ||

13096 | 13097 | | |||

13097 | Semantics: | 13098 | Semantics: | ||

13098 | """""""""" | 13099 | """""""""" | ||

13099 | 13100 | | |||

13100 | This operation performs fixed point multiplication on the 2 arguments of a | 13101 | This operation performs fixed point multiplication on the 2 arguments of a | ||

13101 | specified scale. The result will also be returned in the same scale specified | 13102 | specified scale. The result will also be returned in the same scale specified | ||

13102 | in the third argument. | 13103 | in the third argument. | ||

13103 | 13104 | | |||

13104 | If the result value cannot be precisely represented in the given scale, the | 13105 | If the result value cannot be precisely represented in the given scale, the | ||

13105 | value is rounded up or down to the closest representable value. The rounding | 13106 | value is rounded up or down to the closest representable value. The rounding | ||

13106 | direction is unspecified. | 13107 | direction is unspecified. | ||

13107 | 13108 | | |||

13108 | It is undefined behavior if the source value does not fit within the range of | 13109 | It is undefined behavior if the result value does not fit within the range of | ||

13109 | the fixed point type. | 13110 | the fixed point type. | ||

13110 | 13111 | | |||

13111 | 13112 | | |||

13112 | Examples | 13113 | Examples | ||

13113 | """"""""" | 13114 | """"""""" | ||

13114 | 13115 | | |||

13115 | .. code-block:: llvm | 13116 | .. code-block:: llvm | ||

13116 | 13117 | | |||

13117 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6) | 13118 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6) | ||

13118 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5) | 13119 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5) | ||

13119 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 x -1 = -1.5) | 13120 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 -2, i32 1) ; %res = -3 (1.5 x -1 = -1.5) | ||

13120 | 13121 | | |||

13121 | ; The result in the following could be rounded up to -2 or down to -2.5 | 13122 | ; The result in the following could be rounded up to -2 or down to -2.5 | ||

13122 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 -3, i32 1) ; %res = -5 (or -4) (1.5 x -1.5 = -2.25) | 13123 | %res = call i4 @llvm.smul.fix.i4(i4 3, i4 -3, i32 1) ; %res = -5 (or -4) (1.5 x -1.5 = -2.25) | ||

13123 | 13124 | | |||

13124 | 13125 | | |||

13126 | '``llvm.umul.fix.*``' Intrinsics | ||||

13127 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||

13128 | | ||||

13129 | Syntax | ||||

13130 | """"""" | ||||

13131 | | ||||

13132 | This is an overloaded intrinsic. You can use ``llvm.umul.fix`` | ||||

13133 | on any integer bit width or vectors of integers. | ||||

13134 | | ||||

13135 | :: | ||||

13136 | | ||||

13137 | declare i16 @llvm.umul.fix.i16(i16 %a, i16 %b, i32 %scale) | ||||

13138 | declare i32 @llvm.umul.fix.i32(i32 %a, i32 %b, i32 %scale) | ||||

13139 | declare i64 @llvm.umul.fix.i64(i64 %a, i64 %b, i32 %scale) | ||||

13140 | declare <4 x i32> @llvm.umul.fix.v4i32(<4 x i32> %a, <4 x i32> %b, i32 %scale) | ||||

13141 | | ||||

13142 | Overview | ||||

13143 | """"""""" | ||||

13144 | | ||||

13145 | The '``llvm.umul.fix``' family of intrinsic functions perform unsigned | ||||

13146 | fixed point multiplication on 2 arguments of the same scale. | ||||

13147 | | ||||

13148 | Arguments | ||||

13149 | """""""""" | ||||

13150 | | ||||

13151 | The arguments (%a and %b) and the result may be of integer types of any bit | ||||

13152 | width, but they must have the same bit width. The arguments may also work with | ||||

13153 | int vectors of the same length and int size. ``%a`` and ``%b`` are the two | ||||

13154 | values that will undergo unsigned fixed point multiplication. The argument | ||||

13155 | ``%scale`` represents the scale of both operands, and must be a constant | ||||

13156 | integer. | ||||

13157 | | ||||

13158 | Semantics: | ||||

13159 | """""""""" | ||||

13160 | | ||||

13161 | This operation performs unsigned fixed point multiplication on the 2 arguments of a | ||||

13162 | specified scale. The result will also be returned in the same scale specified | ||||

13163 | in the third argument. | ||||

13164 | | ||||

13165 | If the result value cannot be precisely represented in the given scale, the | ||||

13166 | value is rounded up or down to the closest representable value. The rounding | ||||

13167 | direction is unspecified. | ||||

13168 | | ||||

13169 | It is undefined behavior if the result value does not fit within the range of | ||||

13170 | the fixed point type. | ||||

13171 | | ||||

13172 | | ||||

13173 | Examples | ||||

13174 | """"""""" | ||||

13175 | | ||||

13176 | .. code-block:: llvm | ||||

13177 | | ||||

13178 | %res = call i4 @llvm.umul.fix.i4(i4 3, i4 2, i32 0) ; %res = 6 (2 x 3 = 6) | ||||

13179 | %res = call i4 @llvm.umul.fix.i4(i4 3, i4 2, i32 1) ; %res = 3 (1.5 x 1 = 1.5) | ||||

13180 | | ||||

13181 | ; The result in the following could be rounded down to 3.5 or up to 4 | ||||

13182 | %res = call i4 @llvm.umul.fix.i4(i4 15, i4 1, i32 1) ; %res = 7 (or 8) (7.5 x 0.5 = 3.75) | ||||

13183 | | ||||

13184 | | ||||

13125 | Specialised Arithmetic Intrinsics | 13185 | Specialised Arithmetic Intrinsics | ||

13126 | --------------------------------- | 13186 | --------------------------------- | ||

13127 | 13187 | | |||

13128 | '``llvm.canonicalize.*``' Intrinsic | 13188 | '``llvm.canonicalize.*``' Intrinsic | ||

13129 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 13189 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||

13130 | 13190 | | |||

13131 | Syntax: | 13191 | Syntax: | ||

13132 | """"""" | 13192 | """"""" | ||

▲ Show 20 Lines • Show All 3558 Lines • Show Last 20 Lines |