CPUStringIsValid() into MCSubtargetInfo and use it for ARM .cpu parsing

Hi Divacky,

I have an armv7 variant that supports hardware division (extension).

For my variant, I use “.cpu cortex-a9” and division attribute(.eabi_attribute 44, 2 @ Tag_DIV_use) to let the assembler do the right thing if it encounters a division instruction.

With your path, the .cpu directive is used to fetch the available features of a CPU and ignores the eabi attributes.

What should be the approach to fix the issue which I am facing ?

Shouldn’t the eabi attributes be honored ?

–Sumanth G

Hi Sumanth,

Shouldn’t the eabi attributes be honored ?

EABI attributes are instructions for the linker on which object files
are compatible with each other, not instructions for the assembler
(and trying to make them so sounds like a recipe for confusion to me).

From the ARM ABI addenda:

"Build attributes record data that a linker needs to reason
mechanically about the compatibility, or incompatibility, of a set of
relocatable files."

What should be the approach to fix the issue which I am facing?

There are a few options here:
1. Specify an existing CPU that has hardware division (notably,
Cortex-A9 doesn't).
2. Teach LLVM & Clang about your CPU's features, either locally or upstream.
3. Pass "-mhwdiv=arm,thumb" to Clang (or less if you only have hwdiv
in one mode).

Cheers.

Tim.

Tim,
       How about the below option ?

1. Specify an existing generic armv7 CPU or the CPU which is close my custom variant. My custom variant can be treated as "cortex-a9" + hwdiv.
    So my CPU here is "cortex-a9"
2. Specify the ".arch_extension idiv" which is available as an extension for my custom variant.
3. Teach LLVM & Clang about your CPU's features, either locally or upstream.
4. Pass "-mhwdiv=arm,thumb" to Clang (or less if you only have hwdiv in one mode).

--Sumanth G

How about the below option ?

My options were mutually exclusive, or at least any one of them would
allow you to assemble code using sdiv/udiv. You probably don't need to
combine them.

1. Specify an existing generic armv7 CPU or the CPU which is close my custom variant. My custom variant can be treated as "cortex-a9" + hwdiv. So my CPU here is "cortex-a9"
2. Specify the ".arch_extension idiv" which is available as an extension for my custom variant.

This looks like it'd be sufficient (and I didn't know about
.arch_extension at all, or I'd have mentioned it. Thanks!).

3. Teach LLVM & Clang about your CPU's features, either locally or upstream.
4. Pass "-mhwdiv=arm,thumb" to Clang (or less if you only have hwdiv in one mode).

These ought to be unneeded if you do 1+2 above.

Cheers.

Tim.

As far as I remember, .arch_extension does change the assembler flags
to support whatever you set. Have you tried that?

cheers,
--renato

I have tried ".arch_extension" and it works perfectly fine for me.
I will move ahead and add the arch_extension framework to ARM.

Thanks for your guidance guys.
--Sumanth G

I have pushed the patch here: http://reviews.llvm.org/D7316
Review it and let me know.

--Sumanth G

Renato agreed to the patch.
Patch http://reviews.llvm.org/D7316
Waiting for an "approved" bit.
It has been there for three days idle.