1 //===-- VECustomDAG.h - VE Custom DAG Nodes ------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines the interfaces that VE uses to lower LLVM code into a 10 // selection DAG. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "VECustomDAG.h" 15 16 #ifndef DEBUG_TYPE 17 #define DEBUG_TYPE "vecustomdag" 18 #endif 19 20 namespace llvm { 21 22 /// \returns the VVP_* SDNode opcode corresponsing to \p OC. 23 Optional<unsigned> getVVPOpcode(unsigned Opcode) { 24 switch (Opcode) { 25 #define HANDLE_VP_TO_VVP(VPOPC, VVPNAME) \ 26 case ISD::VPOPC: \ 27 return VEISD::VVPNAME; 28 #define ADD_VVP_OP(VVPNAME, SDNAME) \ 29 case VEISD::VVPNAME: \ 30 case ISD::SDNAME: \ 31 return VEISD::VVPNAME; 32 #include "VVPNodes.def" 33 } 34 return None; 35 } 36 37 bool isVVPBinaryOp(unsigned VVPOpcode) { 38 switch (VVPOpcode) { 39 #define ADD_BINARY_VVP_OP(VVPNAME, ...) \ 40 case VEISD::VVPNAME: \ 41 return true; 42 #include "VVPNodes.def" 43 } 44 return false; 45 } 46 47 SDValue VECustomDAG::getConstant(uint64_t Val, EVT VT, bool IsTarget, 48 bool IsOpaque) const { 49 return DAG.getConstant(Val, DL, VT, IsTarget, IsOpaque); 50 } 51 52 SDValue VECustomDAG::getBroadcast(EVT ResultVT, SDValue Scalar, 53 SDValue AVL) const { 54 return getNode(VEISD::VEC_BROADCAST, ResultVT, {Scalar, AVL}); 55 } 56 57 } // namespace llvm 58