Description
- Implement
mul
clang builtin,Linkmul
clang builtin withhlsl_intrinsics.h
Add sema checks formul
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
Add codegen formul
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
Add codegen tests toclang/test/CodeGenHLSL/builtins/mul.hlsl
Add sema tests toclang/test/SemaHLSL/BuiltIns/mul-errors.hlsl
Create theint_spv_mul
intrinsic inIntrinsicsSPIRV.td
In SPIRVInstructionSelector.cpp create themul
lowering and map it toint_spv_mul
inSPIRVInstructionSelector::selectIntrinsic
.Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/hlsl-intrinsics/mul.ll
DirectX
There were no DXIL opcodes found for mul
.
SPIR-V
OpFMul:
Description:
Floating-point multiplication of Operand 1 and Operand 2.
Result Type must be a scalar or vector of floating-point
type.
The types of Operand 1 and Operand 2 both must be the same as
Result Type.
Results are computed per component.
Word Count | Opcode | Results | Operands | ||
---|---|---|---|---|---|
5 |
133 |
<id> |
<id> |
<id> |
Test Case(s)
Example 1
//dxc mul_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float fn(float p1, float p2) {
return mul(p1, p2);
}
Example 2
//dxc mul_1_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint fn(uint p1, uint p2) {
return mul(p1, p2);
}
Example 3
//dxc mul_2_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int fn(int p1, int p2) {
return mul(p1, p2);
}
Example 4
//dxc mul_3_test.hlsl -T lib_6_8 -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0
export float4 fn(float4 p1, float p2) {
return mul(p1, p2);
}
Example 5
//dxc mul_4_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float p1, float4 p2) {
return mul(p1, p2);
}
Example 6
//dxc mul_5_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(uint p1, uint4 p2) {
return mul(p1, p2);
}
Example 7
//dxc mul_6_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4 fn(int p1, int4 p2) {
return mul(p1, p2);
}
Example 8
//dxc mul_7_test.hlsl -T lib_6_8 -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0
export float4 fn(float4x4 p1, float4 p2) {
return mul(p1, p2);
}
Example 9
//dxc mul_8_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4x4 fn(float p1, float4x4 p2) {
return mul(p1, p2);
}
Example 10
//dxc mul_9_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4x4 fn(uint p1, uint4x4 p2) {
return mul(p1, p2);
}
Example 11
//dxc mul_10_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4x4 fn(int p1, int4x4 p2) {
return mul(p1, p2);
}
Example 12
//dxc mul_12_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1, float p2) {
return mul(p1, p2);
}
Example 13
//dxc mul_13_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(uint4 p1, uint p2) {
return mul(p1, p2);
}
Example 14
//dxc mul_14_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4 fn(int4 p1, int p2) {
return mul(p1, p2);
}
Example 15
//dxc mul_16_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float fn(float4 p1, float4 p2) {
return mul(p1, p2);
}
Example 16
//dxc mul_17_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint fn(uint4 p1, uint4 p2) {
return mul(p1, p2);
}
Example 17
//dxc mul_18_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int fn(int4 p1, int4 p2) {
return mul(p1, p2);
}
Example 18
//dxc mul_20_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4 p1, float4x4 p2) {
return mul(p1, p2);
}
Example 19
//dxc mul_21_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(uint4 p1, uint4x4 p2) {
return mul(p1, p2);
}
Example 20
//dxc mul_22_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4 fn(int4 p1, int4x4 p2) {
return mul(p1, p2);
}
Example 21
//dxc mul_24_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4x4 fn(float4x4 p1, float p2) {
return mul(p1, p2);
}
Example 22
//dxc mul_25_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4x4 fn(uint4x4 p1, uint p2) {
return mul(p1, p2);
}
Example 23
//dxc mul_26_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4x4 fn(int4x4 p1, int p2) {
return mul(p1, p2);
}
Example 24
//dxc mul_28_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4 fn(float4x4 p1, float4 p2) {
return mul(p1, p2);
}
Example 25
//dxc mul_29_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(uint4x4 p1, uint4 p2) {
return mul(p1, p2);
}
Example 26
//dxc mul_30_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4 fn(int4x4 p1, int4 p2) {
return mul(p1, p2);
}
Example 27
//dxc mul_32_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export float4x4 fn(float4x4 p1, float4x4 p2) {
return mul(p1, p2);
}
Example 28
//dxc mul_33_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4x4 fn(uint4x4 p1, uint4x4 p2) {
return mul(p1, p2);
}
Example 29
//dxc mul_34_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export int4x4 fn(int4x4 p1, int4x4 p2) {
return mul(p1, p2);
}
HLSL:
Multiplies x and y using matrix math. The inner dimension x-columns and y-rows must be equal.
ret mul(x, y) |
---|
Parameters
Item | Description |
---|---|
x |
[in] The x input value. If x is a vector, it treated as a row vector. |
y |
[in] The y input value. If y is a vector, it treated as a column vector. |
Return Value
The result of x times y. The result has the dimension x-rows x y-columns.
Type Description
There are 9 overloaded versions of this function; the overloaded versions handle the different cases for the types and sizes of the input arguments.
Version | Name | Purpose | Template Type | Component Type | Size |
---|---|---|---|---|---|
1 | |||||
x | in | scalar | float, int | 1 | |
y | in | scalar | same as input x | 1 | |
ret | out | scalar | same as input x | 1 | |
2 | |||||
x | in | scalar | float, int | 1 | |
y | in | vector | float, int | any | |
ret | out | vector | float, int | same dimension(s) as input y | |
3 | |||||
x | in | scalar | float, int | 1 | |
y | in | matrix | float, int | any | |
ret | out | matrix | same as input y | same dimension(s) as input y | |
4 | |||||
x | in | vector | float, int | any | |
y | in | scalar | float, int | 1 | |
ret | out | vector | float, int | same dimension(s) as input x | |
5 | |||||
x | in | vector | float, int | any | |
y | in | vector | float, int | same dimension(s) as input x | |
ret | out | scalar | float, int | 1 | |
6 | |||||
x | in | vector | float, int | any | |
y | in | matrix | float, int | rows = same dimension(s) as input x, columns = any | |
ret | out | vector | float, int | same dimension(s) as input y columns | |
7 | |||||
x | in | matrix | float, int | any | |
y | in | scalar | float, int | 1 | |
ret | out | matrix | float, int | same dimension(s) as input x | |
8 | |||||
x | in | matrix | float, int | any | |
y | in | vector | float, int | number of columns in input x | |
ret | out | vector | float, int | number of rows in input x | |
9 | |||||
x | in | matrix | float, int | any | |
y | in | matrix | float, int | rows = number of columns in input x | |
ret | out | matrix | float, int | rows = number of rows in input x, columns = number of columns in input y |
Minimum Shader Model
This function is supported in the following shader models.
Shader Model | Supported |
---|---|
Shader Model 1 (DirectX HLSL) and higher shader models | yes |
See also
Metadata
Metadata
Assignees
Type
Projects
Status
No status
Milestone
Relationships
Development
No branches or pull requests
Activity
pow2clk commentedon Nov 19, 2024
Depends on matrix support. #109839 at least. Some complication is that the existing matrix extension performs matrix multiply with the
*
operator while HLSL uses that for elementwise multiplication