The change implements lowering of get_fpenv, set_fpenv and
reset_fpenv. The lowering is based on the intrinsic arm_get_fpscr.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp | ||
---|---|---|
273 | Addr.getValueType() |
llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp | ||
---|---|---|
273 | Fixed. |
llvm/lib/Target/ARM/ARMISelLowering.cpp | ||
---|---|---|
6444–6472 ↗ | (On Diff #523051) | This could be done more simply by setting these nodes to Legal having tablegen patterns instead, e.g. def : Pat<(get_fpenv), (VMRS)>; def : Pat<(set_fpenv GPRnopc:$Rt), (VMSR GPRnopc:$Rt)>; def : Pat<(reset_fpenv), (VMSR 0)>; (though it requires get_fpenv etc. nodes being added to TargetSelectionDAG.td). |
llvm/lib/Target/ARM/ARMISelLowering.cpp | ||
---|---|---|
6444–6472 ↗ | (On Diff #523051) | Indeed, this is much better. |
The patch was reverted because it caused fail on a buildbot with expensive checks. It detected that vmsr does not allow immediate as a source. I am going to modify this commit:
diff --git a/llvm/lib/Target/ARM/ARMInstrVFP.td b/llvm/lib/Target/ARM/ARMInstrVFP.td index 7898972ee278..9b1224c7e1e3 100644 --- a/llvm/lib/Target/ARM/ARMInstrVFP.td +++ b/llvm/lib/Target/ARM/ARMInstrVFP.td @@ -2673,7 +2673,7 @@ def : Pat<(f32 (vfp_f32f16imm:$imm)), // Floating-point environment management. def : Pat<(get_fpenv), (VMRS)>; def : Pat<(set_fpenv GPRnopc:$Rt), (VMSR GPRnopc:$Rt)>; -def : Pat<(reset_fpenv), (VMSR 0)>; +def : Pat<(reset_fpenv), (VMSR (MOVi 0))>; //===----------------------------------------------------------------------===// // Assembler aliases. diff --git a/llvm/test/CodeGen/ARM/fpenv.ll b/llvm/test/CodeGen/ARM/fpenv.ll index f5c6a9608bac..40db627ebb3c 100644 --- a/llvm/test/CodeGen/ARM/fpenv.ll +++ b/llvm/test/CodeGen/ARM/fpenv.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -mtriple=arm-eabi -float-abi=soft -mattr=+vfp2 %s -o - | FileCheck %s +; RUN: llc -mtriple=arm-eabi -float-abi=soft -mattr=+vfp2 --verify-machineinstrs %s -o - | FileCheck %s define void @func_02(i32 %rm) { ; CHECK-LABEL: func_02: @@ -134,7 +134,8 @@ entry: define void @reset_fpenv_02() nounwind { ; CHECK-LABEL: reset_fpenv_02: ; CHECK: @ %bb.0: @ %entry -; CHECK-NEXT: vmsr fpscr, #0 +; CHECK-NEXT: mov r0, #0 +; CHECK-NEXT: vmsr fpscr, r0 ; CHECK-NEXT: mov pc, lr entry: call void @llvm.reset.fpenv()
If there are no objections, I will commit the modified patch.
That would cause an invalid instruction to be emitted when compiling for thumb. I think you need one pattern using MOVi marked with Requires<[IsARM]>, and another using tMOVi8 marked with Requires<[IsThumb]>.
Thank you for advice! Now the problem place looks like:
--- a/llvm/lib/Target/ARM/ARMInstrVFP.td +++ b/llvm/lib/Target/ARM/ARMInstrVFP.td @@ -2673,7 +2673,8 @@ def : Pat<(f32 (vfp_f32f16imm:$imm)), // Floating-point environment management. def : Pat<(get_fpenv), (VMRS)>; def : Pat<(set_fpenv GPRnopc:$Rt), (VMSR GPRnopc:$Rt)>; -def : Pat<(reset_fpenv), (VMSR 0)>; +def : Pat<(reset_fpenv), (VMSR (MOVi 0))>, Requires<[IsARM]>; +def : Pat<(reset_fpenv), (VMSR (tMOVi8 0))>, Requires<[IsThumb]>;
Addr.getValueType()