forked from OSchip/llvm-project
[spirv] Add SPIR-V GLSL extended Round op
Reviewed By: mravishankar, antiagainst Differential Revision: https://reviews.llvm.org/D86914
This commit is contained in:
parent
91848b11b4
commit
1e21ca4d25
|
@ -430,6 +430,36 @@ def SPV_GLSLFloorOp : SPV_GLSLUnaryArithmeticOp<"Floor", 8, SPV_Float> {
|
|||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLRoundOp: SPV_GLSLUnaryArithmeticOp<"Round", 1, SPV_Float> {
|
||||
let summary = "Rounds to the whole number";
|
||||
|
||||
let description = [{
|
||||
Result is the value equal to the nearest whole number.
|
||||
|
||||
The operand x must be a scalar or vector whose component type is
|
||||
floating-point.
|
||||
|
||||
Result Type and the type of x must be the same type. Results are computed
|
||||
per component.
|
||||
|
||||
<!-- End of AutoGen section -->
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
floor-op ::= ssa-id `=` `spv.GLSL.Round` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.GLSL.Round %0 : f32
|
||||
%3 = spv.GLSL.Round %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLInverseSqrtOp : SPV_GLSLUnaryArithmeticOp<"InverseSqrt", 32, SPV_Float> {
|
||||
let summary = "Reciprocal of sqrt(operand)";
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
|
|||
%10 = spv.GLSL.Cosh %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Pow {{%.*}} : f32
|
||||
%11 = spv.GLSL.Pow %arg0, %arg1 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Round {{%.*}} : f32
|
||||
%12 = spv.GLSL.Round %arg0 : f32
|
||||
spv.Return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,3 +254,18 @@ func @powvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) -> () {
|
|||
|
||||
// -----
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.GLSL.Round
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func @round(%arg0 : f32) -> () {
|
||||
// CHECK: spv.GLSL.Round {{%.*}} : f32
|
||||
%2 = spv.GLSL.Round %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func @roundvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.GLSL.Round {{%.*}} : vector<3xf16>
|
||||
%2 = spv.GLSL.Round %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue