-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[LoongArch64] Part-2:Add runtime assembly code (*.S) files in nativeaot. #104084
base: main
Are you sure you want to change the base?
Conversation
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
@shushanhf @huoyaoyuan Could you please review and signoff on this PR? |
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.
I have limited knowledge on LA64 asm. Here are some points I don't understand or can be improved for consistency.
// Preserve the MethodTable in s0 | ||
ori $s0, $a0, 0 | ||
|
||
addi.w $a2, $zero, 0 // numElements |
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 does here use addi.w
to clear $a2, instead of ori
? I'm seeing ori $zero, 0
more in other places.
// Compute overall allocation size (align(base size + (element size * elements), 8)). | ||
addi.w $a2, $zero, STRING_COMPONENT_SIZE | ||
ori $a3, $zero, 29 // STRING_BASE_SIZE + 7 | ||
mulw.d.w $a2, $a1, $a2 |
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.
Nit: STRING_COMPONENT_SIZE
is power of 2, so this can be a shift instead.
ARM also uses MUL here.
addi.w $a2, $zero, STRING_COMPONENT_SIZE | ||
ori $a3, $zero, 29 // STRING_BASE_SIZE + 7 |
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.
Any difference between addi.w
and ori
here?
srli.d $a2, $a2, 3 | ||
slli.d $a2, $a2, 3 |
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.
Note for myself: andi
on LA zero-extends the imm12, so unlike arm, & -8
can't be performed in a single instruction.
ori $t0, $sp, 0 | ||
st.d $t0, $a0, OFFSETOF__PInvokeTransitionFrame__m_PreservedRegs |
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.
Can this st.d
operate on $sp
directly?
ori $t1, $zero, 0 | ||
st.d $t1, $t0, OFFSETOF__Thread__m_pTransitionFrame |
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.
Can $zero
be used directly in the st
?
|
||
// If g_GCShadow is 0, don't perform the check. | ||
PREPARE_EXTERNAL_VAR_INDIRECT g_GCShadow, $t3 | ||
beq $t3, $zero, 1f |
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.
Can the branch instructions use a label?
lu12i.w $a2, 0x3ffff // (MAX_STRING_LENGTH >> 12) & 0xFFFFF | ||
ori $a2, $a2, 0xfdf // MAX_STRING_LENGTH & 0xFFF |
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.
lu12i.w $a2, 0x3ffff // (MAX_STRING_LENGTH >> 12) & 0xFFFFF | |
ori $a2, $a2, 0xfdf // MAX_STRING_LENGTH & 0xFFF | |
lu12i.w $a2, ((MAX_STRING_LENGTH >> 12) & 0xfffff) | |
ori $a2, $a2, (MAX_STRING_LENGTH & 0xfff) |
Use constants like UPDATE_GC_SHADOW macro.
|
||
// Compute overall allocation size (align(base size + (element size * elements), 8)). | ||
addi.w $a2, $zero, STRING_COMPONENT_SIZE | ||
ori $a3, $zero, 29 // STRING_BASE_SIZE + 7 |
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.
ori $a3, $zero, 29 // STRING_BASE_SIZE + 7 | |
ori $a3, $zero, (STRING_BASE_SIZE + 7) |
beq $t0, $t1, 12 | ||
ori $t1, $t0, 0 | ||
b 8 |
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.
Use label for the branches
This PR is the second part adding nativeaot support on LoongArch64.
It adds runtime assembly code (*.S) files.