Skip to content
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

Incorrect code generated for Bytes.get_int64_le on ppc64 #10302

Closed
dra27 opened this issue Mar 19, 2021 · 5 comments
Closed

Incorrect code generated for Bytes.get_int64_le on ppc64 #10302

dra27 opened this issue Mar 19, 2021 · 5 comments
Labels

Comments

@dra27
Copy link
Member

dra27 commented Mar 19, 2021

let _ = Bytes.(get_int64_le (unsafe_of_string "\xfe\xdc\xba\x98\x76\x54\x32\x10\x01\x00") 1)

on ppc64 generates:

        ld      21, 1(11)

which gives assembler error "operand out of domain (1 is not a multiple of 4)".

@xavierleroy
Copy link
Contributor

Well spotted. We need to be more careful during instruction selection and not select the ld OFFSET(reg) and sd OFFSET(reg) forms unless OFFSET is a multiple of 4.

@bschommer
Copy link
Contributor

Seems to me that the gnu assembler here might be more strict, from the PowerPC ISA Document I can get the following restriction for load/stores with DS-FORM:

The DS field in DS-form Storage Access instruc-
tions is a word offset, not a byte offset like the D
field in D-form Storage Access instructions. How-
ever, for programming convenience, Assemblers
should support the specification of byte offsets for
both forms of instruction.

@xavierleroy
Copy link
Contributor

I read this documentation as "in assembly language, the offset is given in bytes, but it must be a multiple of 4 because in the opcode it is stored as a word offset". So, the GNU assembler is doing the right thing by rejecting ld 21, 1(11).

@bschommer
Copy link
Contributor

I read this documentation as "in assembly language, the offset is given in bytes, but it must be a multiple of 4 because in the opcode it is stored as a word offset". So, the GNU assembler is doing the right thing by rejecting ld 21, 1(11).

Make sense, that is by the way the only place were I could find any restriction in the ISA Manual.

@Octachron
Copy link
Member

Fixed by #10303 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants