-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[LLVM] Add __builtin_readsteadycounter
intrinsic and builtin for realtime clocks
#81331
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,6 +312,12 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { | |
CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0)); | ||
break; | ||
} | ||
case Intrinsic::readsteadycounter: { | ||
errs() << "WARNING: this target does not support the llvm.readsteadycounter" | ||
<< " intrinsic. It is being lowered to a constant 0\n"; | ||
CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied it from the other one, but either way works. I think setting it to zero is a little more explicit. |
||
break; | ||
} | ||
|
||
case Intrinsic::dbg_declare: | ||
case Intrinsic::dbg_label: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3805,7 +3805,6 @@ def CALL_PROTOTYPE : | |
|
||
include "NVPTXIntrinsics.td" | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Random whitespace change |
||
//----------------------------------- | ||
// Notes | ||
//----------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx700 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=GCN,GFX700 | ||
; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=GCN,GFX900 | ||
; RUN: llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=GCN,GFX900 | ||
; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=GCN,GFX1100 | ||
; RUN: llc -global-isel=1 -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=GCN,GFX1100 | ||
|
||
declare i64 @llvm.readsteadycounter() #0 | ||
|
||
; GCN-LABEL: {{^}}test_readsteadycounter: | ||
; GFX700: s_mov_b32 s[[REG:[0-9]+]], 0 | ||
; GFX900: s_memrealtime s[[[LO:[0-9]+]]:[[HI:[0-9]+]]] | ||
; GFX900: s_memrealtime s[[[LO:[0-9]+]]:[[HI:[0-9]+]]] | ||
; GFX1100: s_sendmsg_rtn_b64 s[[[LO:[0-9]+]]:[[HI:[0-9]+]]], sendmsg(MSG_RTN_GET_REALTIME) | ||
; GFX1100: s_sendmsg_rtn_b64 s[[[LO:[0-9]+]]:[[HI:[0-9]+]]], sendmsg(MSG_RTN_GET_REALTIME) | ||
define amdgpu_kernel void @test_readsteadycounter(ptr addrspace(1) %out) #0 { | ||
%cycle0 = call i64 @llvm.readsteadycounter() | ||
store volatile i64 %cycle0, ptr addrspace(1) %out | ||
|
||
%cycle1 = call i64 @llvm.readsteadycounter() | ||
store volatile i64 %cycle1, ptr addrspace(1) %out | ||
ret void | ||
} | ||
|
||
attributes #0 = { nounwind } |
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.
Should we mention that we do not guarantee any particular frequency, just that it's stable and it's up to the user to figure out the actual frequency, if they need to.
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.
Good point, done.