LLVM 24.0.0git
PISAUtils.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/// \file
10/// This file implements utility functions for the PISA backend.
11///
12//===----------------------------------------------------------------------===//
13
14#include "PISAUtils.h"
16#include "PISA.h"
17#include "PISAInstrInfo.h"
18#include "llvm/ADT/StringRef.h"
23#include "llvm/IR/IntrinsicsPISA.h"
24
25namespace llvm::PISA {
26std::tuple<MachineInstr *, unsigned>
28 bool NoVectors) {
29 MachineInstr *DefMI = MRI.getVRegDef(Reg);
30 unsigned Opc = DefMI->getOpcode();
31 Register DefReg = Reg;
32 while (Opc == TargetOpcode::G_BITCAST ||
34 Register SrcReg = DefMI->getOperand(1).getReg();
35 LLT SrcTy = MRI.getType(SrcReg);
36 if (!SrcTy.isValid())
37 break;
38 LLT DstTy = MRI.getType(DefMI->getOperand(0).getReg());
39 if (NoVectors && (DstTy.isVector() || SrcTy.isVector()))
40 break;
41 DefReg = SrcReg;
42 DefMI = MRI.getVRegDef(DefReg);
43 Opc = DefMI->getOpcode();
44 }
45 int RegIdx = DefMI->findRegisterDefOperandIdx(DefReg, /*TRI=*/nullptr);
46 assert(RegIdx >= 0 && "defining register operand not found");
47 return std::make_tuple(DefMI, static_cast<unsigned>(RegIdx));
48}
49
50} // namespace llvm::PISA
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
SDValue SrcReg
unsigned Opc
This file declares the MachineIRBuilder class.
Register Reg
This file declares common definitions used by the PISA MC components.
This file declares instruction information for the PISA target.
This file declares utility functions for the PISA backend.
This file declares the top-level interfaces for the PISA target.
MachineRegisterInfo & MRI
constexpr bool isVector() const
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
Definition Register.h:20
std::tuple< MachineInstr *, unsigned > getDefIgnoringBitcasts(Register Reg, const MachineRegisterInfo &MRI, bool NoVectors)
Definition PISAUtils.cpp:27
bool isPreISelGenericOptimizationHint(unsigned Opcode)