Skip to content

ARv2: Incorrect Default CPU #25

@luismgsilva

Description

@luismgsilva

During the analysis of assembly test comparisons, several interesting observations have been made. It was previously assumed that the default CPU for ARCv2 (--target=arc) was ARCHS; however, this assumption turned out to be incorrect.

Presently, the default CPU for ARCv2 is hs38_linux CPU. This can be verified in the following GCC file: gcc/gcc/config/arc/arc.h.

# gcc/gcc/config/arc/arc.h

36     #ifndef TARGET_CPU_DEFAULT
37     #define TARGET_CPU_DEFAULT	PROCESSOR_hs38_linux
38     #endif

Although the default CPU being used is clearly hs38_linux, the information about the architecture in the generated ELF file indicates otherwise:

$ arc-elf32-readelf -A test.x
Attribute Section: ARC
File Attributes
  Tag_ARC_PCS_config: Bare metal/newlib
  Tag_ARC_CPU_base: ARCHS
  Tag_ARC_CPU_variation: Core2
  Tag_ARC_CPU_name: "archs"
  Tag_ARC_ABI_osver: v4
  Tag_ARC_ABI_sda: GNU
  Tag_ARC_ISA_config: "BITSCAN,CD,DIV_REM,FPUD,LL64,BS,SWAP"
  Tag_ARC_ISA_mpy_option: 9
  Tag_ARC_ATR_version: 1

According to the information provided by Binutils, the CPU mentioned is archs, which does not align with the actual default CPU. This discrepancy seems to be a mismatch in the information generated by Binutils.

Furthermore, there are additional discrepancies in the configuration itself. One notable difference is the behavior of the toolchain build when no CPU is specified. In this case, the FPUD (Floating-Point Unit) is enabled by default. Additionally, the Tag_ARC_ISA_mpy_option attribute is set to 9, whereas it is set to 6 when --with-cpu=archs is provided.

Please refer to the following comparisons for better understanding:

Attribute Name Default CPU Value ARCHS CPU Value
Tag_ARC_PCS_config Bare metal/newlib Bare metal/newlib
Tag_ARC_CPU_base ARCHS ARCHS
Tag_ARC_CPU_variation Core2 Core2
Tag_ARC_CPU_name "archs" "archs"
Tag_ARC_ABI_osver v4 v4
Tag_ARC_ABI_sda GNU GNU
Tag_ARC_ISA_config "BITSCAN,CD,DIV_REM,FPUD,LL64,BS,SWAP" "BITSCAN,CD,DIV_REM,LL64,BS,SWAP"
Tag_ARC_ISA_mpy_option 9 6
Tag_ARC_ATR_version 1 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions