[llvm] [RISCV] Implement foward inserting save/restore FRM instructions. (PR #77744)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 11 02:18:39 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff ce944597e43ae4f77260d4683f8d6535947fb0a2 61af743723a156fd0f1c24d8b36d3160b38080f8 -- llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp b/llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
index 4d574a588a..d97aee55cd 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
@@ -23,9 +23,10 @@ using namespace llvm;
#define DEBUG_TYPE "riscv-insert-read-write-csr"
#define RISCV_INSERT_READ_WRITE_CSR_NAME "RISC-V Insert Read/Write CSR Pass"
-static cl::opt<bool> DisableFRMInsertOpt(
- "riscv-disable-frm-insert-opt", cl::init(false), cl::Hidden,
- cl::desc("Disable optimized frm insertion."));
+static cl::opt<bool>
+ DisableFRMInsertOpt("riscv-disable-frm-insert-opt", cl::init(false),
+ cl::Hidden,
+ cl::desc("Disable optimized frm insertion."));
namespace {
@@ -69,7 +70,7 @@ bool RISCVInsertReadWriteCSR::emitWriteRoundingModeOpt(MachineBasicBlock &MBB) {
for (MachineInstr &MI : MBB) {
if (MI.getOpcode() == RISCV::SwapFRMImm ||
- MI.getOpcode() == RISCV::WriteFRMImm ) {
+ MI.getOpcode() == RISCV::WriteFRMImm) {
CurrentRM = MI.getOperand(0).getImm();
SavedFRM = std::nullopt;
continue;
@@ -85,7 +86,7 @@ bool RISCVInsertReadWriteCSR::emitWriteRoundingModeOpt(MachineBasicBlock &MBB) {
// Restore FRM before unknown operations.
if (SavedFRM.has_value())
BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(RISCV::WriteFRM))
- .addReg(*SavedFRM);
+ .addReg(*SavedFRM);
CurrentRM = RISCVFPRndMode::DYN;
SavedFRM = std::nullopt;
continue;
@@ -127,9 +128,10 @@ bool RISCVInsertReadWriteCSR::emitWriteRoundingModeOpt(MachineBasicBlock &MBB) {
if (InstrRM == RISCVFPRndMode::DYN) {
if (!SavedFRM.has_value())
continue;
- // SavedFRM not having a value means current FRM has correct rounding mode.
+ // SavedFRM not having a value means current FRM has correct rounding
+ // mode.
BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(RISCV::WriteFRM))
- .addReg(*SavedFRM);
+ .addReg(*SavedFRM);
SavedFRM = std::nullopt;
CurrentRM = RISCVFPRndMode::DYN;
continue;
@@ -139,13 +141,12 @@ bool RISCVInsertReadWriteCSR::emitWriteRoundingModeOpt(MachineBasicBlock &MBB) {
// Save current FRM value to SavedFRM.
MachineRegisterInfo *MRI = &MBB.getParent()->getRegInfo();
SavedFRM = MRI->createVirtualRegister(&RISCV::GPRRegClass);
- BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(RISCV::SwapFRMImm),
- *SavedFRM)
- .addImm(*InstrRM);
+ BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(RISCV::SwapFRMImm), *SavedFRM)
+ .addImm(*InstrRM);
} else {
// Don't need to save current FRM when CurrentRM != DYN.
BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(RISCV::WriteFRMImm))
- .addImm(*InstrRM);
+ .addImm(*InstrRM);
}
CurrentRM = InstrRM;
Changed = true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/77744
More information about the llvm-commits
mailing list