<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - builtins for ARM M4f (armv7e-m) incorrectly use double precision floating point instructions"
   href="https://bugs.llvm.org/show_bug.cgi?id=42838">42838</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>builtins for ARM M4f (armv7e-m) incorrectly use double precision floating point instructions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>builtins
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>pu.y@delley.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Compiling compiler-rt for ARM M4f (armv7e-m) fails with the following error in
a number of assembly files: "error: instruction requires: double precision
VFP". The source-code suggests that compiler-rt uses the builtin
implementations targeting the VFPv2 instruction set for both armv7-m and
armv7e-m. According to the ARMv7-M Architecture Reference Manual
(<a href="https://static.docs.arm.com/ddi0403/eb/DDI0403E_B_armv7m_arm.pdf">https://static.docs.arm.com/ddi0403/eb/DDI0403E_B_armv7m_arm.pdf</a>, page 22),
armv7(e)-m effectively supports three different floating point extensions,
FPv4-SP, FPv5-SP and FPv5, where only the last one supports double precision
floating point. The other two are single-precision only restrictions of the
VFPv4 and VFPv5 equivalents of the ARM -A and -R profile instructions. M4f
implement FPv4-SP and M7f (typically?) implement FPv5. 

The CMake invocation that was tested (LLVM 9.0.0rc1, out-of-tree build,
LLVM/Clang previously compiled with default target triple "armv7em-none-eabi")
is as follows:

```bash

XTARGET=armv7em-none-eabi
XCPU=cortex-m4
XCPUDIR=cortex-m4f
XFPU="-mfloat-abi=hard -mfpu=fpv4-sp-d16"
XABI="-mthumb -mabi=aapcs"

XOPTFLAGS="-g -O2 -fomit-frame-pointer -fdata-sections -ffunction-sections"

CXX_FLAGS="--target=${XTARGET} -mcpu=${XCPU} ${XFPU} ${XABI} ${XOPTFLAGS}"
CXX_DEFINES=""
CXX_INCLUDE_PATH=""

COMPILER_FLAGS="${CXX_FLAGS} ${CXX_DEFINES} ${CXX_INCLUDE_PATH}"

cmake -GNinja -Wno-dev \
   -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
   -DCMAKE_SYSTEM_PROCESSOR=arm \
   -DCMAKE_SYSTEM_NAME=Generic \
   -DCMAKE_CROSSCOMPILING=ON \
   -DUNIX=1 \
   -DCMAKE_CXX_COMPILER_FORCED=TRUE \
   -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
   -DCMAKE_BUILD_TYPE=Release \
   -DCMAKE_C_COMPILER_TARGET=${XTARGET} \
   -DCMAKE_ASM_COMPILER_TARGET=${XTARGET} \
   -DCMAKE_C_COMPILER=${INSTALL_PREFIX}/bin/clang \
   -DCMAKE_CXX_COMPILER=${INSTALL_PREFIX}/bin/clang++ \
   -DCMAKE_LINKER=${INSTALL_PREFIX}/bin/clang \
   -DCMAKE_AR=${INSTALL_PREFIX}/bin/llvm-ar \
   -DCMAKE_RANLIB=${INSTALL_PREFIX}/bin/llvm-ranlib \
   -DLLVM_CONFIG_PATH=${BUILD_ROOT}/llvm/bin/llvm-config \
    -DLLVM_ENABLE_SPHINX=False \
    -DLLVM_INCLUDE_TESTS=False \
    -DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS \
    -DLLVM_TARGETS_TO_BUILD="ARM" \
    -DLLVM_DEFAULT_TARGET_TRIPLE="armv7em-none-eabi" \
    -DLLVM_ENABLE_LLD=ON \
    -DLLVM_ENABLE_LIBCXX=ON \
   -DCMAKE_SYSROOT=${SYSROOT} \
   -DCMAKE_SYSROOT_LINK=${SYSROOT} \
   -DCMAKE_C_FLAGS="${COMPILER_FLAGS}" \
   -DCMAKE_ASM_FLAGS="${COMPILER_FLAGS}" \
   -DCMAKE_CXX_FLAGS="${COMPILER_FLAGS}" \
   -DCMAKE_EXE_LINKER_FLAGS=-L${SYSROOT}/lib \
   -DCOMPILER_RT_OS_DIR="baremetal" \
   -DCOMPILER_RT_BUILD_BUILTINS=ON \
   -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
   -DCOMPILER_RT_BUILD_XRAY=OFF \
   -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
   -DCOMPILER_RT_BUILD_PROFILE=OFF \
   -DCOMPILER_RT_BAREMETAL_BUILD=ON \
   -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
   -DCOMPILER_RT_INCLUDE_TESTS=OFF \
   -DCOMPILER_RT_USE_LIBCXX=ON \
    ${LLVM_PROJECT_SRC_ROOT}/compiler-rt

```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>