[PATCH] D99319: [RISCV] [2/2] Add intrinsic for Zbb extension

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 25 00:41:46 PDT 2021


craig.topper added inline comments.


================
Comment at: clang/lib/Headers/riscv_zbb_intrin.h:18
+// Zbb
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_orc_b(int_xlen_t rs1) {
+  return __builtin_riscv_orc_b(rs1);
----------------
craig.topper wrote:
> I think rather than int_xlen_t we want an int32_t version for RV32/RV64 and an int64_t version for RV64. I think it is safe to use the 64-bit orc.b instruction for int32_t on RV64 since each output byte is only affected by the bits in the same input byte. So we can put garbage in the upper 4 bytes and ignore the results in the upper bytes.
> 
> We couldn't do this for crc32(c) from Zbr.
To do this you'll need to modify ReplaceNodeResults in RISCVISelLowering.cpp to detect the this intrinsic. I think there's already handling for some other intrinsics in there. Look for INTRINSIC_WO_CHAIN. For this you need to add an ANY_EXTEND to the operand, create a new INTRINSIC_WO_CHAIN node with i64 type, and truncate the result back to i32.

I think you'll need this in the RISCVTargetLowering constructor when Zbb is enabled. We only do it for the V extension right now.
```
setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i32, Custom);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99319/new/

https://reviews.llvm.org/D99319



More information about the cfe-commits mailing list