1//===- GIMatchDagInstr.cpp - A shared operand list for nodes --------------===// 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#include "GIMatchDagInstr.h" 10#include "../CodeGenInstruction.h" 11#include "GIMatchDag.h" 12#include "llvm/TableGen/Record.h" 13 14using namespace llvm; 15 16void GIMatchDagInstr::print(raw_ostream &OS) const { 17 OS << "("; 18 if (const auto *Annotation = getOpcodeAnnotation()) 19 OS << Annotation->TheDef->getName(); 20 else 21 OS << "<unknown>"; 22 OS << " "; 23 OperandInfo.print(OS); 24 OS << "):$" << Name; 25 if (!UserAssignedNamesForOperands.empty()) { 26 OS << " // "; 27 SmallVector<std::pair<unsigned, StringRef>, 8> ToPrint; 28 for (const auto &Assignment : UserAssignedNamesForOperands) 29 ToPrint.emplace_back(Assignment.first, Assignment.second); 30 llvm::sort(ToPrint.begin(), ToPrint.end()); 31 StringRef Separator = ""; 32 for (const auto &Assignment : ToPrint) { 33 OS << Separator << "$" << Assignment.second << "=getOperand(" 34 << Assignment.first << ")"; 35 Separator = ", "; 36 } 37 } 38} 39 40void GIMatchDagInstr::setMatchRoot() { 41 IsMatchRoot = true; 42 Dag.addMatchRoot(this); 43} 44 45raw_ostream &llvm::operator<<(raw_ostream &OS, const GIMatchDagInstr &N) { 46 N.print(OS); 47 return OS; 48} 49