This is an archive of the discontinued LLVM Phabricator instance.

[ARC] Add codegen for the readcyclecounter intrinsic along with disassembly for associated instructions
ClosedPublic

Authored by thomasjohns on Aug 23 2021, 4:53 PM.

Details

Summary

This adds lowering rules for the llvm.readcyclecounter intrinsic along with a codegen test for the ARC backend. To perform the lowering, we needed to generate the LR (Load from Auxiliary Register) instruction to read from the COUNT0 timer register (which has number 33 or 0x22). Thus, this patch also adds support for the LR instruction with both LR_rs12 and LR_ru6 immediate formats along with custom disassembler code and tests.

Diff Detail

Event Timeline

thomasjohns created this revision.Aug 23 2021, 4:53 PM
thomasjohns requested review of this revision.Aug 23 2021, 4:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2021, 4:53 PM
thomasjohns added inline comments.Aug 23 2021, 4:58 PM
llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp
325

This aims to decode either form:
...ssssssSSSSSS
or
...uuuuuu000000
(S12 or U6). I assumed the leading bit of the S12 marks the sign. Is this correct @marksl ?

marksl requested changes to this revision.Aug 24 2021, 8:31 AM
marksl added inline comments.
llvm/lib/Target/ARC/ARCISelLowering.cpp
172

Please use

setOperationAction(ISD::READCYCLECOUNTER,MVT::i64,
                   isTypeLegal(MVT::i64)?Legal:Custom);
llvm/lib/Target/ARC/ARCInstrFormats.td
417

Can this one be DecodeSOPwithRS12?

439

Can this one be DecodeSOPwithRU6?

llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp
325

I'd rather see you use two separate functions: DecodeSOPwithRU6 and DecodeSOPwithRS12

This revision now requires changes to proceed.Aug 24 2021, 8:31 AM
thomasjohns added inline comments.Aug 24 2021, 8:40 AM
llvm/lib/Target/ARC/ARCISelLowering.cpp
172

Thanks, will do!

llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp
325

Thanks, agreed that makes sense to me to separate them.

Separate S12 and U6 single operand decoding into different methods. Check legality of i64 in ARCISelLowering.

marksl accepted this revision.Aug 24 2021, 10:25 AM

Looks good

This revision is now accepted and ready to land.Aug 24 2021, 10:25 AM
This revision was landed with ongoing or failed builds.Aug 24 2021, 11:54 AM
This revision was automatically updated to reflect the committed changes.