@@ -26,24 +26,39 @@ void PredicateExpander::expandCheckImmOperand(raw_ostream &OS, int OpIndex,
26
26
OS << FunctionMapper << " (" ;
27
27
OS << " MI" << (isByRef () ? " ." : " ->" ) << " getOperand(" << OpIndex
28
28
<< " ).getImm()" ;
29
- OS << (FunctionMapper.empty () ? " " : " ) " );
30
- OS << (shouldNegate () ? " != " : " == " ) << ImmVal;
29
+ if (!FunctionMapper.empty ())
30
+ OS << " )" ;
31
+ OS << (shouldNegate () ? " != " : " == " ) << ImmVal;
31
32
}
32
33
33
34
void PredicateExpander::expandCheckImmOperand (raw_ostream &OS, int OpIndex,
34
35
StringRef ImmVal,
35
36
StringRef FunctionMapper) {
37
+ if (ImmVal.empty ())
38
+ expandCheckImmOperandSimple (OS, OpIndex, FunctionMapper);
39
+
36
40
if (!FunctionMapper.empty ())
37
41
OS << FunctionMapper << " (" ;
38
42
OS << " MI" << (isByRef () ? " ." : " ->" ) << " getOperand(" << OpIndex
39
43
<< " ).getImm()" ;
40
-
41
- OS << (FunctionMapper.empty () ? " " : " )" );
42
- if (ImmVal.empty ())
43
- return ;
44
+ if (!FunctionMapper.empty ())
45
+ OS << " )" ;
44
46
OS << (shouldNegate () ? " != " : " == " ) << ImmVal;
45
47
}
46
48
49
+ void PredicateExpander::expandCheckImmOperandSimple (raw_ostream &OS,
50
+ int OpIndex,
51
+ StringRef FunctionMapper) {
52
+ if (shouldNegate ())
53
+ OS << " !" ;
54
+ if (!FunctionMapper.empty ())
55
+ OS << FunctionMapper << " (" ;
56
+ OS << " MI" << (isByRef () ? " ." : " ->" ) << " getOperand(" << OpIndex
57
+ << " ).getImm()" ;
58
+ if (!FunctionMapper.empty ())
59
+ OS << " )" ;
60
+ }
61
+
47
62
void PredicateExpander::expandCheckRegOperand (raw_ostream &OS, int OpIndex,
48
63
const Record *Reg,
49
64
StringRef FunctionMapper) {
@@ -53,16 +68,29 @@ void PredicateExpander::expandCheckRegOperand(raw_ostream &OS, int OpIndex,
53
68
OS << FunctionMapper << " (" ;
54
69
OS << " MI" << (isByRef () ? " ." : " ->" ) << " getOperand(" << OpIndex
55
70
<< " ).getReg()" ;
56
- OS << (FunctionMapper.empty () ? " " : " )" );
57
- if (!Reg)
58
- return ;
71
+ if (!FunctionMapper.empty ())
72
+ OS << " )" ;
59
73
OS << (shouldNegate () ? " != " : " == " );
60
74
const StringRef Str = Reg->getValueAsString (" Namespace" );
61
75
if (!Str.empty ())
62
76
OS << Str << " ::" ;
63
77
OS << Reg->getName ();
64
78
}
65
79
80
+
81
+ void PredicateExpander::expandCheckRegOperandSimple (raw_ostream &OS,
82
+ int OpIndex,
83
+ StringRef FunctionMapper) {
84
+ if (shouldNegate ())
85
+ OS << " !" ;
86
+ if (!FunctionMapper.empty ())
87
+ OS << FunctionMapper << " (" ;
88
+ OS << " MI" << (isByRef () ? " ." : " ->" ) << " getOperand(" << OpIndex
89
+ << " ).getReg()" ;
90
+ if (!FunctionMapper.empty ())
91
+ OS << " )" ;
92
+ }
93
+
66
94
void PredicateExpander::expandCheckInvalidRegOperand (raw_ostream &OS,
67
95
int OpIndex) {
68
96
OS << " MI" << (isByRef () ? " ." : " ->" ) << " getOperand(" << OpIndex
@@ -290,9 +318,8 @@ void PredicateExpander::expandPredicate(raw_ostream &OS, const Record *Rec) {
290
318
Rec->getValueAsString (" FunctionMapper" ));
291
319
292
320
if (Rec->isSubClassOf (" CheckRegOperandSimple" ))
293
- return expandCheckRegOperand (OS, Rec->getValueAsInt (" OpIndex" ),
294
- nullptr ,
295
- Rec->getValueAsString (" FunctionMapper" ));
321
+ return expandCheckRegOperandSimple (OS, Rec->getValueAsInt (" OpIndex" ),
322
+ Rec->getValueAsString (" FunctionMapper" ));
296
323
297
324
if (Rec->isSubClassOf (" CheckInvalidRegOperand" ))
298
325
return expandCheckInvalidRegOperand (OS, Rec->getValueAsInt (" OpIndex" ));
@@ -308,8 +335,8 @@ void PredicateExpander::expandPredicate(raw_ostream &OS, const Record *Rec) {
308
335
Rec->getValueAsString (" FunctionMapper" ));
309
336
310
337
if (Rec->isSubClassOf (" CheckImmOperandSimple" ))
311
- return expandCheckImmOperand (OS, Rec->getValueAsInt (" OpIndex" ), " " ,
312
- Rec->getValueAsString (" FunctionMapper" ));
338
+ return expandCheckImmOperandSimple (OS, Rec->getValueAsInt (" OpIndex" ),
339
+ Rec->getValueAsString (" FunctionMapper" ));
313
340
314
341
if (Rec->isSubClassOf (" CheckSameRegOperand" ))
315
342
return expandCheckSameRegOperand (OS, Rec->getValueAsInt (" FirstIndex" ),
0 commit comments