How to specify the subtarget instruction set for LLVM unit in ARM-backend?

Dear developers!

I’d like to ask you a question concerning the implementation of one algorithm for the generation of energy-efficient code for ARM processors. Unfortunately, the documentation on this subject is incomplete on your site, so could you please explain how to implement my algorithm.

Without going into details, I would like to say, that the implementation of this algorithm requires the ability to specify the subtarget instruction set (ARM or Thumb) for a particular instruction LLVM intermediate representation. If at this stage of development, your compiler does not support this feature, please specify the minimal unit (basic block, entire function or anything else) that the current version of the compiler is able to translate with an indication of the subtarget instruction set.

Also, I wonder whether an LLVM pass can be added to the ARM-backend (if so, please explain how).

Best regards,

Leonid.

Hello

compiler does not support this feature, please specify the minimal unit
(basic block, entire function or anything else) that the current version
of the compiler is able to translate with an indication of the subtarget
instruction set.

Subtarget features are specified on per-module basis. It might be good to allow
certain features to be applied on per-function level. Patches are welcome :slight_smile:

Also, I wonder whether an LLVM pass can be added to the ARM-backend (if
so, please explain how).

Yes, it is possible. There are plenty of examples in the current
codebase. See e.g.
lib/Target/ARM/ARMTargetMachine.cpp