-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Mips] Support llvm.readcyclecounter intrinsic #114953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
41adf42
to
27b5322
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
27b5322
to
490a1da
Compare
Ping. |
|
||
if (Subtarget.hasMips64()) { | ||
RdhwrOpc = Mips::RDHWR64; | ||
DestReg = Mips::V1_64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can V1 can hardcoded here?
If the IR is quite long, will it overwrite some previous value?
490a1da
to
f6b1cb9
Compare
Ping. |
@@ -2092,6 +2095,43 @@ MachineBasicBlock *MipsTargetLowering::emitAtomicCmpSwapPartword( | |||
return exitMBB; | |||
} | |||
|
|||
SDValue MipsTargetLowering::lowerREADCYCLECOUNTER(SDValue Op, | |||
SelectionDAG &DAG) const { | |||
SmallVector<SDValue, 3> Results; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only support it for mips32r2+ or linux triples.
I mean you should check if it is mips32r2+ or the os section of triple is Linux.
f6b1cb9
to
99e5f5f
Compare
MachineFunction &MF = DAG.getMachineFunction(); | ||
unsigned RdhwrOpc, DestReg; | ||
|
||
if (!Subtarget.hasMips32r6() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r2.
@@ -0,0 +1,26 @@ | |||
;RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32r2 < %s | FileCheck %s --check-prefix=MIPSEL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen for pre-r2 or non Linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test cases for
llc -mtriple=mipsel-linux-gnu -mcpu=mips2
llc -mtriple=mips64el-linux-gnu -mcpu=mips3
llc -mtriple=mipsel -mcpu=mips32r2
llc -mtriple=mips64el -mcpu=mips64r2
llc -mtriple=mipsel -mcpu=mips2
llc -mtriple=mips64el -mcpu=mips3
99e5f5f
to
7a05afe
Compare
@@ -359,6 +359,10 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM, | |||
setOperationAction(ISD::FCOPYSIGN, MVT::f64, Custom); | |||
setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom); | |||
|
|||
if (Subtarget.hasMips32r2() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& -> ||
7a05afe
to
5e008c5
Compare
The llvm.readcyclecounter intrinsic can be implemented via the `rdhwr $2, $hwr_cc` instruction. $hwr_cc: High-resolution cycle counter. This register provides read access to the coprocessor 0 Count Register. Fix llvm#106318.
5e008c5
to
5a8708f
Compare
; MIPSEL: # %bb.0: # %entry | ||
; MIPSEL-NEXT: .set push | ||
; MIPSEL-NEXT: .set mips32r2 | ||
; MIPSEL-NEXT: rdhwr $2, $hwr_cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, I find another problem, the return value is i64
.
It means that we should set $a1/$3
to zero here, just as MIPSEL_NOT_SUPPORTED
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yingopq please fix this problem.
Ping. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/13582 Here is the relevant piece of the build log for the reference
|
I reverted this commit. @yingopq can you have a look at this problem? |
The llvm.readcyclecounter intrinsic can be implemented via the `rdhwr $3, $hwr_cc` instruction. $hwr_cc: High-resolution cycle counter. This register provides read access to the coprocessor 0 Count Register. Fix llvm#106318.
This reverts commit 9cc7ee1.
The llvm.readcyclecounter intrinsic can be implemented via the `rdhwr $3, $hwr_cc` instruction. $hwr_cc: High-resolution cycle counter. This register provides read access to the coprocessor 0 Count Register. Fix llvm#106318.
This reverts commit 9cc7ee1.
I try to reproduce this failure, but the result was OK.
I would commit a change. |
The llvm.readcyclecounter intrinsic can be implemented via the `rdhwr $3, $hwr_cc` instruction. $hwr_cc: High-resolution cycle counter. This register provides read access to the coprocessor 0 Count Register. Fix llvm#106318.
This reverts commit 9cc7ee1.
The llvm.readcyclecounter intrinsic can be implemented via the
rdhwr $3, $hwr_cc
instruction.$hwr_cc: High-resolution cycle counter. This register provides read access to the coprocessor 0 Count Register.
Fix #106318.