1 //===- CodeGenInstAlias.h - InstAlias Class Wrapper -------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines a wrapper class for the 'InstAlias' TableGen class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_UTILS_TABLEGEN_CODEGENINSTALIAS_H
14 #define LLVM_UTILS_TABLEGEN_CODEGENINSTALIAS_H
16 #include "llvm/ADT/StringRef.h"
25 template <typename T
> class ArrayRef
;
26 class CodeGenInstruction
;
32 /// CodeGenInstAlias - This represents an InstAlias definition.
33 class CodeGenInstAlias
{
35 Record
*TheDef
; // The actual record defining this InstAlias.
37 /// AsmString - The format string used to emit a .s file for the
39 std::string AsmString
;
41 /// Result - The result instruction.
44 /// ResultInst - The instruction generated by the alias (decoded from
46 CodeGenInstruction
*ResultInst
;
48 struct ResultOperand
{
55 enum { K_Record
, K_Imm
, K_Reg
} Kind
;
57 ResultOperand(std::string N
, Record
*r
)
58 : Name(std::move(N
)), R(r
), Kind(K_Record
) {}
59 ResultOperand(int64_t I
) : Imm(I
), Kind(K_Imm
) {}
60 ResultOperand(Record
*r
) : R(r
), Kind(K_Reg
) {}
62 bool isRecord() const { return Kind
== K_Record
; }
63 bool isImm() const { return Kind
== K_Imm
; }
64 bool isReg() const { return Kind
== K_Reg
; }
66 StringRef
getName() const {
70 Record
*getRecord() const {
74 int64_t getImm() const {
78 Record
*getRegister() const {
83 unsigned getMINumOperands() const;
86 /// ResultOperands - The decoded operands for the result instruction.
87 std::vector
<ResultOperand
> ResultOperands
;
89 /// ResultInstOperandIndex - For each operand, this vector holds a pair of
90 /// indices to identify the corresponding operand in the result
91 /// instruction. The first index specifies the operand and the second
92 /// index specifies the suboperand. If there are no suboperands or if all
93 /// of them are matched by the operand, the second value should be -1.
94 std::vector
<std::pair
<unsigned, int>> ResultInstOperandIndex
;
96 CodeGenInstAlias(Record
*R
, CodeGenTarget
&T
);
98 bool tryAliasOpMatch(DagInit
*Result
, unsigned AliasOpNo
, Record
*InstOpRec
,
99 bool hasSubOps
, ArrayRef
<SMLoc
> Loc
, CodeGenTarget
&T
,
100 ResultOperand
&ResOp
);
105 #endif // LLVM_UTILS_TABLEGEN_CODEGENINSTALIAS_H