Dear LLVM crew, I have been writing a new LLVM backend with a very simple instruction set. moving a constant value to a register is selected as a load of the constant, with a PC-relative positive offset. Thus, the constant should be stored in .text section, after the load instruction, and offset should be computed at compile time (not link time). I struggle to find out : - how llvm handle constant pool - where I should compute the offset (MCCodeEmitter ? MCInstLowering ? ... ?) ARM has a specific pass for this (ARMConstantIslandPass.cpp), but I wonder if such a processing is really needed, at least for simple case (i.e. small enough offset). Handling this with relocations and linker-hacking seems odd, I'd prefer to avoid it. Thanks for you help, either with some advice on the implementation strategy, or with and example in an existing backend. -- Frederic Heitzmann
On Mon, Jun 29, 2015 at 01:00:14PM +0000, HEITZMANN Frédéric 218168 wrote:> Thus, the constant should be stored in .text section, after the load > instruction, and offset should be computed at compile time (not link time).The basic idea is to still create a relocation on the MC level, but fix it up later. You didn't say if your ISA is fixed or variable length, the former, can simplify this quite bit. The constant island pass generally tries to address two issues: (1) Merging of identical constants. (2) Splitting the constant island if the function gets too large. Joerg
> De : Joerg Sonnenberger [mailto:joerg at britannica.bec.de] > > The basic idea is to still create a relocation on the MC level, but fix it up later. > You didn't say if your ISA is fixed or variable length, the former, can simplify > this quite bit. The constant island pass generally tries to address two issues: > (1) Merging of identical constants. > (2) Splitting the constant island if the function gets too large. > > JoergHi Joerg, ISA is actually fixed length. If I get it right, unless the function gets too big, I could at least have a suboptimal thus functional binary, without the constant island pass. Could you spot the hook(s) I should use add a relocation (or do you mean fixup ?) and where I should fix it ? -- Fred