Instruction dependency in ARM backend

Hi

I’m working on a POC adding Windows Phone (ARM) support to the ARM backend.

I’ve encountered the following problem.

Microsoft’s COFF linker/loader supports a single relocation type (IMAGE_REL_ARM_MOV32T) on continuous movw/movt Thumb2 instructions opposed to ELF and Mach-O which support relocation per instruction (one for movw and movt).

I need to make sure that in case of immediate operands which needs fix-up for these instructions they will grouped together with no other instruction inserted between them. Also they need to be emitted in the correct order.

What should be the right approach to implement this?

Is this something I can describe in target description for ARM?

thx
pM0n

Hello

What should be the right approach to implement this?

You definitely can glue them together. Alternatively, you can disable
the generation of movt / movw instruction pairs at all. The latter
probably looks the better solution give the target weirdness :slight_smile:

Is this something I can describe in target description for ARM?

If you mean .td files, then no. movt / movw pairs is inserted via
"pseudo instruction expansion pass". Look into
ARMExpandPseudoInsts.cpp

You definitely can glue them together.
Do you mean instruction bundling?

I see that sometimes (I guess) some optimization does insert other instructions between movw+movt pair. Is there a flag to say “don’t touch them”?