mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
[PowerPC] Rework TLS call operand processing
As part of the global-dynamic and local-dynamic TLS sequences, we need to use a special form of the call instruction: bl __tls_get_addr(sym@tlsld) bl __tls_get_addr(sym@tlsgd) which generates two fixups. The current implementation of this causes problems with recognizing this form in the asm parser. To fix this, this patch reworks operand processing for this special form by using a single operand to hold both __tls_get_addr and sym@tlsld and defining a print method to output the above form, and an encoding method to generate the two fixups. As a side simplification, the patch replaces the two instruction patterns BL8_NOP_TLSGD and BL8_NOP_TLSLD by a single BL8_NOP_TLS, since the patterns already operate in an identical fashion (whether we have a local-dynamic or global-dynamic symbol is already encoded in the symbol modifier). No change in code generation intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185477 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -60,6 +60,8 @@ public:
|
||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||
unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
|
||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||
unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
|
||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||
unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
|
||||
SmallVectorImpl<MCFixup> &Fixups) const;
|
||||
|
||||
@@ -80,7 +82,7 @@ public:
|
||||
unsigned Size = 4; // FIXME: Have Desc.getSize() return the correct value!
|
||||
unsigned Opcode = MI.getOpcode();
|
||||
if (Opcode == PPC::BL8_NOP || Opcode == PPC::BLA8_NOP ||
|
||||
Opcode == PPC::BL8_NOP_TLSGD || Opcode == PPC::BL8_NOP_TLSLD)
|
||||
Opcode == PPC::BL8_NOP_TLS)
|
||||
Size = 8;
|
||||
|
||||
// Output the constant in big endian byte order.
|
||||
@@ -113,17 +115,6 @@ getDirectBrEncoding(const MCInst &MI, unsigned OpNo,
|
||||
// Add a fixup for the branch target.
|
||||
Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
|
||||
(MCFixupKind)PPC::fixup_ppc_br24));
|
||||
|
||||
// For special TLS calls, add another fixup for the symbol. Apparently
|
||||
// BL8_NOP, BL8_NOP_TLSGD, and BL8_NOP_TLSLD are sufficiently
|
||||
// similar that TblGen will not generate a separate case for the latter
|
||||
// two, so this is the only way to get the extra fixup generated.
|
||||
unsigned Opcode = MI.getOpcode();
|
||||
if (Opcode == PPC::BL8_NOP_TLSGD || Opcode == PPC::BL8_NOP_TLSLD) {
|
||||
const MCOperand &MO2 = MI.getOperand(OpNo+1);
|
||||
Fixups.push_back(MCFixup::Create(0, MO2.getExpr(),
|
||||
(MCFixupKind)PPC::fixup_ppc_nofixup));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -222,6 +213,17 @@ unsigned PPCMCCodeEmitter::getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
|
||||
return CTX.getRegisterInfo()->getEncodingValue(PPC::X13);
|
||||
}
|
||||
|
||||
unsigned PPCMCCodeEmitter::getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
|
||||
SmallVectorImpl<MCFixup> &Fixups) const {
|
||||
// For special TLS calls, we need two fixups; one for the branch target
|
||||
// (__tls_get_addr), which we create via getDirectBrEncoding as usual,
|
||||
// and one for the TLSGD or TLSLD symbol, which is emitted here.
|
||||
const MCOperand &MO = MI.getOperand(OpNo+1);
|
||||
Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
|
||||
(MCFixupKind)PPC::fixup_ppc_nofixup));
|
||||
return getDirectBrEncoding(MI, OpNo, Fixups);
|
||||
}
|
||||
|
||||
unsigned PPCMCCodeEmitter::
|
||||
get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
|
||||
SmallVectorImpl<MCFixup> &Fixups) const {
|
||||
|
Reference in New Issue
Block a user