-
Couldn't load subscription status.
- Fork 75
[Draft] Support the globaltimer and smid on Intel Arch #4816
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
base: main
Are you sure you want to change the base?
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,14 +3,20 @@ | |||||||
|
|
||||||||
| @core.extern | ||||||||
| def globaltimer(_semantic=None): | ||||||||
| return core.inline_asm_elementwise("mov.u64 $0, %globaltimer;", "=l", [], dtype=core.int64, is_pure=False, pack=1, | ||||||||
| _semantic=_semantic) | ||||||||
| return core.inline_asm_elementwise( | ||||||||
| """{\n .decl globaltimer v_type=G type=ud num_elts=2 align=qword alias=<$0, 0> \n""" | ||||||||
| """ mov (M1_NM, 2) globaltimer(0, 0)<1> %tsc(0,0)<1;1,0> \n}""", "=rw.u", [], dtype=core.uint64, is_pure=False, | ||||||||
| pack=1, _semantic=_semantic) | ||||||||
|
|
||||||||
|
|
||||||||
| @core.extern | ||||||||
| def smid(_semantic=None): | ||||||||
| return core.inline_asm_elementwise("mov.u32 $0, %smid;", "=r", [], dtype=core.int32, is_pure=True, pack=1, | ||||||||
| _semantic=_semantic) | ||||||||
| sr = core.inline_asm_elementwise("mov (M1_NM, 1) $0(0, 0)<1> %sr0(0,0)<0;1,0>", "=rw.u", [], dtype=core.uint32, | ||||||||
| is_pure=True, pack=1, _semantic=_semantic) | ||||||||
| pos: core.constexpr = core.constexpr(9) | ||||||||
|
||||||||
| pos: core.constexpr = core.constexpr(9) | |
| pos: core.constexpr = core.constexpr(STATUS_REGISTER_BIT_POSITION) |
Copilot
AI
Jul 31, 2025
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.
The magic number 11 should be documented or extracted to a named constant to explain the bit width of the subslice mask.
| subslice_mask: core.constexpr = core.constexpr((1 << 11) - 1) | |
| SUBSLICE_MASK_BIT_WIDTH = 11 # Bit width of the subslice mask | |
| subslice_mask: core.constexpr = core.constexpr((1 << SUBSLICE_MASK_BIT_WIDTH) - 1) |
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.
[nitpick] The inline assembly string is complex and split across multiple lines with embedded newlines and escape sequences. Consider extracting this assembly code to a constant or using a more readable multiline string format to improve maintainability.