1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
//===-- RISCVInstrPredicates.td - Instruction Predicates ---*- tablegen -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file describes the RISC-V instruction predicates.
//
//===----------------------------------------------------------------------===//
// This predicate is true when the rs2 operand of vlse or vsse is x0, false
// otherwise.
def VLDSX0Pred : MCSchedPredicate<CheckRegOperand<3, X0>>;
// Returns true if this is the sext.w pattern, addiw rd, rs1, 0.
def isSEXT_W
: TIIPredicate<"isSEXT_W",
MCReturnStatement<CheckAll<[
CheckOpcode<[ADDIW]>,
CheckIsRegOperand<1>,
CheckIsImmOperand<2>,
CheckImmOperand<2, 0>
]>>>;
// Returns true if this is the zext.w pattern, adduw rd, rs1, x0.
def isZEXT_W
: TIIPredicate<"isZEXT_W",
MCReturnStatement<CheckAll<[
CheckOpcode<[ADD_UW]>,
CheckIsRegOperand<1>,
CheckIsRegOperand<2>,
CheckRegOperand<2, X0>
]>>>;
// Returns true if this is the zext.b pattern, andi rd, rs1, 255.
def isZEXT_B
: TIIPredicate<"isZEXT_B",
MCReturnStatement<CheckAll<[
CheckOpcode<[ANDI]>,
CheckIsRegOperand<1>,
CheckIsImmOperand<2>,
CheckImmOperand<2, 255>
]>>>;
def isSelectPseudo
: TIIPredicate<"isSelectPseudo",
MCReturnStatement<
CheckOpcode<[
Select_GPR_Using_CC_GPR,
Select_GPR_Using_CC_SImm5_CV,
Select_GPRNoX0_Using_CC_SImm5NonZero_QC,
Select_GPRNoX0_Using_CC_UImm5NonZero_QC,
Select_GPRNoX0_Using_CC_SImm16NonZero_QC,
Select_GPRNoX0_Using_CC_UImm16NonZero_QC,
Select_GPR_Using_CC_UImmLog2XLen_NDS,
Select_GPR_Using_CC_UImm7_NDS,
Select_FPR16_Using_CC_GPR,
Select_FPR16INX_Using_CC_GPR,
Select_FPR32_Using_CC_GPR,
Select_FPR32INX_Using_CC_GPR,
Select_FPR64_Using_CC_GPR,
Select_FPR64INX_Using_CC_GPR,
Select_FPR64IN32X_Using_CC_GPR
]>>>;
// Returns true if this is a vector configuration instruction.
def isVectorConfigInstr
: TIIPredicate<"isVectorConfigInstr",
MCReturnStatement<
CheckOpcode<[
PseudoVSETVLI,
PseudoVSETVLIX0,
PseudoVSETVLIX0X0,
PseudoVSETIVLI
]>>>;
// Return true if this is 'vsetvli x0, x0, vtype' which preserves
// VL and only sets VTYPE.
def isVLPreservingConfig
: TIIPredicate<"isVLPreservingConfig",
MCReturnStatement<CheckOpcode<[PseudoVSETVLIX0X0]>>>;
def isFloatScalarMoveOrScalarSplatInstr
: TIIPredicate<"isFloatScalarMoveOrScalarSplatInstr",
MCReturnStatement<
CheckOpcode<!listflatten([
!instances<Pseudo>("^PseudoVFMV_S_F.*"),
!instances<Pseudo>("^PseudoVFMV_V_F.*")
])>>>;
def isScalarExtractInstr
: TIIPredicate<"isScalarExtractInstr",
MCReturnStatement<
CheckOpcode<!listflatten([
!instances<Pseudo>("^PseudoVMV_X_S.*"),
!instances<Pseudo>("^PseudoVFMV_F.*_S.*")
])>>>;
def isVExtractInstr
: TIIPredicate<"isVExtractInstr",
MCReturnStatement<
CheckOpcode<
!instances<Instruction>("^PseudoRI_VEXTRACT.*")>>>;
def isScalarInsertInstr
: TIIPredicate<"isScalarInsertInstr",
MCReturnStatement<
CheckOpcode<!listflatten([
!instances<Pseudo>("^PseudoVMV_S_X.*"),
!instances<Pseudo>("^PseudoVFMV_S_F.*")
])>>>;
def isScalarSplatInstr
: TIIPredicate<"isScalarSplatInstr",
MCReturnStatement<
CheckOpcode<!listflatten([
!instances<Pseudo>("^PseudoVMV_V_I.*"),
!instances<Pseudo>("^PseudoVMV_V_X.*"),
!instances<Pseudo>("^PseudoVFMV_V_F.*")
])>>>;
def isVSlideInstr
: TIIPredicate<"isVSlideInstr",
MCReturnStatement<
CheckOpcode<!listflatten([
!instances<Pseudo>("^PseudoVSLIDEDOWN_VX.*"),
!instances<Pseudo>("^PseudoVSLIDEDOWN_VI.*"),
!instances<Pseudo>("^PseudoVSLIDEUP_VX.*"),
!instances<Pseudo>("^PseudoVSLIDEUP_VI.*")
])>>>;
def isFaultOnlyFirstLoad
: TIIPredicate<"isFaultOnlyFirstLoad",
MCReturnStatement<
CheckOpcode<
!instances<Pseudo>(
"^PseudoVL(SEG[2-8])?E(8|16|32|64)FF_V.*")>>>;
def isNonZeroLoadImmediate
: TIIPredicate<"isNonZeroLoadImmediate",
MCReturnStatement<CheckAll<[
CheckOpcode<[ADDI]>,
CheckIsRegOperand<1>,
CheckRegOperand<1, X0>,
CheckIsImmOperand<2>,
CheckNot<CheckImmOperand<2, 0>>
]>>>;
def ignoresVXRM
: TIIPredicate<"ignoresVXRM",
MCOpcodeSwitchStatement<
[MCOpcodeSwitchCase<
!listflatten([
!instances<Pseudo>("^PseudoVNCLIP_WI.*"),
!instances<Pseudo>("^PseudoVNCLIPU_WI.*")
]),
MCReturnStatement<CheckImmOperand<3, 0>>>],
MCReturnStatement<FalsePred>>>;
|