This is an archive of the discontinued LLVM Phabricator instance.

[RISCV, WIP] Lower TLS addresses using localexec

Authored by lewis-revill on Dec 4 2018, 5:21 PM.



This patch adds lowering for an addressing sequence to access TLS symbols using the localexec model.

This required adding a four operand pseudo add instruction, which uses the fourth operand to express a relocation of the symbol. The instruction is expanded in RISCVMCCodeEmitter.cpp to a normal add, with the necessary fixup emitted. Parsing of the extra operand was also added to ensure that a normal add cannot have four operands and still parse correctly.

Depends on D55305

Diff Detail


Event Timeline

lewis-revill created this revision.Dec 4 2018, 5:21 PM
jrtc27 requested changes to this revision.Dec 4 2018, 7:15 PM

The general strategy of adding a pseudo-instruction seems fine; I checked what the Sparc backend does and it defines a tlsadd node with its extra %tie_add(sym) operand.


Pattern should be (add (add_tprel (lui %tprel_hi(sym)) tp %tprel_add(sym)) %tprel_lo(sym)) - you missed the %tprel_add operand to add_tprel.

This revision now requires changes to proceed.Dec 4 2018, 7:15 PM

I'm going to merge these changes into D55305 (followed by splitting up MC layer changes into separate patches).

lewis-revill marked an inline comment as done.Dec 5 2018, 10:11 AM
lewis-revill added inline comments.

I'll address this when I merge into D55305, thanks.

lewis-revill abandoned this revision.Dec 5 2018, 11:35 AM

Merged into D55305