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

Missing register aliases for AVR for compatibility with gcc-avr's inline assembly #51557

Closed
maribu opened this issue Oct 19, 2021 · 8 comments
Closed
Assignees
Labels
backend:AVR bugzilla Issues migrated from bugzilla

Comments

@maribu
Copy link
Contributor

maribu commented Oct 19, 2021

Bugzilla Link 52215
Version 12.0
OS other

Extended Description

E.g. the avr-libc but also other AVR code written for gcc-avr heavily uses the following aliases:

tmp_reg
SREG
zero_reg
SP_H
SP_L

also the aliases RAMPZ and EIND are occasionally used.

See [1] for their definitions.

This is the first time I looked into the LLVM source code, so I might be talking nonsense here. I tried to fix this by amending lib/Target/AVR/AVRRegisterInfo.td like this:

-def R0 : AVRReg<0, "r0">, DwarfRegNum<[0]>;
-def R1 : AVRReg<1, "r1">, DwarfRegNum<[1]>;
+def R0 : AVRReg<0, "r0", [], ["tmp_reg"]>, DwarfRegNum<[0]>;
+def R1 : AVRReg<1, "r1", [], ["zero_reg"]>, DwarfRegNum<[1]>;

etc. - but to no avail.

I also tried to just emit assignments for the alias via void AVRAsmPrinter::emitStartOfAsmFile(Module &M), but this didn't work for me either.

I think that adding the aliases should be relatively trivial for someone with same basic understanding of the LLVM code - which I sadly lack.

Also note that according to [1] the AVRtiny family has a different mapping (e.g. tmp_reg usually is r0, but on AVRtiny it is r16).

https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config/avr/lib1funcs.S;h=ac101b49f03e340e93e16283eb47146ef47290c2;hb=HEAD

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@benshi001 benshi001 self-assigned this Jan 29, 2022
@benshi001
Copy link
Member

This issue is fixed in https://reviews.llvm.org/D119807,

It needs someone to approve.

@benshi001 benshi001 added this to the LLVM 14.0.0 Release milestone Mar 2, 2022
@tstellar
Copy link
Collaborator

tstellar commented Mar 8, 2022

This issue was not resolved in time for 14.0.0 and will need to be fixed in the next release (14.0.1). If you disagree with this or you feel there was a mistake, please change the milestone back to 'LLVM 14.0.0 Release' so we can discuss.

@benshi001
Copy link
Member

benshi001 commented Mar 9, 2022

ed in time for 14.0.0 and will need to be fixed in the next release (14.0.1). If you disagree with

Can anybody help me review my patch? The code owner of AVR and other AVR contributors do not give me any feedback. Actually this is a simple change. I am quite sure my solution is correct.

@benshi001
Copy link
Member

fixed and committed as d7afea9

@tstellar
Copy link
Collaborator

tstellar commented Apr 6, 2022

/cherry-pick d7afea9

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 6, 2022

Failed to cherry-pick: d7afea9

https://github.com/llvm/llvm-project/actions/runs/2100362322

Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:

/branch <user>/<repo>/<branch>

@benshi001
Copy link
Member

This is a feature, so no need to back port.

@tstellar
Copy link
Collaborator

@benshi001 Ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AVR bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

5 participants