This is an archive of the discontinued LLVM Phabricator instance.

Basic types for LLVM
Needs ReviewPublic

Authored by gchatelet on Jun 17 2022, 6:42 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This is a POC patch implementing the low level abstractions described
in https://discourse.llvm.org/t/rfc-proper-low-level-abstractions-to-llvm-bits-bytes-addresses-and-masks/63081/13

I'm starting with primitives and tests.
I'll convert a few files to get a feel of the usability and tweak accordingly.

At this point feedback is welcome: naming, use cases, integration with other
LLVM concepts, etc...

Diff Detail

Event Timeline

gchatelet created this revision.Jun 17 2022, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2022, 6:42 AM
Herald added a subscriber: mgorny. · View Herald Transcript
gchatelet requested review of this revision.Jun 17 2022, 6:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 17 2022, 6:42 AM
gchatelet updated this revision to Diff 437892.Jun 17 2022, 7:16 AM
  • Turn Mask::from(Align) into Mask::allOnes(PowerOf2)
gchatelet updated this revision to Diff 438332.Jun 20 2022, 3:57 AM
  • rebase + various enhancements
gchatelet updated this revision to Diff 438826.Jun 21 2022, 2:02 PM
  • rebase + various enhancements
  • Add offset types, more tests and better integration with Align
gchatelet updated this revision to Diff 438957.Jun 22 2022, 2:59 AM
  • More documentation and tests
gchatelet updated this revision to Diff 438964.Jun 22 2022, 3:52 AM
  • Fix signed/unsigned mismatch
gchatelet updated this revision to Diff 438965.Jun 22 2022, 3:56 AM
  • Remove Mask and Address for now as it conflicts with clang
gchatelet updated this revision to Diff 483511.Dec 16 2022, 6:27 AM
  • Rename HostAddr to HostAddress and introduce a Scalable type.
  • rebase and improve documentation
gchatelet updated this revision to Diff 483518.Dec 16 2022, 6:35 AM
  • Rename multiple and add documentation
gchatelet updated this revision to Diff 483523.Dec 16 2022, 6:41 AM
  • Updates documentation
arichardson added inline comments.
llvm/include/llvm/Support/BasicTypes.h
421

Would it be possible to change this to masking off low bits instead of shifting? I'm not sure if this code is going to be used for actual pointers, but if it is, the current shifting pattern is incompatible with CHERI hosts such as Arm Morello. On CHERI systems, shifting a pointer will cause it to go so far out of bounds that it becomes invalidated (the bounds are encoded relative to the address and if the address goes too far out of bounds the can no longer be represented).

Also it looks like RISC-V already does this conversion from shift to mask: https://godbolt.org/z/15KfM78Tn

gchatelet updated this revision to Diff 484824.Dec 22 2022, 6:58 AM
  • Reworked types and documentation. Allowed for custom byte width.
llvm/include/llvm/Support/BasicTypes.h
421

I see, thx for the comment. I'll go with masking instead.

gchatelet updated this revision to Diff 484831.Dec 22 2022, 7:13 AM
  • Fix misplaced minus sign in tests
  • Use Bytes instead of SizeIn<ByteUnit>
gchatelet updated this revision to Diff 484834.Dec 22 2022, 7:26 AM
  • Move Align and HostAddress into Alignment.h