@@ -59,18 +59,19 @@ MipsCOFFMCAsmInfo::MipsCOFFMCAsmInfo() {
59
59
AllowAtInName = true ;
60
60
}
61
61
62
- void MipsMCExpr::printImpl (raw_ostream &OS, const MCAsmInfo *MAI) const {
62
+ static void printImpl (const MCAsmInfo &MAI, raw_ostream &OS,
63
+ const MCSpecifierExpr &Expr) {
63
64
int64_t AbsVal;
64
65
65
- switch (specifier ) {
66
+ switch (Expr. getSpecifier () ) {
66
67
case Mips::S_None:
67
68
case Mips::S_Special:
68
69
llvm_unreachable (" Mips::S_None and MEK_Special are invalid" );
69
70
break ;
70
71
case Mips::S_DTPREL:
71
72
// Mips::S_DTPREL is used for marking TLS DIEExpr only
72
73
// and contains a regular sub-expression.
73
- MAI-> printExpr (OS, *getSubExpr ());
74
+ MAI. printExpr (OS, *Expr. getSubExpr ());
74
75
return ;
75
76
case Mips::S_CALL_HI16:
76
77
OS << " %call_hi" ;
@@ -147,20 +148,20 @@ void MipsMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
147
148
}
148
149
149
150
OS << ' (' ;
150
- if (Expr-> evaluateAsAbsolute (AbsVal))
151
+ if (Expr. evaluateAsAbsolute (AbsVal))
151
152
OS << AbsVal;
152
153
else
153
- Expr-> print (OS, MAI );
154
+ MAI. printExpr (OS, *Expr. getSubExpr () );
154
155
OS << ' )' ;
155
156
}
156
157
157
- bool MipsMCExpr ::isGpOff (Specifier &S) const {
158
- if (getSpecifier () == Mips::S_HI || getSpecifier () == Mips::S_LO) {
159
- if (const MipsMCExpr *S1 = dyn_cast<const MipsMCExpr>(getSubExpr ())) {
158
+ bool Mips ::isGpOff (const MCSpecifierExpr &E) {
159
+ if (E. getSpecifier () == Mips::S_HI || E. getSpecifier () == Mips::S_LO) {
160
+ if (const MipsMCExpr *S1 = dyn_cast<const MipsMCExpr>(E. getSubExpr ())) {
160
161
if (const MipsMCExpr *S2 = dyn_cast<const MipsMCExpr>(S1->getSubExpr ())) {
161
162
if (S1->getSpecifier () == Mips::S_NEG &&
162
163
S2->getSpecifier () == Mips::S_GPREL) {
163
- S = getSpecifier ();
164
+ // S = E. getSpecifier();
164
165
return true ;
165
166
}
166
167
}
@@ -169,13 +170,13 @@ bool MipsMCExpr::isGpOff(Specifier &S) const {
169
170
return false ;
170
171
}
171
172
172
- bool MipsMCExpr::evaluateAsRelocatableImpl ( MCValue &Res,
173
- const MCAssembler *Asm) const {
173
+ static bool evaluate ( const MCSpecifierExpr &Expr, MCValue &Res,
174
+ const MCAssembler *Asm) {
174
175
// Look for the %hi(%neg(%gp_rel(X))) and %lo(%neg(%gp_rel(X)))
175
176
// special cases.
176
- if (isGpOff ()) {
177
+ if (Mips:: isGpOff (Expr )) {
177
178
const MCExpr *SubExpr =
178
- cast<MipsMCExpr>(cast<MipsMCExpr>(getSubExpr ())->getSubExpr ())
179
+ cast<MipsMCExpr>(cast<MipsMCExpr>(Expr. getSubExpr ())->getSubExpr ())
179
180
->getSubExpr ();
180
181
if (!SubExpr->evaluateAsRelocatable (Res, Asm))
181
182
return false ;
@@ -184,8 +185,29 @@ bool MipsMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
184
185
return true ;
185
186
}
186
187
187
- if (!getSubExpr ()->evaluateAsRelocatable (Res, Asm))
188
+ if (!Expr. getSubExpr ()->evaluateAsRelocatable (Res, Asm))
188
189
return false ;
189
- Res.setSpecifier (specifier );
190
+ Res.setSpecifier (Expr. getSpecifier () );
190
191
return !Res.getSubSym ();
191
192
}
193
+
194
+ void MipsELFMCAsmInfo::printSpecifierExpr (raw_ostream &OS,
195
+ const MCSpecifierExpr &Expr) const {
196
+ printImpl (*this , OS, Expr);
197
+ }
198
+
199
+ bool MipsELFMCAsmInfo::evaluateAsRelocatableImpl (const MCSpecifierExpr &Expr,
200
+ MCValue &Res,
201
+ const MCAssembler *Asm) const {
202
+ return evaluate (Expr, Res, Asm);
203
+ }
204
+
205
+ void MipsCOFFMCAsmInfo::printSpecifierExpr (raw_ostream &OS,
206
+ const MCSpecifierExpr &Expr) const {
207
+ printImpl (*this , OS, Expr);
208
+ }
209
+
210
+ bool MipsCOFFMCAsmInfo::evaluateAsRelocatableImpl (
211
+ const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const {
212
+ return evaluate (Expr, Res, Asm);
213
+ }
0 commit comments