llvm-6502/lib/MC
Bill Schmidt 57ac1f458a This patch implements the general dynamic TLS model for 64-bit PowerPC.
Given a thread-local symbol x with global-dynamic access, the generated
code to obtain x's address is:

     Instruction                            Relocation            Symbol
  addis ra,r2,x@got@tlsgd@ha           R_PPC64_GOT_TLSGD16_HA       x
  addi  r3,ra,x@got@tlsgd@l            R_PPC64_GOT_TLSGD16_L        x
  bl __tls_get_addr(x@tlsgd)           R_PPC64_TLSGD                x
                                       R_PPC64_REL24           __tls_get_addr
  nop
  <use address in r3>

The implementation borrows from the medium code model work for introducing
special forms of ADDIS and ADDI into the DAG representation.  This is made
slightly more complicated by having to introduce a call to the external
function __tls_get_addr.  Using the full call machinery is overkill and,
more importantly, makes it difficult to add a special relocation.  So I've
introduced another opcode GET_TLS_ADDR to represent the function call, and
surrounded it with register copies to set up the parameter and return value.

Most of the code is pretty straightforward.  I ran into one peculiarity
when I introduced a new PPC opcode BL8_NOP_ELF_TLSGD, which is just like
BL8_NOP_ELF except that it takes another parameter to represent the symbol
("x" above) that requires a relocation on the call.  Something in the 
TblGen machinery causes BL8_NOP_ELF and BL8_NOP_ELF_TLSGD to be treated
identically during the emit phase, so this second operand was never
visited to generate relocations.  This is the reason for the slightly
messy workaround in PPCMCCodeEmitter.cpp:getDirectBrEncoding().

Two new tests are included to demonstrate correct external assembly and
correct generation of relocations using the integrated assembler.

Comments welcome!

Thanks,
Bill


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169910 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-11 20:30:11 +00:00
..
MCDisassembler Add C API for specifying CPU to the disassembler. 2012-12-07 23:53:27 +00:00
MCParser Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
CMakeLists.txt Give MCRegisterInfo an implementation file. 2012-07-27 16:25:20 +00:00
ELFObjectWriter.cpp Make the contents of encoded sections SmallVector<char, N> instead of 2012-12-07 22:06:56 +00:00
LLVMBuild.txt LLVMBuild: Introduce a common section which currently has a list of the 2011-12-12 22:45:54 +00:00
MachObjectWriter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
Makefile
MCAsmBackend.cpp MachO: direct-to-object attribute for data-in-code markers. 2012-10-01 22:20:54 +00:00
MCAsmInfo.cpp Fix alignment of .comm and .lcomm on mingw32. 2012-09-07 21:08:01 +00:00
MCAsmInfoCOFF.cpp Fix alignment of .comm and .lcomm on mingw32. 2012-09-07 21:08:01 +00:00
MCAsmInfoDarwin.cpp Fix alignment of .comm and .lcomm on mingw32. 2012-09-07 21:08:01 +00:00
MCAsmStreamer.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCAssembler.cpp Remove the RelaxAll overrule in MCAssembler::fixupNeedsRelaxation, 2012-12-11 17:16:00 +00:00
MCAtom.cpp
MCCodeEmitter.cpp
MCCodeGenInfo.cpp
MCContext.cpp fixed valgrind issues of prior commit, this change applies r169456 changes back to the tree with fixes. on darwin no valgrind issues exist in the tests that used to fail. 2012-12-06 22:12:44 +00:00
MCDisassembler.cpp
MCDwarf.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCELF.cpp Added Mapping Symbols for ARM ELF 2012-12-07 16:50:23 +00:00
MCELFObjectTargetWriter.cpp Initial TOC support for PowerPC64 object creation 2012-10-25 12:27:42 +00:00
MCELFStreamer.cpp Refactor MCInstFragment and MCDataFragment to adhere to a common interface, 2012-12-07 19:13:57 +00:00
MCExpr.cpp This patch implements the general dynamic TLS model for 64-bit PowerPC. 2012-12-11 20:30:11 +00:00
MCInst.cpp Release build: guard dump functions with 2012-09-12 05:06:18 +00:00
MCInstPrinter.cpp Try to unbreak the build on hosts that don't transitively pull in a definition for int64_t. 2012-12-05 18:31:11 +00:00
MCInstrAnalysis.cpp
MCLabel.cpp Release build: guard dump functions with 2012-09-12 05:06:18 +00:00
MCMachObjectTargetWriter.cpp
MCMachOStreamer.cpp Refactor MCInstFragment and MCDataFragment to adhere to a common interface, 2012-12-07 19:13:57 +00:00
MCModule.cpp
MCNullStreamer.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCObjectFileInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCObjectStreamer.cpp Refactor MCInstFragment and MCDataFragment to adhere to a common interface, 2012-12-07 19:13:57 +00:00
MCObjectWriter.cpp Move [SU]LEB128 encoding to a utility header. 2012-08-08 23:56:06 +00:00
MCPureStreamer.cpp Refactor MCInstFragment and MCDataFragment to adhere to a common interface, 2012-12-07 19:13:57 +00:00
MCRegisterInfo.cpp Add MCRI::getNumSubRegIndices() and start checking SubRegIndex ranges. 2012-09-11 16:34:02 +00:00
MCSection.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCSectionCOFF.cpp Tidy up. Trailing whitespace. 2012-05-11 01:41:30 +00:00
MCSectionELF.cpp Tidy up. Trailing whitespace. 2012-05-11 01:41:30 +00:00
MCSectionMachO.cpp
MCStreamer.cpp Defer call to InitSections until after MCContext has been initialized. If 2012-12-10 22:49:11 +00:00
MCSubtargetInfo.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
MCSymbol.cpp Fix Doxygen issues: 2012-09-14 14:57:36 +00:00
MCTargetAsmLexer.cpp
MCValue.cpp Release build: guard dump functions with 2012-09-12 05:06:18 +00:00
MCWin64EH.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
SubtargetFeature.cpp Symbol hygiene: Make sure declarations and definitions match, make helper functions static. 2012-10-20 12:53:26 +00:00
WinCOFFObjectWriter.cpp Use the new script to sort the includes of every file under lib. 2012-12-03 16:50:05 +00:00
WinCOFFStreamer.cpp Refactor MCInstFragment and MCDataFragment to adhere to a common interface, 2012-12-07 19:13:57 +00:00