Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Phabricator shutdown timeline

[Xtensa 4/10] Add basic *td files with Xtensa architecture description.
ClosedPublic

Authored by andreisfr on Jul 16 2019, 3:21 PM.

Details

Summary

Add initial Xtensa.td file with target machine description. Add XtensaInstrInfo.td,
currently describe just susbet of Core Instructions like ALU, Processor control,
memory barrier and some move instructions. Add descriptions of the instructions
formats(XtensaInstrInfo.td) and some immediate instruction operands(XtensaOperands.td).
Add General Registers and Special Registers classes.

Diff Detail

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
andreisfr added a comment.EditedJan 24 2021, 5:14 PM

@brainstorm , @tonic , @tstellar , thank you very much for your help!

I support and improve Xtensa backend now, current version of the backend is rebased on release 11.0.0 https://github.com/espressif/llvm-project/tree/xtensa_release_11.0.0 .

@tstellar , so I can just update these 10 patches according to latest changes in LLVM, add myself as code owner in the first patch and send patches again to list (I will recheck outstanding issues)?

@brainstorm , @tonic , @tstellar , thank you very much for your help!

I support and improve Xtensa backend now, current version of the backend is rebased on release 11.0.0 https://github.com/espressif/llvm-project/tree/xtensa_release_11.0.0 .

@tstellar , so I can just update these 10 patches according to latest changes in LLVM, add myself as code owner in the first patch and send patches again to list (I will recheck outstanding issues)?

@andreisfr Yes, that sounds good.

aykevl added a comment.Mar 4 2021, 6:45 AM

@andreisfr any update on this?

It would be great if you could update these patches and send a new RFC to llvm-dev, like you did here: https://lists.llvm.org/pipermail/llvm-dev/2019-March/130796.html

aykevl added a comment.EditedMar 4 2021, 4:31 PM

Also, there is an emulator here: https://github.com/espressif/qemu/wiki
I have successfully used it in the past. Noting it here as it can make backend review/development easier for those who don't have the hardware.

@aykevl , I prepared new version of patches and I will update them in 1 day.

andreisfr updated this revision to Diff 328695.EditedMar 5 2021, 4:44 PM

Patch is updated according to LLVM upstream version and latest Xtensa backend version.

aykevl added a comment.Mar 9 2021, 2:28 PM

@andreisfr awesome! Thanks a lot!

Can you please also write a new RFC and send it to llvm-dev like @tstellar proposed? An RFC is the next step in getting this backend accepted.

If you think you meet those requirements, please re-send the RFC to the list, so we can discuss getting this added.

craig.topper added inline comments.
llvm/lib/Target/Xtensa/Xtensa.td
2

Please limit line length to 80 characters

llvm/lib/Target/Xtensa/XtensaInstrFormats.td
2

Please limit line length to 80 characters

15

I think the prevailing style in LLVM has the open curly brace at the end of the previous line.

32

It might just be me, but I find this lining the XtensaInst up with template parameters hard to read. I think a common style is to put at the start of the line with only a small indentation. For example

class PseudoI<dag oops, dag iops, list<dag> pattern>                                                                                                                                                                                                                                   
  : X86Inst<0, Pseudo, NoImm, oops, iops, ""> {                                                                                                                                                                                                                                        
  let Pattern = pattern;                                                                                                                                                                                                                                                               
}
llvm/lib/Target/Xtensa/XtensaOperands.td
2

This line seems shorter than 80 characters.

andreisfr updated this revision to Diff 335949.Apr 7 2021, 4:40 PM

Correct instruction descriptions, format descriptions and instruction operands according to common style for *.td files.

andreisfr added inline comments.Apr 7 2021, 4:47 PM
llvm/lib/Target/Xtensa/Xtensa.td
2

Corrected

llvm/lib/Target/Xtensa/XtensaInstrFormats.td
2

Corrected

15

Corrected for instruction descriptions, format descriptions and instruction operands.

32

@craig.topper , I corrected instruction formats and instruction descriptions, do you think that this code now in common style or it must be corrected bit more?

llvm/lib/Target/Xtensa/XtensaOperands.td
2

Corrected

@craig.topper , thank you very much for comments!

craig.topper added inline comments.Apr 8 2021, 3:01 PM
llvm/lib/Target/Xtensa/XtensaInstrFormats.td
32

I think this looks better. Unfortunately, we don't have a formatting tool for tablegen and no rules are written down. I think this is good enough.

167

Drop the second blank line?

llvm/lib/Target/Xtensa/XtensaRegisterInfo.td
31

This is overindented relative to the style of the rest of the file.

andreisfr updated this revision to Diff 336425.Apr 9 2021, 6:09 AM

Corrected indentation, removed blank line

llvm/lib/Target/Xtensa/XtensaInstrFormats.td
167

Corrected

llvm/lib/Target/Xtensa/XtensaRegisterInfo.td
31

Corrected

lmb added a subscriber: lmb.May 31 2021, 3:01 AM
marbre added a subscriber: marbre.Aug 11 2021, 12:27 AM
ofen added a subscriber: ofen.Nov 8 2021, 1:36 PM

Who is needed to review and approve this patch?

Patch is updated according to LLVM upstream version.

bero added a subscriber: bero.Apr 14 2022, 1:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2022, 1:59 PM
luojia added a subscriber: luojia.Apr 26 2022, 2:22 AM

What's the current state of this patch? :)

ofen removed a subscriber: ofen.Apr 26 2022, 2:38 AM

What's the current state of this patch? :)

HI @luojia, thank you for your interest to the Xtensa backend.

Currently, probably all suggestions in comments for this patch were implemented. If you can help with further reviewing or approving this patch that would be great.
Brief status of the whole series of the Xtensa backend patches :

  1. All 10 patches are updated according to the latest upstream changes . Patches 1-3 are approved.
  2. We have submitted an RFC to the mailing list https://lists.llvm.org/pipermail/llvm-dev/2021-March/149090.html .
  3. We have written the ISA documentation https://github.com/espressif/xtensa-isa-doc .
  4. Also we have a branch on Github with patches rebased to llvm-project main branch https://github.com/espressif/llvm-project/tree/main_xtensa .
saugustine requested changes to this revision.Aug 19 2022, 3:33 PM
saugustine added a subscriber: saugustine.

I have access to an up-to-date copy of the isa book and can review these for technical correctness. I'm less familiar with style issues.

I have checked the bitfields, encodings, and field names. They are all correct.

Some comments below, especially on the xSYNC instructions. Nothing too serious, but they do have side effects of one form or another. Typically a compiler wouldn't generate them unless as part of a larger hard-coded, unsplittable block, but if they are present, they ought to be correct.

llvm/lib/Target/Xtensa/XtensaInstrFormats.td
53

These fields are reverse order in big endian versions of the core. Is the ESP32 implementation of Xtensa always little endian?

It would be nice to handle both variants, but that isn't a block for this patch.

llvm/lib/Target/Xtensa/XtensaInstrInfo.td
102

This is quite a bit more conservative than necessary. MEMW only serializes memory operations, it is fine to move arithmetic ops across it.

109

This instruction is a superset of MEMW and serializes all externally visible operations.

hasSideEffects is necessary on this one (at least in a base ISA implementation).

116

DSYNC is the least intrusive processor-state sync instruction, used to serialize loads and stores against WSR and XSR instructions that may update the page table.

It could be modeled quite similarly to MEMW, but with a more complete memory-barrier model, it should include side effects.

123

ISYNC synchronizes the instruction fetch unit against updates to the icache. Needs hasSideEffects set.

130

This synchronizes reading register fields out of instructions against WSR and XSR modifying the register window. Needs hasSideEffects set.

137

This is quite similar to RSYNC, but synchronizes the exact read from the register window, rather than the fields out of the instruction. Needs hasSideEffects set.

This revision now requires changes to proceed.Aug 19 2022, 3:33 PM
andreisfr updated this revision to Diff 455441.Aug 24 2022, 5:56 PM

Corrected MEMW, EXTW, DSYNC, ESYNC, ISYNC and RSYNC instruction descriptions

andreisfr marked 6 inline comments as done.Aug 24 2022, 6:17 PM

@saugustine , thank you very much for your comments!

llvm/lib/Target/Xtensa/XtensaInstrFormats.td
53

Yes, the ESP32 implementation is always little endian, and I didn't observed any public available big endian implementations. So, initial idea was to implement just little endian at first and maybe implement support of the big endian in future.

llvm/lib/Target/Xtensa/XtensaInstrInfo.td
102

Corrected

109

Corrected

116

Corrected

123

Corrected

130

Corrected

137

Corrected

saugustine accepted this revision.Aug 29 2022, 6:11 PM
This revision is now accepted and ready to land.Aug 29 2022, 6:11 PM
phosek added a subscriber: phosek.Sep 1 2022, 11:43 AM
andreisfr marked 6 inline comments as done.Oct 10 2022, 7:11 AM

@aykevl , @jyknight , @ivanbaev , I have a good news about Xtensa ISA documentation. Cadence makes documentation publicly available https://www.cadence.com/content/dam/cadence-www/global/en_US/documents/tools/ip/tensilica-ip/isa-summary.pdf

What is the current state of this patch? As the Debian maintainer of ath9k_htc, the flagship libre wireless firmware for USB adapters, I eagerly wait for this to be merged so that I may begin exploring using LLVM to build the firmware, which is currently a rather painful process with GCC.

Hi everyone. Since this has been accepted for some time now, we're planning to commit this on Monday (December 16th). Please let us know if there is anything else we should address.

barannikov88 added inline comments.
llvm/lib/Target/Xtensa/XtensaInstrFormats.td
218
  • IIRC SoftFail is no longer necessary after this patch (if you don't use this functionality, of course).
  • 'field' seems redundant, too (hasn't this keyword been deprecated?).
  • Do isCodeGenOnly instructions really need encoding bits?
andreisfr updated this revision to Diff 485249.Dec 25 2022, 4:28 PM

Added fixes according to comments

andreisfr added inline comments.Dec 25 2022, 4:29 PM
llvm/lib/Target/Xtensa/XtensaInstrFormats.td
218

Thank you for comments, I removed redundant code.

barannikov88 accepted this revision.Dec 25 2022, 5:29 PM
This revision was landed with ongoing or failed builds.Dec 26 2022, 4:39 AM
This revision was automatically updated to reflect the committed changes.