llvm-6502/include/llvm
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
..
ADT Mark ImmutableMap::remove/add() const. 2012-12-07 19:44:12 +00:00
Analysis Hoist the GEP constant address offset computation to a common home on 2012-12-11 10:29:10 +00:00
Assembly
Bitcode Have the bitcode reader/writer just use FPMathOperator's fast math enum directly 2012-12-09 20:23:16 +00:00
CodeGen Revert EVT->MVT changes, r169836-169851, due to buildbot failures. 2012-12-11 11:14:33 +00:00
Config
DebugInfo
ExecutionEngine
MC This patch implements the general dynamic TLS model for 64-bit PowerPC. 2012-12-11 20:30:11 +00:00
Object
Option Copy clang/Driver/<Option parsing stuff> to llvm. 2012-12-05 00:29:32 +00:00
Support This patch implements the general dynamic TLS model for 64-bit PowerPC. 2012-12-11 20:30:11 +00:00
TableGen
Target Revert EVT->MVT changes, r169836-169851, due to buildbot failures. 2012-12-11 11:14:33 +00:00
Transforms Use an ArrayRef instead of a std::vector&. 2012-12-11 16:36:02 +00:00
AddressingMode.h
Argument.h
Attributes.h s/AttrListPtr/AttributeSet/g to better label what this class is going to be in the near future. 2012-12-07 23:16:57 +00:00
AutoUpgrade.h
BasicBlock.h
CallGraphSCCPass.h
CallingConv.h
CMakeLists.txt
Constant.h
Constants.h
DataLayout.h
DebugInfo.h Handle non-default array bounds. 2012-12-06 07:38:10 +00:00
DefaultPasses.h
DerivedTypes.h
DIBuilder.h Use the 'count' attribute to calculate the upper bound of an array. 2012-12-04 21:34:03 +00:00
Function.h s/AttrListPtr/AttributeSet/g to better label what this class is going to be in the near future. 2012-12-07 23:16:57 +00:00
GlobalAlias.h
GlobalValue.h
GlobalVariable.h
GVMaterializer.h
InitializePasses.h
InlineAsm.h
InstrTypes.h
Instruction.def
Instruction.h Reorganize FastMathFlags to be a wrapper around unsigned, and streamline some interfaces. 2012-12-09 21:12:04 +00:00
Instructions.h Hoist the GEP constant address offset computation to a common home on 2012-12-11 10:29:10 +00:00
InstVisitor.h
IntrinsicInst.h
Intrinsics.h s/AttrListPtr/AttributeSet/g to better label what this class is going to be in the near future. 2012-12-07 23:16:57 +00:00
Intrinsics.td
IntrinsicsARM.td
IntrinsicsHexagon.td
IntrinsicsMips.td
IntrinsicsNVVM.td
IntrinsicsPowerPC.td
IntrinsicsX86.td
IntrinsicsXCore.td
IRBuilder.h
LinkAllPasses.h
LinkAllVMCore.h
Linker.h
LLVMContext.h
MDBuilder.h
Metadata.h
Module.h s/AttrListPtr/AttributeSet/g to better label what this class is going to be in the near future. 2012-12-07 23:16:57 +00:00
OperandTraits.h
Operator.h Holding my nose and moving the accumulation routine to GEPOperator 2012-12-11 11:05:15 +00:00
Pass.h
PassAnalysisSupport.h
PassManager.h
PassManagers.h
PassRegistry.h
PassSupport.h
SymbolTableListTraits.h
TargetTransformInfo.h LoopVectorize: support vectorizing intrinsic calls 2012-12-09 20:42:17 +00:00
Type.h
TypeBuilder.h
TypeFinder.h
Use.h
User.h
Value.h
ValueSymbolTable.h