Question about thumb2 define in clang for ARMv8

(Sorry if this is a double post, I sent this email a few days ago from an e-mail that’s not subscribed to the mailing list and it seems to be stuck in moderation).

Hi everyone,

tl;dr: GCC defines thumb2 in ARMv8 and clang doesn’t. Is that a bug? Is there a better way to check if thumb2 is supported? Maybe __ARM_ARCH_ISA_THUMB?

Hello,

This is likely down to the default triple and CPU that clang uses.

An arm-linux-gnueabihf-gcc defaults to Thumb architecture v7-A which supports Thumb2. Whereas clang defaults to Arm state and architecture v4t which does not support Thumb2.

On a relatively recent build of clang, but I think this goes back some way:

clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - < /dev/null | grep thumb

#define thumb2 1

#define thumb 1

Can you give that a try?

Peter

Hello,

My turn for the double post, my mail client stripped off the list on reply-all and I’d assumed it was llvm-dev. My apologies, resending back on cfe-dev

This is likely down to the default triple and CPU that clang uses.

An arm-linux-gnueabihf-gcc defaults to Thumb architecture v7-A which supports Thumb2. Whereas clang defaults to Arm state and architecture v4t which does not support Thumb2.

On a relatively recent build of clang, but I think this goes back some way:

clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - < /dev/null | grep thumb

#define thumb2 1

#define thumb 1

Can you give that a try?

Peter

Hello,

My turn for the double post, my mail client stripped off the list on reply-all and I’d assumed it was llvm-dev. My apologies, resending back on cfe-dev

This is likely down to the default triple and CPU that clang uses.

An arm-linux-gnueabihf-gcc defaults to Thumb architecture v7-A which supports Thumb2. Whereas clang defaults to Arm state and architecture v4t which does not support Thumb2.

On a relatively recent build of clang, but I think this goes back some way:

clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - < /dev/null | grep thumb

yeah -mthumb -march=armv7-a are key here.

Hi,

Hello,

My turn for the double post, my mail client stripped off the list on reply-all and I’d assumed it was llvm-dev. My apologies, resending back on cfe-dev

This is likely down to the default triple and CPU that clang uses.

An arm-linux-gnueabihf-gcc defaults to Thumb architecture v7-A which supports Thumb2. Whereas clang defaults to Arm state and architecture v4t which does not support Thumb2.

On a relatively recent build of clang, but I think this goes back some way:

clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - < /dev/null | grep thumb

#define thumb2 1

#define thumb 1

Can you give that a try?

Nice, it now defines them:

$ clang --target=arm-linux-gnueabihf -mthumb -march=armv7-a -dM -E - < /dev/null | grep thumb
#define thumb2 1
#define thumb 1

but does it mean that if I don’t pass these arguments clang won’t thumb2 code? Despite __ARM_ARCH_ISA_THUMB being set to 2?

Thank you

I believe thumb/thumb2 are defined based on what default mode you’re compiling for, and __ARM_ARCH_ISA_THUMB is defined based on what your processor supports. So:

-target=armv4t -marm: __ARM_ARCH_ISA_THUMB=1
-target=armv4t -mthumb: __ARM_ARCH_ISA_THUMB=1 thumb=1
-target=armv7 -marm: __ARM_ARCH_ISA_THUMB=2
-target=armv7 -mthumb: __ARM_ARCH_ISA_THUMB=2 thumb=1 thumb2=1

Jess