[PATCH] D85366: [RISCV] Disparage CSR instructions

Evandro Menezes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 15:09:40 PDT 2020


evandro created this revision.
evandro added reviewers: asb, compilerguy.
Herald added subscribers: llvm-commits, luismarques, apazos, sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
Herald added a project: LLVM.
evandro requested review of this revision.
Herald added a subscriber: MaskRay.

Many CSRs have adverse side effects on the machine and they should be treated with caution by the rest of the compiler.

They should not be duplicated, for their positioning may be critical.

Scheduling information is of little value when they may disrupt the pipeline.  It doesn't make much sense to schedule around such instructions either and adding `isBarrier` might also apply.


Repository:
  rL LLVM

https://reviews.llvm.org/D85366

Files:
  llvm/lib/Target/RISCV/RISCVInstrInfo.td


Index: llvm/lib/Target/RISCV/RISCVInstrInfo.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -368,12 +368,14 @@
     : RVInstR<funct7, funct3, OPC_OP, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2),
               opcodestr, "$rd, $rs1, $rs2">;
 
-let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
+let hasNoSchedulingInfo = 1, isNotDuplicable = 1,
+    hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
 class CSR_ir<bits<3> funct3, string opcodestr>
     : RVInstI<funct3, OPC_SYSTEM, (outs GPR:$rd), (ins csr_sysreg:$imm12, GPR:$rs1),
               opcodestr, "$rd, $imm12, $rs1">, Sched<[WriteCSR, ReadCSR]>;
 
-let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
+let hasNoSchedulingInfo = 1, isNotDuplicable = 1,
+    hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
 class CSR_ii<bits<3> funct3, string opcodestr>
     : RVInstI<funct3, OPC_SYSTEM, (outs GPR:$rd),
               (ins csr_sysreg:$imm12, uimm5:$rs1),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85366.283408.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200805/06b72666/attachment.bin>


More information about the llvm-commits mailing list