_ReadStatusReg and _WriteStatusReg intrinsics take ARM64_REGNO as input. These are defined in https://www.codemachine.com/downloads/win10/winnt.h.
LLVM already has intrinsics to read/write status regs: builtin_arm_rsr/builtin_arm_wsr. But these take the string concatenation of the byte repesentation of a register (like "1:2:3:4:5"). So I convert ARM64_REGNO to this string format and invoke read_register/write_register intrinsics.
I had to create a new test file here as the existing file arm64-microsoft-intrinsics.cpp has a check for metadata and it seems I cannot have 2 different tests checking different metadata in the same test file.
If I understand correctly, when trying to match the metadata for one test the lit parser reaches the end of the generated IR and then cannot go up again to match the other checks.
I agree we shouldn't try to figure out whether the register is valid, but we probably want a range check anyway: if the value is greater than 0x7FFF, it can't be encoded.