[LoongArch] Added spill/reload/copy support for CFRs
authorwanglei <wanglei@loongson.cn>
Thu, 10 Nov 2022 11:56:36 +0000 (19:56 +0800)
committerwanglei <wanglei@loongson.cn>
Thu, 10 Nov 2022 12:12:18 +0000 (20:12 +0800)
commit7d5c8cb023515efd1d80a9120f27ed5cdb1d1404
treea10178ef866e66d237fe4b2717a81bb0a6c9455a
parentde4364f1ecaa6a5d631cff036b8f31e02841e73d
[LoongArch] Added spill/reload/copy support for CFRs

1, spill/reload
When a function call is made immediately after a floating point
comparison, the result of the comparison needs to be spilled before
function call and reloaded after the function returns.

2, copy
Support `GPR` to `CFR` and `CFR` to `GRP` copys. Therefore, the correct
register class can be used in the pattern template, and the hard-coding
of mutual coping of `CFR` and `GRP` is eliminated, reducing redundant
comparison instructions.

Note: Since the `COPY` instruction between CFRs is not provided in
LoongArch, we only use `$fcc0` in the register allocation.

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137004
llvm/lib/Target/LoongArch/LoongArchFloat32InstrInfo.td
llvm/lib/Target/LoongArch/LoongArchFloat64InstrInfo.td
llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
llvm/lib/Target/LoongArch/LoongArchRegisterInfo.cpp
llvm/test/CodeGen/LoongArch/ir-instruction/fcmp-dbl.ll
llvm/test/CodeGen/LoongArch/ir-instruction/fcmp-flt.ll
llvm/test/CodeGen/LoongArch/ir-instruction/float-convert.ll
llvm/test/CodeGen/LoongArch/spill-reload-cfr.ll [new file with mode: 0644]