1*e8d8bef9SDimitry Andric//===----------- VVPInstrPatternsVec.td - VVP_* SDNode patterns -----------===// 2*e8d8bef9SDimitry Andric// 3*e8d8bef9SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*e8d8bef9SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5*e8d8bef9SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*e8d8bef9SDimitry Andric// 7*e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 8*e8d8bef9SDimitry Andric// 9*e8d8bef9SDimitry Andric// This file describes how VVP_* SDNodes are lowered to machine instructions. 10*e8d8bef9SDimitry Andric// 11*e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 12*e8d8bef9SDimitry Andric 13*e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 14*e8d8bef9SDimitry Andric// 15*e8d8bef9SDimitry Andric// VVP SDNode definitions. 16*e8d8bef9SDimitry Andric// 17*e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 18*e8d8bef9SDimitry Andricinclude "VVPInstrInfo.td" 19*e8d8bef9SDimitry Andric 20*e8d8bef9SDimitry Andricmulticlass VectorBinaryArith< 21*e8d8bef9SDimitry Andric SDPatternOperator OpNode, 22*e8d8bef9SDimitry Andric ValueType ScalarVT, ValueType DataVT, ValueType MaskVT, 23*e8d8bef9SDimitry Andric string OpBaseName, 24*e8d8bef9SDimitry Andric SDPatternOperator ImmOp, SDNodeXForm ImmCast> { 25*e8d8bef9SDimitry Andric // No mask. 26*e8d8bef9SDimitry Andric def : Pat<(OpNode 27*e8d8bef9SDimitry Andric (any_broadcast ScalarVT:$sx), 28*e8d8bef9SDimitry Andric DataVT:$vy, (MaskVT true_mask), i32:$avl), 29*e8d8bef9SDimitry Andric (!cast<Instruction>(OpBaseName#"rvl") 30*e8d8bef9SDimitry Andric ScalarVT:$sx, $vy, $avl)>; 31*e8d8bef9SDimitry Andric def : Pat<(OpNode DataVT:$vx, DataVT:$vy, (MaskVT true_mask), i32:$avl), 32*e8d8bef9SDimitry Andric (!cast<Instruction>(OpBaseName#"vvl") 33*e8d8bef9SDimitry Andric $vx, $vy, $avl)>; 34*e8d8bef9SDimitry Andric 35*e8d8bef9SDimitry Andric // Mask. 36*e8d8bef9SDimitry Andric def : Pat<(OpNode 37*e8d8bef9SDimitry Andric (any_broadcast ScalarVT:$sx), 38*e8d8bef9SDimitry Andric DataVT:$vy, MaskVT:$mask, i32:$avl), 39*e8d8bef9SDimitry Andric (!cast<Instruction>(OpBaseName#"rvml") 40*e8d8bef9SDimitry Andric ScalarVT:$sx, $vy, $mask, $avl)>; 41*e8d8bef9SDimitry Andric def : Pat<(OpNode DataVT:$vx, DataVT:$vy, MaskVT:$mask, i32:$avl), 42*e8d8bef9SDimitry Andric (!cast<Instruction>(OpBaseName#"vvml") 43*e8d8bef9SDimitry Andric $vx, $vy, $mask, $avl)>; 44*e8d8bef9SDimitry Andric 45*e8d8bef9SDimitry Andric // TODO We do not specify patterns for the immediate variants here. There 46*e8d8bef9SDimitry Andric // will be an immediate folding pass that takes care of switching to the 47*e8d8bef9SDimitry Andric // immediate variant where applicable. 48*e8d8bef9SDimitry Andric 49*e8d8bef9SDimitry Andric // TODO Fold vvp_select into passthru. 50*e8d8bef9SDimitry Andric} 51*e8d8bef9SDimitry Andric 52*e8d8bef9SDimitry Andric// Expand both 64bit and 32 bit variant (256 elements) 53*e8d8bef9SDimitry Andricmulticlass VectorBinaryArith_ShortLong< 54*e8d8bef9SDimitry Andric SDPatternOperator OpNode, 55*e8d8bef9SDimitry Andric ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName, 56*e8d8bef9SDimitry Andric ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> { 57*e8d8bef9SDimitry Andric defm : VectorBinaryArith<OpNode, 58*e8d8bef9SDimitry Andric LongScalarVT, LongDataVT, v256i1, 59*e8d8bef9SDimitry Andric LongOpBaseName, simm7, LO7>; 60*e8d8bef9SDimitry Andric defm : VectorBinaryArith<OpNode, 61*e8d8bef9SDimitry Andric ShortScalarVT, ShortDataVT, v256i1, 62*e8d8bef9SDimitry Andric ShortOpBaseName, simm7, LO7>; 63*e8d8bef9SDimitry Andric} 64*e8d8bef9SDimitry Andric 65*e8d8bef9SDimitry Andric 66*e8d8bef9SDimitry Andricdefm : VectorBinaryArith_ShortLong<c_vvp_add, 67*e8d8bef9SDimitry Andric i64, v256i64, "VADDSL", 68*e8d8bef9SDimitry Andric i32, v256i32, "VADDSWSX">; 69*e8d8bef9SDimitry Andricdefm : VectorBinaryArith_ShortLong<c_vvp_and, 70*e8d8bef9SDimitry Andric i64, v256i64, "VAND", 71*e8d8bef9SDimitry Andric i32, v256i32, "PVANDLO">; 72