llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.47k stars 11.77k forks source link

Assembly instructions "adrl, cpy, vmrs, vmsr" don't supported by Clang #41927

Open 44128753-b9b6-4faf-984b-690a6ca556cf opened 5 years ago

44128753-b9b6-4faf-984b-690a6ca556cf commented 5 years ago
Bugzilla Link 42582
Version 8.0
OS Linux
Attachments Test to reproduce situation
CC @P1119r1m,@zygoloid,@TNorthover

Extended Description

Assembly instructions "adrl, cpy, vmrs, vmsr" don't supported by Clang. At the same time, they are supported by GCC.

Environment information: OS: Ubuntu 16.04.5 LTS GCC: arm-linux-gnueabihf-gcc (Linaro GCC 6.2-2016.11) 6.2.1 20161016 CLANG: clang version 8.0.0 (tags/RELEASE_800/final)

Usecase is attached to this report. Also it is duplicated below in this text:

adrl_cpy_vmrs_vmsr.s

add:
adrl r0, add
cpy r0, r1
VMRS r2,FPEXC
VMSR FPEXC,r2

adrl_cpy_vmrs_vmsr.sh

#!/bin/bash

COMPILER_GCC=/opt/toolchains/aarch32/bin/arm-linux-gnueabihf-gcc
COMPILER_CLANG=opt/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/arm-funnyos-gnueabi-clang

i=adrl_cpy_vmrs_vmsr;

echo "======================================================================"
echo "Building by GCC";
echo "======================================================================"
${COMPILER_GCC} -c $i.s;
RESULT=$?
echo "----------------------------------------------------------------------"
echo "Build result: $RESULT";
echo "----------------------------------------------------------------------"
echo "";
echo "";

echo "======================================================================"
echo "Building by CLANG";
echo "======================================================================"
${COMPILER_CLANG} -c $i.s;
RESULT=$?
echo "----------------------------------------------------------------------"
echo "Build result: $RESULT";
echo "----------------------------------------------------------------------"
echo "";
echo "";

Result of "adrl_cpy_vmrs_vmsr.sh" execution:

$ ./adrl_cpy_vmrs_vmsr.sh 
======================================================================
Building by GCC
======================================================================
----------------------------------------------------------------------
Build result: 0
----------------------------------------------------------------------

======================================================================
Building by CLANG
======================================================================
adrl_cpy_vmrs_vmsr.s:2:1: error: invalid instruction, did you mean: adr?
adrl r0, add
^
adrl_cpy_vmrs_vmsr.s:3:1: error: invalid instruction, did you mean: cdp, cmp, cps?
cpy r0, r1
^
adrl_cpy_vmrs_vmsr.s:4:1: error: instruction requires: VFP2
VMRS r2,FPEXC
^
adrl_cpy_vmrs_vmsr.s:5:1: error: instruction requires: VFP2
VMSR FPEXC,r2
^
----------------------------------------------------------------------
Build result: 1
----------------------------------------------------------------------
44128753-b9b6-4faf-984b-690a6ca556cf commented 5 years ago

It's a pity...

TNorthover commented 5 years ago

But how about adrl? Will it be implemented in the near future?

That seems unlikely, I'm afraid. I don't know of anyone who considers pseudos outside the official architecture reference a priority.

44128753-b9b6-4faf-984b-690a6ca556cf commented 5 years ago

Thank you! Sorry, it was my fault to not specifying right target or -mfpu!

I agree with your opinion about cpy.

But how about adrl? Will it be implemented in the near future?

TNorthover commented 5 years ago

VMRS and VMSR are giving an error because Clang defaults to an early CPU without an FPU for arm-linux-gnueabi. If you need them you should specify a CPU or architecture on the command-line (actually, you probably should anyway).

ADRL and CPY are non-standard pseudo-instructions. CPY is particularly pointless because it's just MOV under a different name. ADRL at least does something different. I doubt either will be a high priority, so you're probably better off changing the source.