This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Remove AssemblerPredicate for features: f/d/lsx/lasx/lvz/lbt
ClosedPublic

Authored by SixWeining on May 9 2023, 6:08 AM.

Details

Summary

Linux LoongArch port [1] uses -msoft-float (implies no FPU) in its
cflags while it also uses floating-point insns in asm sources [2].
GAS allows this usage while IAS currently does not.

This patch removes AssemblerPredicates for floating-point insns so
that to make IAS compitable with GAS. Similarly, also remove
AssemblerPredicates for other ISA extensions, i.e. lsx/las/lvz/lbt.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/Makefile?h=v6.4-rc1#n49
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/kernel/fpu.S?h=v6.4-rc1#n29

Diff Detail

Event Timeline

SixWeining created this revision.May 9 2023, 6:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2023, 6:08 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
SixWeining requested review of this revision.May 9 2023, 6:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2023, 6:08 AM
xry111 added a comment.May 9 2023, 6:38 AM

Hmm, I think it's a kernel issue and should be fixed by using -mabi=lp64s instead of -msoft-float for this specific file...

Hmm, I think it's a kernel issue and should be fixed by using -mabi=lp64s instead of -msoft-float for this specific file...

Makes sense. I'm not sure whether kernel‘s Makefile can distinguish .c and .S (or .c with floating-point insn inlineasm). I'll report this issue to Huacai tomorrow.

Seems there is another approach: add an assembler option to IAS called -mfpu=64/32/0/none.
Then kernel Makefile can be:

if LLVM == 1 && LLVM_IAS ==1
  cflags-y = -msolft-float -Wa,-mfpu=64
endif
xry111 added a comment.May 9 2023, 8:17 AM

Hmm, I think it's a kernel issue and should be fixed by using -mabi=lp64s instead of -msoft-float for this specific file...

Makes sense. I'm not sure whether kernel‘s Makefile can distinguish .c and .S (or .c with floating-point insn inlineasm). I'll report this issue to Huacai tomorrow.

AFAIK we just need

CFLAGS_fpu.o  = -mabi=lp64s
CFLAGS_REMOVE_fpu.o = -msoft-float

KBuild has a fine-grained control on CFLAGS for TUs.

Seems there is another approach: add an assembler option to IAS called -mfpu=64/32/0/none.
Then kernel Makefile can be:

if LLVM == 1 && LLVM_IAS ==1
  cflags-y = -msolft-float -Wa,-mfpu=64
endif

AFAIK we just need

CFLAGS_fpu.o  = -mabi=lp64s
CFLAGS_REMOVE_fpu.o = -msoft-float

KBuild has a fine-grained control on CFLAGS for TUs.

Looks great!

hev added a comment.May 9 2023, 8:31 AM

AFAIK we just need

CFLAGS_fpu.o  = -mabi=lp64s
CFLAGS_REMOVE_fpu.o = -msoft-float

Does this work for performing floating-point operations using inline assembly in C source files?

hev added a comment.Jun 7 2023, 8:34 AM

Just like in the Linux kernel, In bare-metal development with Rust, there is also need for compiling targets with software floating-point support to access the floating-point context through hardware floating-point instructions, potentially even within Rust's inline assembly. This should be one of the ways to address the problem.

Thanks.

hev accepted this revision.Jun 14 2023, 8:29 AM
This revision is now accepted and ready to land.Jun 14 2023, 8:29 AM
xen0n accepted this revision.Jun 21 2023, 8:30 PM
This revision was landed with ongoing or failed builds.Jun 25 2023, 7:38 PM
This revision was automatically updated to reflect the committed changes.
llvm/test/MC/LoongArch/Basic/Float/f-comp.s