Skip to content

Commit 3c5d03a

Browse files
committed
SystemZMCCodeEmitter: Standardize how fixups are appended
This helper will facilitate future fixup data structure optimizations.
1 parent 637a382 commit 3c5d03a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCCodeEmitter.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ class SystemZMCCodeEmitter : public MCCodeEmitter {
129129
};
130130

131131
} // end anonymous namespace
132+
//
133+
static void addFixup(SmallVectorImpl<MCFixup> &Fixups, uint32_t Offset,
134+
const MCExpr *Value, uint16_t Kind, bool PCRel = false) {
135+
Fixups.push_back(MCFixup::create(Offset, Value, Kind, PCRel));
136+
}
132137

133138
void SystemZMCCodeEmitter::encodeInstruction(const MCInst &MI,
134139
SmallVectorImpl<char> &CB,
@@ -170,8 +175,7 @@ uint64_t SystemZMCCodeEmitter::getImmOpValue(const MCInst &MI, unsigned OpNum,
170175
unsigned OpBitSize =
171176
SystemZ::MCFixupKindInfos[Kind - FirstTargetFixupKind].TargetSize;
172177
uint32_t BitOffset = MIBitSize - RawBitOffset - OpBitSize;
173-
Fixups.push_back(
174-
MCFixup::create(BitOffset >> 3, MO.getExpr(), (MCFixupKind)Kind));
178+
addFixup(Fixups, BitOffset >> 3, MO.getExpr(), Kind);
175179
return 0;
176180
}
177181
llvm_unreachable("Unexpected operand type!");
@@ -206,13 +210,12 @@ SystemZMCCodeEmitter::getPCRelEncoding(const MCInst &MI, unsigned OpNum,
206210
Expr = MCBinaryExpr::createAdd(Expr, OffsetExpr, Ctx, Loc);
207211
}
208212
}
209-
Fixups.push_back(MCFixup::create(Offset, Expr, Kind, true));
213+
addFixup(Fixups, Offset, Expr, Kind, true);
210214

211215
// Output the fixup for the TLS marker if present.
212216
if (AllowTLS && OpNum + 1 < MI.getNumOperands()) {
213217
const MCOperand &MOTLS = MI.getOperand(OpNum + 1);
214-
Fixups.push_back(MCFixup::create(0, MOTLS.getExpr(),
215-
(MCFixupKind)SystemZ::FK_390_TLS_CALL));
218+
addFixup(Fixups, 0, MOTLS.getExpr(), SystemZ::FK_390_TLS_CALL);
216219
}
217220
return 0;
218221
}

0 commit comments

Comments
 (0)