let hasVerifier = 1;
+ string llvmInstName = "ShuffleVector";
string llvmBuilder = [{
$res = builder.CreateShuffleVector($v1, $v2, $mask);
}];
+ string mlirBuilder = [{
+ auto *svInst = cast<llvm::ShuffleVectorInst>(inst);
+ SmallVector<int32_t> mask(svInst->getShuffleMask());
+ $res = $_builder.create<LLVM::ShuffleVectorOp>(
+ $_location, $v1, $v2, mask);
+ }];
}
// Misc operations.
mapValue(inst, res);
return success();
}
- if (inst->getOpcode() == llvm::Instruction::ShuffleVector) {
- auto *svInst = cast<llvm::ShuffleVectorInst>(inst);
- Value vec1 = processValue(svInst->getOperand(0));
- Value vec2 = processValue(svInst->getOperand(1));
-
- SmallVector<int32_t> mask(svInst->getShuffleMask());
- Value res = b.create<ShuffleVectorOp>(loc, vec1, vec2, mask);
- mapValue(inst, res);
- return success();
- }
return emitError(loc) << "unknown instruction: " << diag(*inst);
}
ret void
}
-; Shufflevector
-; CHECK-LABEL: llvm.func @shuffle_vec
-define <4 x half> @shuffle_vec(<4 x half>* %arg0, <4 x half>* %arg1) {
- ; CHECK: %[[V0:.+]] = llvm.load %{{.+}} : !llvm.ptr<vector<4xf16>>
- %val0 = load <4 x half>, <4 x half>* %arg0
- ; CHECK: %[[V1:.+]] = llvm.load %{{.+}} : !llvm.ptr<vector<4xf16>>
- %val1 = load <4 x half>, <4 x half>* %arg1
- ; CHECK: llvm.shufflevector %[[V0]], %[[V1]] [2, 3, -1, -1] : vector<4xf16>
- %shuffle = shufflevector <4 x half> %val0, <4 x half> %val1, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
- ret <4 x half> %shuffle
-}
-
; Varadic function definition
%struct.va_list = type { i8* }
; // -----
+; CHECK-LABEL: func @shuffle_vec
+; CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]
+; CHECK-SAME: %[[ARG2:[a-zA-Z0-9]+]]
+define <4 x half> @shuffle_vec(<4 x half> %arg1, <4 x half> %arg2) {
+ ; CHECK: llvm.shufflevector %[[ARG1]], %[[ARG2]] [2, 3, -1, -1] : vector<4xf16>
+ %1 = shufflevector <4 x half> %arg1, <4 x half> %arg2, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
+ ret <4 x half> %1
+}
+
+; // -----
+
; CHECK-LABEL: @alloca
; CHECK-SAME: %[[SIZE:[a-zA-Z0-9]+]]
define double* @alloca(i64 %size) {