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 helper functions that VE uses to lower LLVM code into a 10 // selection DAG. For example, hiding SDLoc, and easy to use SDNodeFlags. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_VE_VECUSTOMDAG_H 15 #define LLVM_LIB_TARGET_VE_VECUSTOMDAG_H 16 17 #include "VE.h" 18 #include "VEISelLowering.h" 19 #include "llvm/CodeGen/SelectionDAG.h" 20 #include "llvm/CodeGen/TargetLowering.h" 21 22 namespace llvm { 23 24 Optional<unsigned> getVVPOpcode(unsigned Opcode); 25 26 bool isVVPBinaryOp(unsigned Opcode); 27 28 bool isPackedVectorType(EVT SomeVT); 29 30 class VECustomDAG { 31 SelectionDAG &DAG; 32 SDLoc DL; 33 34 public: 35 SelectionDAG *getDAG() const { return &DAG; } 36 37 VECustomDAG(SelectionDAG &DAG, SDLoc DL) : DAG(DAG), DL(DL) {} 38 39 VECustomDAG(SelectionDAG &DAG, SDValue WhereOp) : DAG(DAG), DL(WhereOp) {} 40 41 VECustomDAG(SelectionDAG &DAG, const SDNode *WhereN) : DAG(DAG), DL(WhereN) {} 42 43 /// getNode { 44 SDValue getNode(unsigned OC, SDVTList VTL, ArrayRef<SDValue> OpV, 45 Optional<SDNodeFlags> Flags = None) const { 46 auto N = DAG.getNode(OC, DL, VTL, OpV); 47 if (Flags) 48 N->setFlags(*Flags); 49 return N; 50 } 51 52 SDValue getNode(unsigned OC, ArrayRef<EVT> ResVT, ArrayRef<SDValue> OpV, 53 Optional<SDNodeFlags> Flags = None) const { 54 auto N = DAG.getNode(OC, DL, ResVT, OpV); 55 if (Flags) 56 N->setFlags(*Flags); 57 return N; 58 } 59 60 SDValue getNode(unsigned OC, EVT ResVT, ArrayRef<SDValue> OpV, 61 Optional<SDNodeFlags> Flags = None) const { 62 auto N = DAG.getNode(OC, DL, ResVT, OpV); 63 if (Flags) 64 N->setFlags(*Flags); 65 return N; 66 } 67 68 SDValue getUNDEF(EVT VT) const { return DAG.getUNDEF(VT); } 69 /// } getNode 70 71 SDValue getConstant(uint64_t Val, EVT VT, bool IsTarget = false, 72 bool IsOpaque = false) const; 73 74 SDValue getBroadcast(EVT ResultVT, SDValue Scalar, SDValue AVL) const; 75 }; 76 77 } // namespace llvm 78 79 #endif // LLVM_LIB_TARGET_VE_VECUSTOMDAG_H 80