|
17 | 17 | include "clang/CIR/Dialect/IR/CIRDialect.td" |
18 | 18 | include "clang/CIR/Dialect/IR/CIRTypes.td" |
19 | 19 | include "clang/CIR/Dialect/IR/CIRAttrs.td" |
| 20 | +include "clang/CIR/Dialect/IR/CIRAttrConstraints.td" |
20 | 21 |
|
21 | 22 | include "clang/CIR/Interfaces/CIROpInterfaces.td" |
22 | 23 | include "clang/CIR/Interfaces/CIRLoopOpInterface.td" |
@@ -2155,6 +2156,52 @@ def VecCmpOp : CIR_Op<"vec.cmp", [Pure, SameTypeOperands]> { |
2155 | 2156 | }]; |
2156 | 2157 | } |
2157 | 2158 |
|
| 2159 | +//===----------------------------------------------------------------------===// |
| 2160 | +// VecShuffleOp |
| 2161 | +//===----------------------------------------------------------------------===// |
| 2162 | + |
| 2163 | +// TODO: Create an interface that both VecShuffleOp and VecShuffleDynamicOp |
| 2164 | +// implement. This could be useful for passes that don't care how the vector |
| 2165 | +// shuffle was specified. |
| 2166 | + |
| 2167 | +def VecShuffleOp : CIR_Op<"vec.shuffle", |
| 2168 | + [Pure, AllTypesMatch<["vec1", "vec2"]>]> { |
| 2169 | + let summary = "Combine two vectors using indices passed as constant integers"; |
| 2170 | + let description = [{ |
| 2171 | + The `cir.vec.shuffle` operation implements the documented form of Clang's |
| 2172 | + `__builtin_shufflevector`, where the indices of the shuffled result are |
| 2173 | + integer constants. |
| 2174 | + |
| 2175 | + The two input vectors, which must have the same type, are concatenated. |
| 2176 | + Each of the integer constant arguments is interpreted as an index into that |
| 2177 | + concatenated vector, with a value of -1 meaning that the result value |
| 2178 | + doesn't matter. The result vector, which must have the same element type as |
| 2179 | + the input vectors and the same number of elements as the list of integer |
| 2180 | + constant indices, is constructed by taking the elements at the given |
| 2181 | + indices from the concatenated vector. The size of the result vector does |
| 2182 | + not have to match the size of the individual input vectors or of the |
| 2183 | + concatenated vector. |
| 2184 | + |
| 2185 | + ```mlir |
| 2186 | + %new_vec = cir.vec.shuffle(%vec_1, %vec_2 : !cir.vector<2 x !s32i>) |
| 2187 | + [#cir.int<3> : !s64i, #cir.int<1> : !s64i] : !cir.vector<2 x !s32i> |
| 2188 | + ``` |
| 2189 | + }]; |
| 2190 | + |
| 2191 | + let arguments = (ins |
| 2192 | + CIR_VectorType:$vec1, |
| 2193 | + CIR_VectorType:$vec2, |
| 2194 | + CIR_IntArrayAttr:$indices |
| 2195 | + ); |
| 2196 | + |
| 2197 | + let results = (outs CIR_VectorType:$result); |
| 2198 | + let assemblyFormat = [{ |
| 2199 | + `(` $vec1 `,` $vec2 `:` qualified(type($vec1)) `)` $indices `:` |
| 2200 | + qualified(type($result)) attr-dict |
| 2201 | + }]; |
| 2202 | + let hasVerifier = 1; |
| 2203 | +} |
| 2204 | + |
2158 | 2205 | //===----------------------------------------------------------------------===// |
2159 | 2206 | // VecShuffleDynamicOp |
2160 | 2207 | //===----------------------------------------------------------------------===// |
|
0 commit comments