Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wannacu
Copy link
Contributor

@wannacu wannacu commented Aug 7, 2023

No description provided.

@ptitSeb ptitSeb merged commit adaafc2 into ptitSeb:main Aug 7, 2023
// put imm20 in the [31:12] bits of rd, zero [11:0] and sign extend bits31
#define LUI(rd, imm20) EMIT(U_type((imm20)<<12, rd, 0b0110111))

#define LI(rd, imm12) if (imm12 < 0x800) { ADDI(rd, xZR, imm12);} else {LUI(rd, 1); ADDIW(rd, rd, -(0x1000 - imm12));}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant. FYI we have this macro, which correctly handles signed 32-bit immediate:

#define MOV32w(A, B) rv64_move32(dyn, ninst, A, B, 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I got a mistake. The immediate value for the pseudo instruction 'li' should be 32 bits.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wannacu Can you submit another PR for these suggestions?

}
} else {
if (rex.w) {
LI(x2, 0xff);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0xff fits in imm12, so ADDI(x2, xZr, 0xff) is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants