35
35
36
36
namespace llvm {
37
37
38
+ static void addFixup (SmallVectorImpl<MCFixup> &Fixups, uint32_t Offset,
39
+ const MCExpr *Value, uint16_t Kind) {
40
+ bool PCRel = false ;
41
+ switch (Kind) {
42
+ case AVR::fixup_7_pcrel:
43
+ case AVR::fixup_13_pcrel:
44
+ PCRel = true ;
45
+ }
46
+ Fixups.push_back (MCFixup::create (Offset, Value, Kind, PCRel));
47
+ }
48
+
38
49
// / Performs a post-encoding step on a `LD` or `ST` instruction.
39
50
// /
40
51
// / The encoding of the LD/ST family of instructions is inconsistent w.r.t
@@ -110,7 +121,7 @@ AVRMCCodeEmitter::encodeRelCondBrTarget(const MCInst &MI, unsigned OpNo,
110
121
const MCOperand &MO = MI.getOperand (OpNo);
111
122
112
123
if (MO.isExpr ()) {
113
- Fixups. push_back ( MCFixup::create ( 0 , MO.getExpr (), MCFixupKind (Fixup) ));
124
+ addFixup (Fixups, 0 , MO.getExpr (), MCFixupKind (Fixup));
114
125
return 0 ;
115
126
}
116
127
@@ -155,8 +166,7 @@ unsigned AVRMCCodeEmitter::encodeMemri(const MCInst &MI, unsigned OpNo,
155
166
OffsetBits = OffsetOp.getImm ();
156
167
} else if (OffsetOp.isExpr ()) {
157
168
OffsetBits = 0 ;
158
- Fixups.push_back (
159
- MCFixup::create (0 , OffsetOp.getExpr (), MCFixupKind (AVR::fixup_6)));
169
+ addFixup (Fixups, 0 , OffsetOp.getExpr (), MCFixupKind (AVR::fixup_6));
160
170
} else {
161
171
llvm_unreachable (" Invalid value for offset" );
162
172
}
@@ -190,7 +200,7 @@ unsigned AVRMCCodeEmitter::encodeImm(const MCInst &MI, unsigned OpNo,
190
200
}
191
201
192
202
MCFixupKind FixupKind = static_cast <MCFixupKind>(Fixup);
193
- Fixups. push_back ( MCFixup::create ( Offset, MO.getExpr (), FixupKind) );
203
+ addFixup (Fixups, Offset, MO.getExpr (), FixupKind);
194
204
195
205
return 0 ;
196
206
}
@@ -206,7 +216,7 @@ unsigned AVRMCCodeEmitter::encodeCallTarget(const MCInst &MI, unsigned OpNo,
206
216
207
217
if (MO.isExpr ()) {
208
218
MCFixupKind FixupKind = static_cast <MCFixupKind>(AVR::fixup_call);
209
- Fixups. push_back ( MCFixup::create ( 0 , MO.getExpr (), FixupKind) );
219
+ addFixup (Fixups, 0 , MO.getExpr (), FixupKind);
210
220
return 0 ;
211
221
}
212
222
@@ -236,7 +246,7 @@ unsigned AVRMCCodeEmitter::getExprOpValue(const MCExpr *Expr,
236
246
}
237
247
238
248
MCFixupKind FixupKind = static_cast <MCFixupKind>(AVRExpr->getFixupKind ());
239
- Fixups. push_back ( MCFixup::create ( 0 , AVRExpr, FixupKind) );
249
+ addFixup (Fixups, 0 , AVRExpr, FixupKind);
240
250
return 0 ;
241
251
}
242
252
0 commit comments