This is an archive of the discontinued LLVM Phabricator instance.

[MSVC, ARM64] Add __readx18 intrinsics
ClosedPublic

Authored by steplong on May 19 2022, 3:18 PM.

Details

Summary

https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170

unsigned char __readx18byte(unsigned long)
unsigned short __readx18word(unsigned long)
unsigned long __readx18dword(unsigned long)
unsigned __int64 __readx18qword(unsigned long)

Given the lack of documentation of the intrinsics, we chose to align the offset with just
CharUnits::One() when calling IRBuilderBase::CreateAlignedLoad()

Diff Detail

Event Timeline

steplong created this revision.May 19 2022, 3:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2022, 3:18 PM
steplong requested review of this revision.May 19 2022, 3:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2022, 3:18 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Like D126023, the generated assembly for MSVC is slightly different:

MSVC                                                                          LLVM
__readx18byte:
                          ldrb    w0, [x18, x0]                             ldrb    w0, [x18, w0, uxtw] 
__readx18word:
                          ldrh    w0, [x18, x0]                             ldrh    w0, [x18, w0, uxtw #1]
__readx18dword:
                          ldr     w0, [x18, x0]                             ldr     w0, [x18, w0, uxtw #2]
__readx18qword:
                          ldr     x0, [x18, x0]                              ldr     x0, [x18, w0, uxtw #3]
steplong updated this revision to Diff 430994.May 20 2022, 9:06 AM

The assembly for LLVM is now:

__readx18byte:
       ldrb    w0, [x18, w0, uxtw]
__readx18word:
       ldrh    w0, [x18, w0, uxtw]
__readx18dword:
       ldr     w0, [x18, w0, uxtw]
__readx18qword:
       ldr     x0, [x18, w0, uxtw]
steplong updated this revision to Diff 431011.May 20 2022, 11:17 AM
  • Change addrspace(256) to the default addrspace 0
steplong updated this revision to Diff 431021.May 20 2022, 12:07 PM
  • Use CharUnits::One() instead of getTypeAlignInChars()
This revision is now accepted and ready to land.May 20 2022, 2:50 PM
steplong edited the summary of this revision. (Show Details)May 23 2022, 6:58 AM
steplong updated this revision to Diff 431392.May 23 2022, 9:00 AM
  • Rebased patch on top of main
This revision was automatically updated to reflect the committed changes.