Path: blob/main/contrib/llvm-project/llvm/utils/TableGen/Common/CodeGenInstAlias.h
35290 views
//===- CodeGenInstAlias.h - InstAlias Class Wrapper -------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines a wrapper class for the 'InstAlias' TableGen class.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_UTILS_TABLEGEN_CODEGENINSTALIAS_H13#define LLVM_UTILS_TABLEGEN_CODEGENINSTALIAS_H1415#include "llvm/ADT/StringRef.h"16#include <cassert>17#include <cstdint>18#include <string>19#include <utility>20#include <vector>2122namespace llvm {2324template <typename T> class ArrayRef;25class CodeGenInstruction;26class CodeGenTarget;27class DagInit;28class SMLoc;29class Record;3031/// CodeGenInstAlias - This represents an InstAlias definition.32class CodeGenInstAlias {33public:34Record *TheDef; // The actual record defining this InstAlias.3536/// AsmString - The format string used to emit a .s file for the37/// instruction.38std::string AsmString;3940/// Result - The result instruction.41DagInit *Result;4243/// ResultInst - The instruction generated by the alias (decoded from44/// Result).45CodeGenInstruction *ResultInst;4647struct ResultOperand {48private:49std::string Name;50Record *R = nullptr;51int64_t Imm = 0;5253public:54enum { K_Record, K_Imm, K_Reg } Kind;5556ResultOperand(std::string N, Record *r)57: Name(std::move(N)), R(r), Kind(K_Record) {}58ResultOperand(int64_t I) : Imm(I), Kind(K_Imm) {}59ResultOperand(Record *r) : R(r), Kind(K_Reg) {}6061bool isRecord() const { return Kind == K_Record; }62bool isImm() const { return Kind == K_Imm; }63bool isReg() const { return Kind == K_Reg; }6465StringRef getName() const {66assert(isRecord());67return Name;68}69Record *getRecord() const {70assert(isRecord());71return R;72}73int64_t getImm() const {74assert(isImm());75return Imm;76}77Record *getRegister() const {78assert(isReg());79return R;80}8182unsigned getMINumOperands() const;83};8485/// ResultOperands - The decoded operands for the result instruction.86std::vector<ResultOperand> ResultOperands;8788/// ResultInstOperandIndex - For each operand, this vector holds a pair of89/// indices to identify the corresponding operand in the result90/// instruction. The first index specifies the operand and the second91/// index specifies the suboperand. If there are no suboperands or if all92/// of them are matched by the operand, the second value should be -1.93std::vector<std::pair<unsigned, int>> ResultInstOperandIndex;9495CodeGenInstAlias(Record *R, CodeGenTarget &T);9697bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, Record *InstOpRec,98bool hasSubOps, ArrayRef<SMLoc> Loc, CodeGenTarget &T,99ResultOperand &ResOp);100};101102} // namespace llvm103104#endif // LLVM_UTILS_TABLEGEN_CODEGENINSTALIAS_H105106107