mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-24 17:06:07 +00:00
[mlir][spirv] Rename spv.ocl to spv.cl. NFC.
This is to improve the consistency within the SPIR-V dialect and to make op names a bit shorter. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D130194
This commit is contained in:
parent
0c1b32717b
commit
3930cc6847
@ -622,7 +622,7 @@ There is no support of the following ops:
|
||||
* All atomic ops
|
||||
* All group ops
|
||||
* All matrix ops
|
||||
* All OCL ops
|
||||
* All CL ops
|
||||
|
||||
As well as:
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- SPIRVOCLOps.td - OpenCL extended insts spec file ----*- tablegen -*-===//
|
||||
//===- SPIRVCLOps.td - OpenCL extended insts spec file ----*- tablegen -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
@ -10,8 +10,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_DIALECT_SPIRV_IR_OCL_OPS
|
||||
#define MLIR_DIALECT_SPIRV_IR_OCL_OPS
|
||||
#ifndef MLIR_DIALECT_SPIRV_IR_CL_OPS
|
||||
#define MLIR_DIALECT_SPIRV_IR_CL_OPS
|
||||
|
||||
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
|
||||
|
||||
@ -20,8 +20,8 @@ include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Base class for all OpenCL ops.
|
||||
class SPV_OCLOp<string mnemonic, int opcode, list<Trait> traits = []> :
|
||||
SPV_ExtInstOp<mnemonic, "OCL", "OpenCL.std", opcode, traits> {
|
||||
class SPV_CLOp<string mnemonic, int opcode, list<Trait> traits = []> :
|
||||
SPV_ExtInstOp<mnemonic, "CL", "OpenCL.std", opcode, traits> {
|
||||
|
||||
let availability = [
|
||||
MinVersion<SPV_V_1_0>,
|
||||
@ -32,9 +32,9 @@ class SPV_OCLOp<string mnemonic, int opcode, list<Trait> traits = []> :
|
||||
}
|
||||
|
||||
// Base class for OpenCL unary ops.
|
||||
class SPV_OCLUnaryOp<string mnemonic, int opcode, Type resultType,
|
||||
class SPV_CLUnaryOp<string mnemonic, int opcode, Type resultType,
|
||||
Type operandType, list<Trait> traits = []> :
|
||||
SPV_OCLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
|
||||
SPV_CLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
|
||||
|
||||
let arguments = (ins
|
||||
SPV_ScalarOrVectorOf<operandType>:$operand
|
||||
@ -51,15 +51,15 @@ class SPV_OCLUnaryOp<string mnemonic, int opcode, Type resultType,
|
||||
|
||||
// Base class for OpenCL Unary arithmetic ops where return type matches
|
||||
// the operand type.
|
||||
class SPV_OCLUnaryArithmeticOp<string mnemonic, int opcode, Type type,
|
||||
class SPV_CLUnaryArithmeticOp<string mnemonic, int opcode, Type type,
|
||||
list<Trait> traits = []> :
|
||||
SPV_OCLUnaryOp<mnemonic, opcode, type, type,
|
||||
SPV_CLUnaryOp<mnemonic, opcode, type, type,
|
||||
traits # [SameOperandsAndResultType]>;
|
||||
|
||||
// Base class for OpenCL binary ops.
|
||||
class SPV_OCLBinaryOp<string mnemonic, int opcode, Type resultType,
|
||||
class SPV_CLBinaryOp<string mnemonic, int opcode, Type resultType,
|
||||
Type operandType, list<Trait> traits = []> :
|
||||
SPV_OCLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
|
||||
SPV_CLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
|
||||
|
||||
let arguments = (ins
|
||||
SPV_ScalarOrVectorOf<operandType>:$lhs,
|
||||
@ -75,17 +75,17 @@ class SPV_OCLBinaryOp<string mnemonic, int opcode, Type resultType,
|
||||
|
||||
// Base class for OpenCL Binary arithmetic ops where operand types and
|
||||
// return type matches.
|
||||
class SPV_OCLBinaryArithmeticOp<string mnemonic, int opcode, Type type,
|
||||
class SPV_CLBinaryArithmeticOp<string mnemonic, int opcode, Type type,
|
||||
list<Trait> traits = []> :
|
||||
SPV_OCLBinaryOp<mnemonic, opcode, type, type,
|
||||
traits # [SameOperandsAndResultType]> {
|
||||
SPV_CLBinaryOp<mnemonic, opcode, type, type,
|
||||
traits # [SameOperandsAndResultType]> {
|
||||
let assemblyFormat = "operands attr-dict `:` type($result)";
|
||||
}
|
||||
|
||||
// Base class for OpenCL binary ops.
|
||||
class SPV_OCLTernaryOp<string mnemonic, int opcode, Type resultType,
|
||||
class SPV_CLTernaryOp<string mnemonic, int opcode, Type resultType,
|
||||
Type operandType, list<Trait> traits = []> :
|
||||
SPV_OCLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
|
||||
SPV_CLOp<mnemonic, opcode, !listconcat([NoSideEffect], traits)> {
|
||||
|
||||
let arguments = (ins
|
||||
SPV_ScalarOrVectorOf<operandType>:$x,
|
||||
@ -102,9 +102,9 @@ class SPV_OCLTernaryOp<string mnemonic, int opcode, Type resultType,
|
||||
|
||||
// Base class for OpenCL Ternary arithmetic ops where operand types and
|
||||
// return type matches.
|
||||
class SPV_OCLTernaryArithmeticOp<string mnemonic, int opcode, Type type,
|
||||
class SPV_CLTernaryArithmeticOp<string mnemonic, int opcode, Type type,
|
||||
list<Trait> traits = []> :
|
||||
SPV_OCLTernaryOp<mnemonic, opcode, type, type,
|
||||
SPV_CLTernaryOp<mnemonic, opcode, type, type,
|
||||
traits # [SameOperandsAndResultType]> {
|
||||
let assemblyFormat = "operands attr-dict `:` type($result)";
|
||||
}
|
||||
@ -113,7 +113,7 @@ class SPV_OCLTernaryArithmeticOp<string mnemonic, int opcode, Type type,
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLCeilOp : SPV_OCLUnaryArithmeticOp<"ceil", 12, SPV_Float> {
|
||||
def SPV_CLCeilOp : SPV_CLUnaryArithmeticOp<"ceil", 12, SPV_Float> {
|
||||
let summary = [{
|
||||
Round x to integral value using the round to positive infinity rounding
|
||||
mode.
|
||||
@ -131,22 +131,22 @@ def SPV_OCLCeilOp : SPV_OCLUnaryArithmeticOp<"ceil", 12, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
ceil-op ::= ssa-id `=` `spv.OCL.ceil` ssa-use `:`
|
||||
ceil-op ::= ssa-id `=` `spv.CL.ceil` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.ceil %0 : f32
|
||||
%3 = spv.OCL.ceil %1 : vector<3xf16>
|
||||
%2 = spv.CL.ceil %0 : f32
|
||||
%3 = spv.CL.ceil %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLCosOp : SPV_OCLUnaryArithmeticOp<"cos", 14, SPV_Float> {
|
||||
def SPV_CLCosOp : SPV_CLUnaryArithmeticOp<"cos", 14, SPV_Float> {
|
||||
let summary = "Compute the cosine of x radians.";
|
||||
|
||||
let description = [{
|
||||
@ -161,22 +161,22 @@ def SPV_OCLCosOp : SPV_OCLUnaryArithmeticOp<"cos", 14, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
cos-op ::= ssa-id `=` `spv.OCL.cos` ssa-use `:`
|
||||
cos-op ::= ssa-id `=` `spv.CL.cos` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.cos %0 : f32
|
||||
%3 = spv.OCL.cos %1 : vector<3xf16>
|
||||
%2 = spv.CL.cos %0 : f32
|
||||
%3 = spv.CL.cos %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLErfOp : SPV_OCLUnaryArithmeticOp<"erf", 18, SPV_Float> {
|
||||
def SPV_CLErfOp : SPV_CLUnaryArithmeticOp<"erf", 18, SPV_Float> {
|
||||
let summary = [{
|
||||
Error function of x encountered in integrating the normal distribution.
|
||||
}];
|
||||
@ -193,22 +193,22 @@ def SPV_OCLErfOp : SPV_OCLUnaryArithmeticOp<"erf", 18, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
erf-op ::= ssa-id `=` `spv.OCL.erf` ssa-use `:`
|
||||
erf-op ::= ssa-id `=` `spv.CL.erf` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.erf %0 : f32
|
||||
%3 = spv.OCL.erf %1 : vector<3xf16>
|
||||
%2 = spv.CL.erf %0 : f32
|
||||
%3 = spv.CL.erf %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLExpOp : SPV_OCLUnaryArithmeticOp<"exp", 19, SPV_Float> {
|
||||
def SPV_CLExpOp : SPV_CLUnaryArithmeticOp<"exp", 19, SPV_Float> {
|
||||
let summary = "Exponentiation of Operand 1";
|
||||
|
||||
let description = [{
|
||||
@ -224,21 +224,21 @@ def SPV_OCLExpOp : SPV_OCLUnaryArithmeticOp<"exp", 19, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
exp-op ::= ssa-id `=` `spv.OCL.exp` ssa-use `:`
|
||||
exp-op ::= ssa-id `=` `spv.CL.exp` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.OCL.exp %0 : f32
|
||||
%3 = spv.OCL.exp %1 : vector<3xf16>
|
||||
%2 = spv.CL.exp %0 : f32
|
||||
%3 = spv.CL.exp %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLFAbsOp : SPV_OCLUnaryArithmeticOp<"fabs", 23, SPV_Float> {
|
||||
def SPV_CLFAbsOp : SPV_CLUnaryArithmeticOp<"fabs", 23, SPV_Float> {
|
||||
let summary = "Absolute value of operand";
|
||||
|
||||
let description = [{
|
||||
@ -254,21 +254,21 @@ def SPV_OCLFAbsOp : SPV_OCLUnaryArithmeticOp<"fabs", 23, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
abs-op ::= ssa-id `=` `spv.OCL.fabs` ssa-use `:`
|
||||
abs-op ::= ssa-id `=` `spv.CL.fabs` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.OCL.fabs %0 : f32
|
||||
%3 = spv.OCL.fabs %1 : vector<3xf16>
|
||||
%2 = spv.CL.fabs %0 : f32
|
||||
%3 = spv.CL.fabs %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLFloorOp : SPV_OCLUnaryArithmeticOp<"floor", 25, SPV_Float> {
|
||||
def SPV_CLFloorOp : SPV_CLUnaryArithmeticOp<"floor", 25, SPV_Float> {
|
||||
let summary = [{
|
||||
Round x to the integral value using the round to negative infinity
|
||||
rounding mode.
|
||||
@ -286,22 +286,22 @@ def SPV_OCLFloorOp : SPV_OCLUnaryArithmeticOp<"floor", 25, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
floor-op ::= ssa-id `=` `spv.OCL.floor` ssa-use `:`
|
||||
floor-op ::= ssa-id `=` `spv.CL.floor` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.floor %0 : f32
|
||||
%3 = spv.OCL.ceifloorl %1 : vector<3xf16>
|
||||
%2 = spv.CL.floor %0 : f32
|
||||
%3 = spv.CL.ceifloorl %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLFmaOp : SPV_OCLTernaryArithmeticOp<"fma", 26, SPV_Float> {
|
||||
def SPV_CLFmaOp : SPV_CLTernaryArithmeticOp<"fma", 26, SPV_Float> {
|
||||
let summary = [{
|
||||
Compute the correctly rounded floating-point representation of the sum
|
||||
of c with the infinitely precise product of a and b. Rounding of
|
||||
@ -319,20 +319,20 @@ def SPV_OCLFmaOp : SPV_OCLTernaryArithmeticOp<"fma", 26, SPV_Float> {
|
||||
<!-- End of AutoGen section -->
|
||||
|
||||
```
|
||||
fma-op ::= ssa-id `=` `spv.OCL.fma` ssa-use, ssa-use, ssa-use `:`
|
||||
fma-op ::= ssa-id `=` `spv.CL.fma` ssa-use, ssa-use, ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
```
|
||||
%0 = spv.OCL.fma %a, %b, %c : f32
|
||||
%1 = spv.OCL.fma %a, %b, %c : vector<3xf16>
|
||||
%0 = spv.CL.fma %a, %b, %c : f32
|
||||
%1 = spv.CL.fma %a, %b, %c : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLLogOp : SPV_OCLUnaryArithmeticOp<"log", 37, SPV_Float> {
|
||||
def SPV_CLLogOp : SPV_CLUnaryArithmeticOp<"log", 37, SPV_Float> {
|
||||
let summary = "Compute the natural logarithm of x.";
|
||||
|
||||
let description = [{
|
||||
@ -347,22 +347,22 @@ def SPV_OCLLogOp : SPV_OCLUnaryArithmeticOp<"log", 37, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
log-op ::= ssa-id `=` `spv.OCL.log` ssa-use `:`
|
||||
log-op ::= ssa-id `=` `spv.CL.log` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.log %0 : f32
|
||||
%3 = spv.OCL.log %1 : vector<3xf16>
|
||||
%2 = spv.CL.log %0 : f32
|
||||
%3 = spv.CL.log %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLPowOp : SPV_OCLBinaryArithmeticOp<"pow", 48, SPV_Float> {
|
||||
def SPV_CLPowOp : SPV_CLBinaryArithmeticOp<"pow", 48, SPV_Float> {
|
||||
let summary = "Compute x to the power y.";
|
||||
|
||||
let description = [{
|
||||
@ -379,21 +379,21 @@ def SPV_OCLPowOp : SPV_OCLBinaryArithmeticOp<"pow", 48, SPV_Float> {
|
||||
restricted-float-scalar-vector-type ::=
|
||||
restricted-float-scalar-type |
|
||||
`vector<` integer-literal `x` restricted-float-scalar-type `>`
|
||||
pow-op ::= ssa-id `=` `spv.OCL.pow` ssa-use `:`
|
||||
pow-op ::= ssa-id `=` `spv.CL.pow` ssa-use `:`
|
||||
restricted-float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.OCL.pow %0, %1 : f32
|
||||
%3 = spv.OCL.pow %0, %1 : vector<3xf16>
|
||||
%2 = spv.CL.pow %0, %1 : f32
|
||||
%3 = spv.CL.pow %0, %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLRoundOp : SPV_OCLUnaryArithmeticOp<"round", 55, SPV_Float> {
|
||||
def SPV_CLRoundOp : SPV_CLUnaryArithmeticOp<"round", 55, SPV_Float> {
|
||||
let summary = [{
|
||||
Return the integral value nearest to x rounding halfway cases away from
|
||||
zero, regardless of the current rounding direction.
|
||||
@ -411,21 +411,21 @@ def SPV_OCLRoundOp : SPV_OCLUnaryArithmeticOp<"round", 55, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
round-op ::= ssa-id `=` `spv.OCL.round` ssa-use `:`
|
||||
round-op ::= ssa-id `=` `spv.CL.round` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.OCL.round %0 : f32
|
||||
%3 = spv.OCL.round %0 : vector<3xf16>
|
||||
%2 = spv.CL.round %0 : f32
|
||||
%3 = spv.CL.round %0 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLRsqrtOp : SPV_OCLUnaryArithmeticOp<"rsqrt", 56, SPV_Float> {
|
||||
def SPV_CLRsqrtOp : SPV_CLUnaryArithmeticOp<"rsqrt", 56, SPV_Float> {
|
||||
let summary = "Compute inverse square root of x.";
|
||||
|
||||
let description = [{
|
||||
@ -440,22 +440,22 @@ def SPV_OCLRsqrtOp : SPV_OCLUnaryArithmeticOp<"rsqrt", 56, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
rsqrt-op ::= ssa-id `=` `spv.OCL.rsqrt` ssa-use `:`
|
||||
rsqrt-op ::= ssa-id `=` `spv.CL.rsqrt` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.rsqrt %0 : f32
|
||||
%3 = spv.OCL.rsqrt %1 : vector<3xf16>
|
||||
%2 = spv.CL.rsqrt %0 : f32
|
||||
%3 = spv.CL.rsqrt %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLSinOp : SPV_OCLUnaryArithmeticOp<"sin", 57, SPV_Float> {
|
||||
def SPV_CLSinOp : SPV_CLUnaryArithmeticOp<"sin", 57, SPV_Float> {
|
||||
let summary = "Compute sine of x radians.";
|
||||
|
||||
let description = [{
|
||||
@ -470,22 +470,22 @@ def SPV_OCLSinOp : SPV_OCLUnaryArithmeticOp<"sin", 57, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
sin-op ::= ssa-id `=` `spv.OCL.sin` ssa-use `:`
|
||||
sin-op ::= ssa-id `=` `spv.CL.sin` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.sin %0 : f32
|
||||
%3 = spv.OCL.sin %1 : vector<3xf16>
|
||||
%2 = spv.CL.sin %0 : f32
|
||||
%3 = spv.CL.sin %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLSqrtOp : SPV_OCLUnaryArithmeticOp<"sqrt", 61, SPV_Float> {
|
||||
def SPV_CLSqrtOp : SPV_CLUnaryArithmeticOp<"sqrt", 61, SPV_Float> {
|
||||
let summary = "Compute square root of x.";
|
||||
|
||||
let description = [{
|
||||
@ -500,22 +500,22 @@ def SPV_OCLSqrtOp : SPV_OCLUnaryArithmeticOp<"sqrt", 61, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
sqrt-op ::= ssa-id `=` `spv.OCL.sqrt` ssa-use `:`
|
||||
sqrt-op ::= ssa-id `=` `spv.CL.sqrt` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.sqrt %0 : f32
|
||||
%3 = spv.OCL.sqrt %1 : vector<3xf16>
|
||||
%2 = spv.CL.sqrt %0 : f32
|
||||
%3 = spv.CL.sqrt %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLTanhOp : SPV_OCLUnaryArithmeticOp<"tanh", 63, SPV_Float> {
|
||||
def SPV_CLTanhOp : SPV_CLUnaryArithmeticOp<"tanh", 63, SPV_Float> {
|
||||
let summary = "Compute hyperbolic tangent of x radians.";
|
||||
|
||||
let description = [{
|
||||
@ -530,22 +530,22 @@ def SPV_OCLTanhOp : SPV_OCLUnaryArithmeticOp<"tanh", 63, SPV_Float> {
|
||||
```
|
||||
float-scalar-vector-type ::= float-type |
|
||||
`vector<` integer-literal `x` float-type `>`
|
||||
tanh-op ::= ssa-id `=` `spv.OCL.tanh` ssa-use `:`
|
||||
tanh-op ::= ssa-id `=` `spv.CL.tanh` ssa-use `:`
|
||||
float-scalar-vector-type
|
||||
```mlir
|
||||
|
||||
#### Example:
|
||||
|
||||
```
|
||||
%2 = spv.OCL.tanh %0 : f32
|
||||
%3 = spv.OCL.tanh %1 : vector<3xf16>
|
||||
%2 = spv.CL.tanh %0 : f32
|
||||
%3 = spv.CL.tanh %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_OCLSAbsOp : SPV_OCLUnaryArithmeticOp<"s_abs", 141, SPV_Integer> {
|
||||
def SPV_CLSAbsOp : SPV_CLUnaryArithmeticOp<"s_abs", 141, SPV_Integer> {
|
||||
let summary = "Absolute value of operand";
|
||||
|
||||
let description = [{
|
||||
@ -561,16 +561,16 @@ def SPV_OCLSAbsOp : SPV_OCLUnaryArithmeticOp<"s_abs", 141, SPV_Integer> {
|
||||
```
|
||||
integer-scalar-vector-type ::= integer-type |
|
||||
`vector<` integer-literal `x` integer-type `>`
|
||||
abs-op ::= ssa-id `=` `spv.OCL.s_abs` ssa-use `:`
|
||||
abs-op ::= ssa-id `=` `spv.CL.s_abs` ssa-use `:`
|
||||
integer-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.OCL.s_abs %0 : i32
|
||||
%3 = spv.OCL.s_abs %1 : vector<3xi16>
|
||||
%2 = spv.CL.s_abs %0 : i32
|
||||
%3 = spv.CL.s_abs %1 : vector<3xi16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
#endif // MLIR_DIALECT_SPIRV_IR_OCL_OPS
|
||||
#endif // MLIR_DIALECT_SPIRV_IR_CL_OPS
|
@ -38,7 +38,7 @@ include "mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td"
|
||||
include "mlir/Dialect/SPIRV/IR/SPIRVMemoryOps.td"
|
||||
include "mlir/Dialect/SPIRV/IR/SPIRVMiscOps.td"
|
||||
include "mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td"
|
||||
include "mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td"
|
||||
include "mlir/Dialect/SPIRV/IR/SPIRVCLOps.td"
|
||||
include "mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td"
|
||||
include "mlir/Interfaces/SideEffectInterfaces.td"
|
||||
|
||||
|
@ -60,7 +60,7 @@ struct RemSIOpGLSLPattern final : public OpConversionPattern<arith::RemSIOp> {
|
||||
};
|
||||
|
||||
/// Converts arith.remsi to OpenCL SPIR-V ops.
|
||||
struct RemSIOpOCLPattern final : public OpConversionPattern<arith::RemSIOp> {
|
||||
struct RemSIOpCLPattern final : public OpConversionPattern<arith::RemSIOp> {
|
||||
using OpConversionPattern<arith::RemSIOp>::OpConversionPattern;
|
||||
|
||||
LogicalResult
|
||||
@ -487,13 +487,13 @@ RemSIOpGLSLPattern::matchAndRewrite(arith::RemSIOp op, OpAdaptor adaptor,
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// RemSIOpOCLPattern
|
||||
// RemSIOpCLPattern
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
LogicalResult
|
||||
RemSIOpOCLPattern::matchAndRewrite(arith::RemSIOp op, OpAdaptor adaptor,
|
||||
ConversionPatternRewriter &rewriter) const {
|
||||
Value result = emulateSignedRemainder<spirv::OCLSAbsOp>(
|
||||
RemSIOpCLPattern::matchAndRewrite(arith::RemSIOp op, OpAdaptor adaptor,
|
||||
ConversionPatternRewriter &rewriter) const {
|
||||
Value result = emulateSignedRemainder<spirv::CLSAbsOp>(
|
||||
op.getLoc(), adaptor.getOperands()[0], adaptor.getOperands()[1],
|
||||
adaptor.getOperands()[0], rewriter);
|
||||
rewriter.replaceOp(op, result);
|
||||
@ -862,7 +862,7 @@ void mlir::arith::populateArithmeticToSPIRVPatterns(
|
||||
spirv::ElementwiseOpPattern<arith::DivUIOp, spirv::UDivOp>,
|
||||
spirv::ElementwiseOpPattern<arith::DivSIOp, spirv::SDivOp>,
|
||||
spirv::ElementwiseOpPattern<arith::RemUIOp, spirv::UModOp>,
|
||||
RemSIOpGLSLPattern, RemSIOpOCLPattern,
|
||||
RemSIOpGLSLPattern, RemSIOpCLPattern,
|
||||
BitwiseOpPattern<arith::AndIOp, spirv::LogicalAndOp, spirv::BitwiseAndOp>,
|
||||
BitwiseOpPattern<arith::OrIOp, spirv::LogicalOrOp, spirv::BitwiseOrOp>,
|
||||
XOrIOpLogicalPattern, XOrIOpBooleanPattern,
|
||||
|
@ -301,21 +301,21 @@ void populateMathToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
|
||||
typeConverter, patterns.getContext());
|
||||
|
||||
// OpenCL patterns
|
||||
patterns.add<Log1pOpPattern<spirv::OCLLogOp>, ExpM1OpPattern<spirv::OCLExpOp>,
|
||||
spirv::ElementwiseOpPattern<math::AbsOp, spirv::OCLFAbsOp>,
|
||||
spirv::ElementwiseOpPattern<math::CeilOp, spirv::OCLCeilOp>,
|
||||
spirv::ElementwiseOpPattern<math::CosOp, spirv::OCLCosOp>,
|
||||
spirv::ElementwiseOpPattern<math::ErfOp, spirv::OCLErfOp>,
|
||||
spirv::ElementwiseOpPattern<math::ExpOp, spirv::OCLExpOp>,
|
||||
spirv::ElementwiseOpPattern<math::FloorOp, spirv::OCLFloorOp>,
|
||||
spirv::ElementwiseOpPattern<math::FmaOp, spirv::OCLFmaOp>,
|
||||
spirv::ElementwiseOpPattern<math::LogOp, spirv::OCLLogOp>,
|
||||
spirv::ElementwiseOpPattern<math::PowFOp, spirv::OCLPowOp>,
|
||||
spirv::ElementwiseOpPattern<math::RoundOp, spirv::OCLRoundOp>,
|
||||
spirv::ElementwiseOpPattern<math::RsqrtOp, spirv::OCLRsqrtOp>,
|
||||
spirv::ElementwiseOpPattern<math::SinOp, spirv::OCLSinOp>,
|
||||
spirv::ElementwiseOpPattern<math::SqrtOp, spirv::OCLSqrtOp>,
|
||||
spirv::ElementwiseOpPattern<math::TanhOp, spirv::OCLTanhOp>>(
|
||||
patterns.add<Log1pOpPattern<spirv::CLLogOp>, ExpM1OpPattern<spirv::CLExpOp>,
|
||||
spirv::ElementwiseOpPattern<math::AbsOp, spirv::CLFAbsOp>,
|
||||
spirv::ElementwiseOpPattern<math::CeilOp, spirv::CLCeilOp>,
|
||||
spirv::ElementwiseOpPattern<math::CosOp, spirv::CLCosOp>,
|
||||
spirv::ElementwiseOpPattern<math::ErfOp, spirv::CLErfOp>,
|
||||
spirv::ElementwiseOpPattern<math::ExpOp, spirv::CLExpOp>,
|
||||
spirv::ElementwiseOpPattern<math::FloorOp, spirv::CLFloorOp>,
|
||||
spirv::ElementwiseOpPattern<math::FmaOp, spirv::CLFmaOp>,
|
||||
spirv::ElementwiseOpPattern<math::LogOp, spirv::CLLogOp>,
|
||||
spirv::ElementwiseOpPattern<math::PowFOp, spirv::CLPowOp>,
|
||||
spirv::ElementwiseOpPattern<math::RoundOp, spirv::CLRoundOp>,
|
||||
spirv::ElementwiseOpPattern<math::RsqrtOp, spirv::CLRsqrtOp>,
|
||||
spirv::ElementwiseOpPattern<math::SinOp, spirv::CLSinOp>,
|
||||
spirv::ElementwiseOpPattern<math::SqrtOp, spirv::CLSqrtOp>,
|
||||
spirv::ElementwiseOpPattern<math::TanhOp, spirv::CLTanhOp>>(
|
||||
typeConverter, patterns.getContext());
|
||||
}
|
||||
|
||||
|
@ -952,8 +952,8 @@ module attributes {
|
||||
// CHECK-LABEL: @scalar_srem
|
||||
// CHECK-SAME: (%[[LHS:.+]]: i32, %[[RHS:.+]]: i32)
|
||||
func.func @scalar_srem(%lhs: i32, %rhs: i32) {
|
||||
// CHECK: %[[LABS:.+]] = spv.OCL.s_abs %[[LHS]] : i32
|
||||
// CHECK: %[[RABS:.+]] = spv.OCL.s_abs %[[RHS]] : i32
|
||||
// CHECK: %[[LABS:.+]] = spv.CL.s_abs %[[LHS]] : i32
|
||||
// CHECK: %[[RABS:.+]] = spv.CL.s_abs %[[RHS]] : i32
|
||||
// CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : i32
|
||||
// CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : i32
|
||||
// CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : i32
|
||||
@ -965,8 +965,8 @@ func.func @scalar_srem(%lhs: i32, %rhs: i32) {
|
||||
// CHECK-LABEL: @vector_srem
|
||||
// CHECK-SAME: (%[[LHS:.+]]: vector<3xi16>, %[[RHS:.+]]: vector<3xi16>)
|
||||
func.func @vector_srem(%arg0: vector<3xi16>, %arg1: vector<3xi16>) {
|
||||
// CHECK: %[[LABS:.+]] = spv.OCL.s_abs %[[LHS]] : vector<3xi16>
|
||||
// CHECK: %[[RABS:.+]] = spv.OCL.s_abs %[[RHS]] : vector<3xi16>
|
||||
// CHECK: %[[LABS:.+]] = spv.CL.s_abs %[[LHS]] : vector<3xi16>
|
||||
// CHECK: %[[RABS:.+]] = spv.CL.s_abs %[[RHS]] : vector<3xi16>
|
||||
// CHECK: %[[ABS:.+]] = spv.UMod %[[LABS]], %[[RABS]] : vector<3xi16>
|
||||
// CHECK: %[[POS:.+]] = spv.IEqual %[[LHS]], %[[LABS]] : vector<3xi16>
|
||||
// CHECK: %[[NEG:.+]] = spv.SNegate %[[ABS]] : vector<3xi16>
|
||||
|
@ -4,85 +4,85 @@ module attributes { spv.target_env = #spv.target_env<#spv.vce<v1.0, [Kernel], []
|
||||
|
||||
// CHECK-LABEL: @float32_unary_scalar
|
||||
func.func @float32_unary_scalar(%arg0: f32) {
|
||||
// CHECK: spv.OCL.cos %{{.*}}: f32
|
||||
// CHECK: spv.CL.cos %{{.*}}: f32
|
||||
%0 = math.cos %arg0 : f32
|
||||
// CHECK: spv.OCL.exp %{{.*}}: f32
|
||||
// CHECK: spv.CL.exp %{{.*}}: f32
|
||||
%1 = math.exp %arg0 : f32
|
||||
// CHECK: %[[EXP:.+]] = spv.OCL.exp %arg0
|
||||
// CHECK: %[[EXP:.+]] = spv.CL.exp %arg0
|
||||
// CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32
|
||||
// CHECK: spv.FSub %[[EXP]], %[[ONE]]
|
||||
%2 = math.expm1 %arg0 : f32
|
||||
// CHECK: spv.OCL.log %{{.*}}: f32
|
||||
// CHECK: spv.CL.log %{{.*}}: f32
|
||||
%3 = math.log %arg0 : f32
|
||||
// CHECK: %[[ONE:.+]] = spv.Constant 1.000000e+00 : f32
|
||||
// CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}}
|
||||
// CHECK: spv.OCL.log %[[ADDONE]]
|
||||
// CHECK: spv.CL.log %[[ADDONE]]
|
||||
%4 = math.log1p %arg0 : f32
|
||||
// CHECK: spv.OCL.rsqrt %{{.*}}: f32
|
||||
// CHECK: spv.CL.rsqrt %{{.*}}: f32
|
||||
%5 = math.rsqrt %arg0 : f32
|
||||
// CHECK: spv.OCL.sqrt %{{.*}}: f32
|
||||
// CHECK: spv.CL.sqrt %{{.*}}: f32
|
||||
%6 = math.sqrt %arg0 : f32
|
||||
// CHECK: spv.OCL.tanh %{{.*}}: f32
|
||||
// CHECK: spv.CL.tanh %{{.*}}: f32
|
||||
%7 = math.tanh %arg0 : f32
|
||||
// CHECK: spv.OCL.sin %{{.*}}: f32
|
||||
// CHECK: spv.CL.sin %{{.*}}: f32
|
||||
%8 = math.sin %arg0 : f32
|
||||
// CHECK: spv.OCL.fabs %{{.*}}: f32
|
||||
// CHECK: spv.CL.fabs %{{.*}}: f32
|
||||
%9 = math.abs %arg0 : f32
|
||||
// CHECK: spv.OCL.ceil %{{.*}}: f32
|
||||
// CHECK: spv.CL.ceil %{{.*}}: f32
|
||||
%10 = math.ceil %arg0 : f32
|
||||
// CHECK: spv.OCL.floor %{{.*}}: f32
|
||||
// CHECK: spv.CL.floor %{{.*}}: f32
|
||||
%11 = math.floor %arg0 : f32
|
||||
// CHECK: spv.OCL.erf %{{.*}}: f32
|
||||
// CHECK: spv.CL.erf %{{.*}}: f32
|
||||
%12 = math.erf %arg0 : f32
|
||||
// CHECK: spv.OCL.round %{{.*}}: f32
|
||||
// CHECK: spv.CL.round %{{.*}}: f32
|
||||
%13 = math.round %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @float32_unary_vector
|
||||
func.func @float32_unary_vector(%arg0: vector<3xf32>) {
|
||||
// CHECK: spv.OCL.cos %{{.*}}: vector<3xf32>
|
||||
// CHECK: spv.CL.cos %{{.*}}: vector<3xf32>
|
||||
%0 = math.cos %arg0 : vector<3xf32>
|
||||
// CHECK: spv.OCL.exp %{{.*}}: vector<3xf32>
|
||||
// CHECK: spv.CL.exp %{{.*}}: vector<3xf32>
|
||||
%1 = math.exp %arg0 : vector<3xf32>
|
||||
// CHECK: %[[EXP:.+]] = spv.OCL.exp %arg0
|
||||
// CHECK: %[[EXP:.+]] = spv.CL.exp %arg0
|
||||
// CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<3xf32>
|
||||
// CHECK: spv.FSub %[[EXP]], %[[ONE]]
|
||||
%2 = math.expm1 %arg0 : vector<3xf32>
|
||||
// CHECK: spv.OCL.log %{{.*}}: vector<3xf32>
|
||||
// CHECK: spv.CL.log %{{.*}}: vector<3xf32>
|
||||
%3 = math.log %arg0 : vector<3xf32>
|
||||
// CHECK: %[[ONE:.+]] = spv.Constant dense<1.000000e+00> : vector<3xf32>
|
||||
// CHECK: %[[ADDONE:.+]] = spv.FAdd %[[ONE]], %{{.+}}
|
||||
// CHECK: spv.OCL.log %[[ADDONE]]
|
||||
// CHECK: spv.CL.log %[[ADDONE]]
|
||||
%4 = math.log1p %arg0 : vector<3xf32>
|
||||
// CHECK: spv.OCL.rsqrt %{{.*}}: vector<3xf32>
|
||||
// CHECK: spv.CL.rsqrt %{{.*}}: vector<3xf32>
|
||||
%5 = math.rsqrt %arg0 : vector<3xf32>
|
||||
// CHECK: spv.OCL.sqrt %{{.*}}: vector<3xf32>
|
||||
// CHECK: spv.CL.sqrt %{{.*}}: vector<3xf32>
|
||||
%6 = math.sqrt %arg0 : vector<3xf32>
|
||||
// CHECK: spv.OCL.tanh %{{.*}}: vector<3xf32>
|
||||
// CHECK: spv.CL.tanh %{{.*}}: vector<3xf32>
|
||||
%7 = math.tanh %arg0 : vector<3xf32>
|
||||
// CHECK: spv.OCL.sin %{{.*}}: vector<3xf32>
|
||||
// CHECK: spv.CL.sin %{{.*}}: vector<3xf32>
|
||||
%8 = math.sin %arg0 : vector<3xf32>
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @float32_binary_scalar
|
||||
func.func @float32_binary_scalar(%lhs: f32, %rhs: f32) {
|
||||
// CHECK: spv.OCL.pow %{{.*}}: f32
|
||||
// CHECK: spv.CL.pow %{{.*}}: f32
|
||||
%0 = math.powf %lhs, %rhs : f32
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @float32_binary_vector
|
||||
func.func @float32_binary_vector(%lhs: vector<4xf32>, %rhs: vector<4xf32>) {
|
||||
// CHECK: spv.OCL.pow %{{.*}}: vector<4xf32>
|
||||
// CHECK: spv.CL.pow %{{.*}}: vector<4xf32>
|
||||
%0 = math.powf %lhs, %rhs : vector<4xf32>
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @float32_ternary_scalar
|
||||
func.func @float32_ternary_scalar(%a: f32, %b: f32, %c: f32) {
|
||||
// CHECK: spv.OCL.fma %{{.*}}: f32
|
||||
// CHECK: spv.CL.fma %{{.*}}: f32
|
||||
%0 = math.fma %a, %b, %c : f32
|
||||
return
|
||||
}
|
||||
@ -90,7 +90,7 @@ func.func @float32_ternary_scalar(%a: f32, %b: f32, %c: f32) {
|
||||
// CHECK-LABEL: @float32_ternary_vector
|
||||
func.func @float32_ternary_vector(%a: vector<4xf32>, %b: vector<4xf32>,
|
||||
%c: vector<4xf32>) {
|
||||
// CHECK: spv.OCL.fma %{{.*}}: vector<4xf32>
|
||||
// CHECK: spv.CL.fma %{{.*}}: vector<4xf32>
|
||||
%0 = math.fma %a, %b, %c : vector<4xf32>
|
||||
return
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.OCL.exp
|
||||
// spv.CL.exp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func.func @exp(%arg0 : f32) -> () {
|
||||
// CHECK: spv.OCL.exp {{%.*}} : f32
|
||||
%2 = spv.OCL.exp %arg0 : f32
|
||||
// CHECK: spv.CL.exp {{%.*}} : f32
|
||||
%2 = spv.CL.exp %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func.func @expvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.OCL.exp {{%.*}} : vector<3xf16>
|
||||
%2 = spv.OCL.exp %arg0 : vector<3xf16>
|
||||
// CHECK: spv.CL.exp {{%.*}} : vector<3xf16>
|
||||
%2 = spv.CL.exp %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ func.func @expvec(%arg0 : vector<3xf16>) -> () {
|
||||
|
||||
func.func @exp(%arg0 : i32) -> () {
|
||||
// expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}}
|
||||
%2 = spv.OCL.exp %arg0 : i32
|
||||
%2 = spv.CL.exp %arg0 : i32
|
||||
return
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ func.func @exp(%arg0 : i32) -> () {
|
||||
|
||||
func.func @exp(%arg0 : vector<5xf32>) -> () {
|
||||
// expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4}}
|
||||
%2 = spv.OCL.exp %arg0 : vector<5xf32>
|
||||
%2 = spv.CL.exp %arg0 : vector<5xf32>
|
||||
return
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ func.func @exp(%arg0 : vector<5xf32>) -> () {
|
||||
|
||||
func.func @exp(%arg0 : f32, %arg1 : f32) -> () {
|
||||
// expected-error @+1 {{expected ':'}}
|
||||
%2 = spv.OCL.exp %arg0, %arg1 : i32
|
||||
%2 = spv.CL.exp %arg0, %arg1 : i32
|
||||
return
|
||||
}
|
||||
|
||||
@ -44,31 +44,31 @@ func.func @exp(%arg0 : f32, %arg1 : f32) -> () {
|
||||
|
||||
func.func @exp(%arg0 : i32) -> () {
|
||||
// expected-error @+1 {{expected non-function type}}
|
||||
%2 = spv.OCL.exp %arg0 :
|
||||
%2 = spv.CL.exp %arg0 :
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.OCL.fabs
|
||||
// spv.CL.fabs
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func.func @fabs(%arg0 : f32) -> () {
|
||||
// CHECK: spv.OCL.fabs {{%.*}} : f32
|
||||
%2 = spv.OCL.fabs %arg0 : f32
|
||||
// CHECK: spv.CL.fabs {{%.*}} : f32
|
||||
%2 = spv.CL.fabs %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func.func @fabsvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.OCL.fabs {{%.*}} : vector<3xf16>
|
||||
%2 = spv.OCL.fabs %arg0 : vector<3xf16>
|
||||
// CHECK: spv.CL.fabs {{%.*}} : vector<3xf16>
|
||||
%2 = spv.CL.fabs %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
func.func @fabsf64(%arg0 : f64) -> () {
|
||||
// CHECK: spv.OCL.fabs {{%.*}} : f64
|
||||
%2 = spv.OCL.fabs %arg0 : f64
|
||||
// CHECK: spv.CL.fabs {{%.*}} : f64
|
||||
%2 = spv.CL.fabs %arg0 : f64
|
||||
return
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ func.func @fabsf64(%arg0 : f64) -> () {
|
||||
|
||||
func.func @fabs(%arg0 : i32) -> () {
|
||||
// expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values}}
|
||||
%2 = spv.OCL.fabs %arg0 : i32
|
||||
%2 = spv.CL.fabs %arg0 : i32
|
||||
return
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ func.func @fabs(%arg0 : i32) -> () {
|
||||
|
||||
func.func @fabs(%arg0 : vector<5xf32>) -> () {
|
||||
// expected-error @+1 {{op operand #0 must be 16/32/64-bit float or vector of 16/32/64-bit float values of length 2/3/4}}
|
||||
%2 = spv.OCL.fabs %arg0 : vector<5xf32>
|
||||
%2 = spv.CL.fabs %arg0 : vector<5xf32>
|
||||
return
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ func.func @fabs(%arg0 : vector<5xf32>) -> () {
|
||||
|
||||
func.func @fabs(%arg0 : f32, %arg1 : f32) -> () {
|
||||
// expected-error @+1 {{expected ':'}}
|
||||
%2 = spv.OCL.fabs %arg0, %arg1 : i32
|
||||
%2 = spv.CL.fabs %arg0, %arg1 : i32
|
||||
return
|
||||
}
|
||||
|
||||
@ -100,37 +100,37 @@ func.func @fabs(%arg0 : f32, %arg1 : f32) -> () {
|
||||
|
||||
func.func @fabs(%arg0 : i32) -> () {
|
||||
// expected-error @+1 {{expected non-function type}}
|
||||
%2 = spv.OCL.fabs %arg0 :
|
||||
%2 = spv.CL.fabs %arg0 :
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.OCL.s_abs
|
||||
// spv.CL.s_abs
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func.func @sabs(%arg0 : i32) -> () {
|
||||
// CHECK: spv.OCL.s_abs {{%.*}} : i32
|
||||
%2 = spv.OCL.s_abs %arg0 : i32
|
||||
// CHECK: spv.CL.s_abs {{%.*}} : i32
|
||||
%2 = spv.CL.s_abs %arg0 : i32
|
||||
return
|
||||
}
|
||||
|
||||
func.func @sabsvec(%arg0 : vector<3xi16>) -> () {
|
||||
// CHECK: spv.OCL.s_abs {{%.*}} : vector<3xi16>
|
||||
%2 = spv.OCL.s_abs %arg0 : vector<3xi16>
|
||||
// CHECK: spv.CL.s_abs {{%.*}} : vector<3xi16>
|
||||
%2 = spv.CL.s_abs %arg0 : vector<3xi16>
|
||||
return
|
||||
}
|
||||
|
||||
func.func @sabsi64(%arg0 : i64) -> () {
|
||||
// CHECK: spv.OCL.s_abs {{%.*}} : i64
|
||||
%2 = spv.OCL.s_abs %arg0 : i64
|
||||
// CHECK: spv.CL.s_abs {{%.*}} : i64
|
||||
%2 = spv.CL.s_abs %arg0 : i64
|
||||
return
|
||||
}
|
||||
|
||||
func.func @sabsi8(%arg0 : i8) -> () {
|
||||
// CHECK: spv.OCL.s_abs {{%.*}} : i8
|
||||
%2 = spv.OCL.s_abs %arg0 : i8
|
||||
// CHECK: spv.CL.s_abs {{%.*}} : i8
|
||||
%2 = spv.CL.s_abs %arg0 : i8
|
||||
return
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ func.func @sabsi8(%arg0 : i8) -> () {
|
||||
|
||||
func.func @sabs(%arg0 : f32) -> () {
|
||||
// expected-error @+1 {{op operand #0 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values}}
|
||||
%2 = spv.OCL.s_abs %arg0 : f32
|
||||
%2 = spv.CL.s_abs %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ func.func @sabs(%arg0 : f32) -> () {
|
||||
|
||||
func.func @sabs(%arg0 : vector<5xi32>) -> () {
|
||||
// expected-error @+1 {{op operand #0 must be 8/16/32/64-bit integer or vector of 8/16/32/64-bit integer values of length 2/3/4}}
|
||||
%2 = spv.OCL.s_abs %arg0 : vector<5xi32>
|
||||
%2 = spv.CL.s_abs %arg0 : vector<5xi32>
|
||||
return
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ func.func @sabs(%arg0 : vector<5xi32>) -> () {
|
||||
|
||||
func.func @sabs(%arg0 : i32, %arg1 : i32) -> () {
|
||||
// expected-error @+1 {{expected ':'}}
|
||||
%2 = spv.OCL.s_abs %arg0, %arg1 : i32
|
||||
%2 = spv.CL.s_abs %arg0, %arg1 : i32
|
||||
return
|
||||
}
|
||||
|
||||
@ -162,26 +162,26 @@ func.func @sabs(%arg0 : i32, %arg1 : i32) -> () {
|
||||
|
||||
func.func @sabs(%arg0 : i32) -> () {
|
||||
// expected-error @+1 {{expected non-function type}}
|
||||
%2 = spv.OCL.s_abs %arg0 :
|
||||
%2 = spv.CL.s_abs %arg0 :
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.OCL.fma
|
||||
// spv.CL.fma
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func.func @fma(%a : f32, %b : f32, %c : f32) -> () {
|
||||
// CHECK: spv.OCL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32
|
||||
%2 = spv.OCL.fma %a, %b, %c : f32
|
||||
// CHECK: spv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32
|
||||
%2 = spv.CL.fma %a, %b, %c : f32
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
func.func @fma(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> () {
|
||||
// CHECK: spv.OCL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32>
|
||||
%2 = spv.OCL.fma %a, %b, %c : vector<3xf32>
|
||||
// CHECK: spv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32>
|
||||
%2 = spv.CL.fma %a, %b, %c : vector<3xf32>
|
||||
return
|
||||
}
|
||||
|
@ -2,46 +2,46 @@
|
||||
|
||||
spv.module Physical64 OpenCL requires #spv.vce<v1.0, [Kernel, Addresses], []> {
|
||||
spv.func @float_insts(%arg0 : f32) "None" {
|
||||
// CHECK: {{%.*}} = spv.OCL.exp {{%.*}} : f32
|
||||
%0 = spv.OCL.exp %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.fabs {{%.*}} : f32
|
||||
%1 = spv.OCL.fabs %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.sin {{%.*}} : f32
|
||||
%2 = spv.OCL.sin %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.cos {{%.*}} : f32
|
||||
%3 = spv.OCL.cos %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.log {{%.*}} : f32
|
||||
%4 = spv.OCL.log %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.sqrt {{%.*}} : f32
|
||||
%5 = spv.OCL.sqrt %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.ceil {{%.*}} : f32
|
||||
%6 = spv.OCL.ceil %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.floor {{%.*}} : f32
|
||||
%7 = spv.OCL.floor %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.pow {{%.*}}, {{%.*}} : f32
|
||||
%8 = spv.OCL.pow %arg0, %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.rsqrt {{%.*}} : f32
|
||||
%9 = spv.OCL.rsqrt %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.OCL.erf {{%.*}} : f32
|
||||
%10 = spv.OCL.erf %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.exp {{%.*}} : f32
|
||||
%0 = spv.CL.exp %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.fabs {{%.*}} : f32
|
||||
%1 = spv.CL.fabs %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.sin {{%.*}} : f32
|
||||
%2 = spv.CL.sin %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.cos {{%.*}} : f32
|
||||
%3 = spv.CL.cos %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.log {{%.*}} : f32
|
||||
%4 = spv.CL.log %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.sqrt {{%.*}} : f32
|
||||
%5 = spv.CL.sqrt %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.ceil {{%.*}} : f32
|
||||
%6 = spv.CL.ceil %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.floor {{%.*}} : f32
|
||||
%7 = spv.CL.floor %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.pow {{%.*}}, {{%.*}} : f32
|
||||
%8 = spv.CL.pow %arg0, %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.rsqrt {{%.*}} : f32
|
||||
%9 = spv.CL.rsqrt %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.CL.erf {{%.*}} : f32
|
||||
%10 = spv.CL.erf %arg0 : f32
|
||||
spv.Return
|
||||
}
|
||||
|
||||
spv.func @integer_insts(%arg0 : i32) "None" {
|
||||
// CHECK: {{%.*}} = spv.OCL.s_abs {{%.*}} : i32
|
||||
%0 = spv.OCL.s_abs %arg0 : i32
|
||||
// CHECK: {{%.*}} = spv.CL.s_abs {{%.*}} : i32
|
||||
%0 = spv.CL.s_abs %arg0 : i32
|
||||
spv.Return
|
||||
}
|
||||
|
||||
spv.func @vector_size16(%arg0 : vector<16xf32>) "None" {
|
||||
// CHECK: {{%.*}} = spv.OCL.fabs {{%.*}} : vector<16xf32>
|
||||
%0 = spv.OCL.fabs %arg0 : vector<16xf32>
|
||||
// CHECK: {{%.*}} = spv.CL.fabs {{%.*}} : vector<16xf32>
|
||||
%0 = spv.CL.fabs %arg0 : vector<16xf32>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
spv.func @fma(%arg0 : f32, %arg1 : f32, %arg2 : f32) "None" {
|
||||
// CHECK: spv.OCL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32
|
||||
%13 = spv.OCL.fma %arg0, %arg1, %arg2 : f32
|
||||
// CHECK: spv.CL.fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32
|
||||
%13 = spv.CL.fma %arg0, %arg1, %arg2 : f32
|
||||
spv.Return
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
# For example, to define the enum attribute for SPIR-V memory model:
|
||||
#
|
||||
# ./gen_spirv_dialect.py --base_td_path /path/to/SPIRVBase.td \
|
||||
# ./gen_spirv_dialect.py --base-td-path /path/to/SPIRVBase.td \
|
||||
# --new-enum MemoryModel
|
||||
#
|
||||
# The 'operand_kinds' dict of spirv.core.grammar.json contains all supported
|
||||
@ -25,8 +25,8 @@ import yaml
|
||||
SPIRV_HTML_SPEC_URL = 'https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html'
|
||||
SPIRV_JSON_SPEC_URL = 'https://raw.githubusercontent.com/KhronosGroup/SPIRV-Headers/master/include/spirv/unified1/spirv.core.grammar.json'
|
||||
|
||||
SPIRV_OCL_EXT_HTML_SPEC_URL = 'https://www.khronos.org/registry/SPIR-V/specs/unified1/OpenCL.ExtendedInstructionSet.100.html'
|
||||
SPIRV_OCL_EXT_JSON_SPEC_URL = 'https://raw.githubusercontent.com/KhronosGroup/SPIRV-Headers/master/include/spirv/unified1/extinst.opencl.std.100.grammar.json'
|
||||
SPIRV_CL_EXT_HTML_SPEC_URL = 'https://www.khronos.org/registry/SPIR-V/specs/unified1/OpenCL.ExtendedInstructionSet.100.html'
|
||||
SPIRV_CL_EXT_JSON_SPEC_URL = 'https://raw.githubusercontent.com/KhronosGroup/SPIRV-Headers/master/include/spirv/unified1/extinst.opencl.std.100.grammar.json'
|
||||
|
||||
AUTOGEN_OP_DEF_SEPARATOR = '\n// -----\n\n'
|
||||
AUTOGEN_ENUM_SECTION_MARKER = 'enum section. Generated from SPIR-V spec; DO NOT MODIFY!'
|
||||
@ -50,7 +50,7 @@ def get_spirv_doc_from_html_spec(url, settings):
|
||||
|
||||
doc = {}
|
||||
|
||||
if settings.gen_ocl_ops:
|
||||
if settings.gen_cl_ops:
|
||||
section_anchor = spirv.find('h2', {'id': '_binary_form'})
|
||||
for section in section_anchor.parent.find_all('div', {'class': 'sect2'}):
|
||||
for table in section.find_all('table'):
|
||||
@ -703,7 +703,7 @@ def get_op_definition(instruction, opname, doc, existing_info, capability_mappin
|
||||
Returns:
|
||||
- A string containing the TableGen op definition
|
||||
"""
|
||||
if settings.gen_ocl_ops:
|
||||
if settings.gen_cl_ops:
|
||||
fmt_str = ('def SPV_{opname}Op : '
|
||||
'SPV_{inst_category}<"{opname_src}", {opcode}, <<Insert result type>> > '
|
||||
'{{\n let summary = {summary};\n\n let description = '
|
||||
@ -959,8 +959,8 @@ def update_td_op_definitions(path, instructions, docs, filter_list,
|
||||
|
||||
op_defs = []
|
||||
|
||||
if settings.gen_ocl_ops:
|
||||
fix_opname = lambda src: src.replace('OCL','').lower()
|
||||
if settings.gen_cl_ops:
|
||||
fix_opname = lambda src: src.replace('CL','').lower()
|
||||
else:
|
||||
fix_opname = lambda src: src
|
||||
|
||||
@ -1035,19 +1035,19 @@ if __name__ == '__main__':
|
||||
help='SPIR-V instruction category used for choosing '\
|
||||
'the TableGen base class to define this op')
|
||||
cli_parser.add_argument(
|
||||
'--gen-ocl-ops',
|
||||
dest='gen_ocl_ops',
|
||||
'--gen-cl-ops',
|
||||
dest='gen_cl_ops',
|
||||
help='Generate OpenCL Extended Instruction Set op',
|
||||
action='store_true')
|
||||
cli_parser.set_defaults(gen_ocl_ops=False)
|
||||
cli_parser.set_defaults(gen_cl_ops=False)
|
||||
cli_parser.add_argument('--gen-inst-coverage', dest='gen_inst_coverage', action='store_true')
|
||||
cli_parser.set_defaults(gen_inst_coverage=False)
|
||||
|
||||
args = cli_parser.parse_args()
|
||||
|
||||
if args.gen_ocl_ops:
|
||||
ext_html_url = SPIRV_OCL_EXT_HTML_SPEC_URL
|
||||
ext_json_url = SPIRV_OCL_EXT_JSON_SPEC_URL
|
||||
if args.gen_cl_ops:
|
||||
ext_html_url = SPIRV_CL_EXT_HTML_SPEC_URL
|
||||
ext_json_url = SPIRV_CL_EXT_JSON_SPEC_URL
|
||||
else:
|
||||
ext_html_url = None
|
||||
ext_json_url = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user