1*480093f4SDimitry Andric //===-- VEISelDAGToDAG.cpp - A dag to dag inst selector for VE ------------===// 2*480093f4SDimitry Andric // 3*480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*480093f4SDimitry Andric // 7*480093f4SDimitry Andric //===----------------------------------------------------------------------===// 8*480093f4SDimitry Andric // 9*480093f4SDimitry Andric // This file defines an instruction selector for the VE target. 10*480093f4SDimitry Andric // 11*480093f4SDimitry Andric //===----------------------------------------------------------------------===// 12*480093f4SDimitry Andric 13*480093f4SDimitry Andric #include "VETargetMachine.h" 14*480093f4SDimitry Andric #include "llvm/CodeGen/MachineRegisterInfo.h" 15*480093f4SDimitry Andric #include "llvm/CodeGen/SelectionDAGISel.h" 16*480093f4SDimitry Andric #include "llvm/IR/Intrinsics.h" 17*480093f4SDimitry Andric #include "llvm/Support/Debug.h" 18*480093f4SDimitry Andric #include "llvm/Support/ErrorHandling.h" 19*480093f4SDimitry Andric #include "llvm/Support/raw_ostream.h" 20*480093f4SDimitry Andric using namespace llvm; 21*480093f4SDimitry Andric 22*480093f4SDimitry Andric //===----------------------------------------------------------------------===// 23*480093f4SDimitry Andric // Instruction Selector Implementation 24*480093f4SDimitry Andric //===----------------------------------------------------------------------===// 25*480093f4SDimitry Andric 26*480093f4SDimitry Andric //===--------------------------------------------------------------------===// 27*480093f4SDimitry Andric /// VEDAGToDAGISel - VE specific code to select VE machine 28*480093f4SDimitry Andric /// instructions for SelectionDAG operations. 29*480093f4SDimitry Andric /// 30*480093f4SDimitry Andric namespace { 31*480093f4SDimitry Andric class VEDAGToDAGISel : public SelectionDAGISel { 32*480093f4SDimitry Andric /// Subtarget - Keep a pointer to the VE Subtarget around so that we can 33*480093f4SDimitry Andric /// make the right decision when generating code for different targets. 34*480093f4SDimitry Andric const VESubtarget *Subtarget; 35*480093f4SDimitry Andric 36*480093f4SDimitry Andric public: 37*480093f4SDimitry Andric explicit VEDAGToDAGISel(VETargetMachine &tm) : SelectionDAGISel(tm) {} 38*480093f4SDimitry Andric 39*480093f4SDimitry Andric bool runOnMachineFunction(MachineFunction &MF) override { 40*480093f4SDimitry Andric Subtarget = &MF.getSubtarget<VESubtarget>(); 41*480093f4SDimitry Andric return SelectionDAGISel::runOnMachineFunction(MF); 42*480093f4SDimitry Andric } 43*480093f4SDimitry Andric 44*480093f4SDimitry Andric void Select(SDNode *N) override; 45*480093f4SDimitry Andric 46*480093f4SDimitry Andric StringRef getPassName() const override { 47*480093f4SDimitry Andric return "VE DAG->DAG Pattern Instruction Selection"; 48*480093f4SDimitry Andric } 49*480093f4SDimitry Andric 50*480093f4SDimitry Andric // Include the pieces autogenerated from the target description. 51*480093f4SDimitry Andric #include "VEGenDAGISel.inc" 52*480093f4SDimitry Andric }; 53*480093f4SDimitry Andric } // end anonymous namespace 54*480093f4SDimitry Andric 55*480093f4SDimitry Andric void VEDAGToDAGISel::Select(SDNode *N) { 56*480093f4SDimitry Andric SDLoc dl(N); 57*480093f4SDimitry Andric if (N->isMachineOpcode()) { 58*480093f4SDimitry Andric N->setNodeId(-1); 59*480093f4SDimitry Andric return; // Already selected. 60*480093f4SDimitry Andric } 61*480093f4SDimitry Andric 62*480093f4SDimitry Andric SelectCode(N); 63*480093f4SDimitry Andric } 64*480093f4SDimitry Andric 65*480093f4SDimitry Andric /// createVEISelDag - This pass converts a legalized DAG into a 66*480093f4SDimitry Andric /// VE-specific DAG, ready for instruction scheduling. 67*480093f4SDimitry Andric /// 68*480093f4SDimitry Andric FunctionPass *llvm::createVEISelDag(VETargetMachine &TM) { 69*480093f4SDimitry Andric return new VEDAGToDAGISel(TM); 70*480093f4SDimitry Andric } 71