This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Implement intrinsic for DARN instruction
ClosedPublic

Authored by qiucf on Dec 1 2020, 11:47 PM.

Details

Summary

Instruction darn was introduced in ISA 3.0. It means 'Deliver A Random Number'.

The immediate number L means:

  • L=0, the generated random number is 32-bit (higher 32-bits are all-zero)
  • L=1, the generated random number is 'conditioned' (processed by hardware to reduce bias)
  • L=2, the generated random number is not conditioned, directly from noise source

GCC implements them in three separate intrinsics. (__builtin_darn, __builtin_darn_32 and __builtin_darn_raw)

This patch also addresses Bugzilla PR39800.

Diff Detail

Event Timeline

qiucf created this revision.Dec 1 2020, 11:47 PM
qiucf requested review of this revision.Dec 1 2020, 11:47 PM
This revision is now accepted and ready to land.Dec 7 2020, 5:14 PM
qiucf added a comment.Dec 7 2020, 6:19 PM

LGTM.

Thanks for reviewing! Maybe we need a predicate to guard it to prevent generating it on P8 or earlier targets? And as I see for other intrinsics (for example, dcbfps), if current platform doesn't support it, llc would crash and say LLVM ERROR: Cannot select: intrinsic %llvm.ppc.dcbfps. This is expected, but is there some way to express normal error to user instead of internal crash?

LGTM.

Thanks for reviewing! Maybe we need a predicate to guard it to prevent generating it on P8 or earlier targets? And as I see for other intrinsics (for example, dcbfps), if current platform doesn't support it, llc would crash and say LLVM ERROR: Cannot select: intrinsic %llvm.ppc.dcbfps. This is expected, but is there some way to express normal error to user instead of internal crash?

Yes, it should be guarded. But please leave the LLVM ERROR alone as it is by design I think.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2020, 10:13 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript