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

Cherry-pick improvements for AVR codegen #149

Closed

Commits on Jul 23, 2023

  1. [AVR] Fix incorrect decoding of conditional branch instructions

    This patch fixes the inaccurate decoding of the offset operand of
    the conditional branch instructions.
    
    Reviewed By: aykevl
    
    Differential Revision: https://reviews.llvm.org/D140816
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    3c4f514 View commit details
    Browse the repository at this point in the history
  2. [AVR][NFC] Remove redundant target feature PROGMEM

    The functionality of FeaturePROGMEM is all equivalant to FeatureLPM.
    
    Reviewed By: Chenbing.Zheng, aykevl
    
    Differential Revision: https://reviews.llvm.org/D141242
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    6d0184a View commit details
    Browse the repository at this point in the history
  3. [AVR][NFC] Refactor 'AVRAsmPrinter::PrintAsmOperand'

    Reviewed By: Chenbing.Zheng, aykevl
    
    Differential Revision: https://reviews.llvm.org/D142170
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    83205f5 View commit details
    Browse the repository at this point in the history
  4. [AVR] Optimize 16-bit comparison with a constant

    Fixes llvm#30923
    
    Reviewed By: jacquesguan, aykevl
    
    Differential Revision: https://reviews.llvm.org/D142281
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    e8a78a6 View commit details
    Browse the repository at this point in the history
  5. [AVR] Fix inaccurate offsets in PC relative branch instructions

    In avr-gcc, the destination of "rjmp label + offset" is address
    'label + offset', while destination of "rjmp . + offset" is
    'address_of_rjmp + offset + 2'.
    
    Clang is in accordance with avr-gcc for "rjmp label + offset", but
    emits incorrect destination of "rjmp . + offset" to
    'address_of_rjmp + offset', in which the expected offset 2 is missing.
    
    This patch fixes the above issue.
    
    Fixes llvm#60019
    
    Reviewed By: jacquesguan, aykevl
    
    Differential Revision: https://reviews.llvm.org/D143901
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    2f4a9d7 View commit details
    Browse the repository at this point in the history
  6. [AVR][MC] Add ELF flag 'EF_AVR_LINKRELAX_PREPARED' to OBJ files

    This is in accordance with avr-gcc, even '-mno-relax' is specified
    to avr-gcc, this flag will also be added to the output relocatables.
    
    With this flag set, the GNU ld will perform long call -> short call
    optimization for AVR, otherwise not.
    
    Fixes llvm#54508
    
    Reviewed By: MaskRay, jacquesguan, aykevl
    
    Differential Revision: https://reviews.llvm.org/D144617
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    4d1912b View commit details
    Browse the repository at this point in the history
  7. [AVR] Fix incorrect flags of livein registers when spilling them

    In AVRFrameLowering::spillCalleeSavedRegisters(), when a 16-bit
    livein register is spilled, two PUSH instructions are generated
    for the higher and lower 8-bit registers. But these two 8-bit
    registers are marked as killed in the two PUSH instructions, so
    any future use of them will cause a crash.
    
    This patch fixes the above issue by adding the two sub 8-bit
    registers to the livein list.
    
    Fixes llvm#56423
    
    Reviewed By: jacquesguan
    
    Differential Revision: https://reviews.llvm.org/D144720
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    8dc25fa View commit details
    Browse the repository at this point in the history
  8. [AVR] Fix incorrect expansion of the pseudo 'ELPMBRdZ' instruction

    The 'ELPM' instruction has three forms:
    
    --------------------------
    | form        | feature  |
    | ----------- | -------- |
    | ELPM        | hasELPM  |
    | ELPM Rd, Z  | hasELPMX |
    | ELPM Rd, Z+ | hasELPMX |
    --------------------------
    
    The second form is always used in the expansion of the pseudo
    instruction 'ELPMBRdZ'. But for devices without ELPMX but only
    with ELPM, only the first form can be emitted.
    
    Reviewed By: jacquesguan
    
    Differential Revision: https://reviews.llvm.org/D141221
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    0b320f8 View commit details
    Browse the repository at this point in the history
  9. [AVR] Do not emit 'LPM Rd, Z' on devices without FeatureLPMX

    The 'LPM' instruction has three forms:
    
    ------------------------
    | form       | feature |
    | ---------- | --------|
    | LPM        | hasLPM  |
    | LPM Rd, Z  | hasLPMX |
    | LPM Rd, Z+ | hasLPMX |
    ------------------------
    
    The second form is always selected in ISelDAGToDAG, even on devices
    without FeatureLPMX. This patch emits "LPM + MOV" on devices with
    only FeatureLPM.
    
    Reviewed By: jacquesguan
    
    Differential Revision: https://reviews.llvm.org/D141246
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    6582eff View commit details
    Browse the repository at this point in the history
  10. [AVR] Fix incorrect expansion of pseudo instructions LPMWRdZ/ELPMWRdZ

    The 'ELPM' instruction has three forms:
    
    --------------------------
    | form        | feature  |
    | ----------- | -------- |
    | ELPM        | hasELPM  |
    | ELPM Rd, Z  | hasELPMX |
    | ELPM Rd, Z+ | hasELPMX |
    --------------------------
    
    The second form is always used in the expansion of pseudo instructions
    LPMWRdZ/ELPMWRdZ. But for devices without ELPMX and with only ELPM,
    only the first form can be used.
    
    Reviewed By: aykevl, Miss_Grape
    
    Differential Revision: https://reviews.llvm.org/D141264
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    722c7b6 View commit details
    Browse the repository at this point in the history
  11. [AVR] Reject invalid LDD instruction with explicit error

    We should reject "ldd Rn, X" with explicit error message
    rather than "llvm_unreachable" in llvm's release build.
    
    Fixes llvm#62012
    
    Reviewed By: Miss_Grape
    
    Differential Revision: https://reviews.llvm.org/D147877
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    d103fcc View commit details
    Browse the repository at this point in the history
  12. [AVR][NFC] Fix errors in commit 6e57f68

    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    ccd3588 View commit details
    Browse the repository at this point in the history
  13. [AVR] Disable post increment load from program memory space

    We temporarily only allow post increment load/store from/to data memory,
    and disable post increment load from program space.
    
    Updates llvm#59914
    
    Reviewed By: mzh
    
    Differential Revision: https://reviews.llvm.org/D147761
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    614a431 View commit details
    Browse the repository at this point in the history
  14. [AVR] Fix an issue of writing 16-bit ports

    For 16-bit ports, the normal devices reqiure writing high byte first
    and then low byte. But the XMEGA devices require the reverse order.
    
    Fixes llvm#58395
    
    Reviewed By: aykevl, jacquesguan
    
    Differential Revision: https://reviews.llvm.org/D141752
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    c5cadd1 View commit details
    Browse the repository at this point in the history
  15. [AVR] Fix incorrect operands of pseudo instruction 'ROLBRd'

    Fixes llvm#63098
    
    Reviewed by: benshi001
    
    Differential Revision: https://reviews.llvm.org/D152063
    Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    1c5fb0c View commit details
    Browse the repository at this point in the history
  16. [AVR][NFC][test] Suppement a test of the pseudo instruction RORBRd

    Reviewed By: aykevl, Patryk27
    
    Differential Revision: https://reviews.llvm.org/D152087
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    eeb4a65 View commit details
    Browse the repository at this point in the history
  17. [AVR][NFC][test] Supplement more tests of 8-bit rotation

    Reviewed By: Patryk27, jacquesguan
    
    Differential Revision: https://reviews.llvm.org/D152129
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    b0ad3bc View commit details
    Browse the repository at this point in the history
  18. [AVR][NFC] Improve CodeGen tests

    Reviewed By: Patryk27
    
    Differential Revision: https://reviews.llvm.org/D152605
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    4f9f7c0 View commit details
    Browse the repository at this point in the history
  19. [AVR] Enable sub register liveness

    Reviewed By: Patryk27
    
    Differential Revision: https://reviews.llvm.org/D152606
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    2f895d5 View commit details
    Browse the repository at this point in the history
  20. [AVR] Fix incorrect expansion of pseudo instruction ROLBRd

    Since ROLBRd needs an implicit R1 (on AVR) or an implicit R17 (on AVRTiny),
    we split ROLBRd to ROLBRdR1 (on AVR) and ROLBRdR17 (on AVRTiny).
    
    Reviewed By: aykevl, Patryk27
    
    Differential Revision: https://reviews.llvm.org/D152248
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    b9b277b View commit details
    Browse the repository at this point in the history
  21. [AVR] Optimize 8-bit rotation when rotation bits >= 4

    Fixes llvm#63100
    
    Reviewed By: aykevl, Patryk27, jacquesguan
    
    Differential Revision: https://reviews.llvm.org/D152130
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    1201a28 View commit details
    Browse the repository at this point in the history
  22. [AVR] Optimize 8-bit rotation when rotation bits == 3

    Fixes llvm#63100
    
    Reviewed By: aykevl
    
    Differential Revision: https://reviews.llvm.org/D152365
    benshi001 authored and Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    894df9d View commit details
    Browse the repository at this point in the history
  23. [AVR] Expand shifts of all types except int8 and int16

    Currently our AVRShiftExpand pass expands only 32-bit shifts, with the
    assumption that other kinds of shifts (e.g. 64-bit ones) are
    automatically reduced to 8-bit ones by LLVM during ISel.
    
    However this is not always true and causes problems in the rust-lang runtime.
    
    This commit changes the logic a bit, so that instead of expanding only
    32-bit shifts, we expand shifts of all types except 8-bit and 16-bit.
    
    This is not the most optimal solution, because 64-bit shifts can be
    expanded to 32-bit shifts which has been deeply optimized.
    
    I've checked the generated code using rustc + simavr, and all shifts
    seem to behave correctly.
    
    Spotted in the wild in rustc:
    rust-lang/compiler-builtins#523
    rust-lang/rust#112140
    
    Reviewed By: benshi001
    
    Differential Revision: https://reviews.llvm.org/D154785
    Patryk27 committed Jul 23, 2023
    Configuration menu
    Copy the full SHA
    8b9c317 View commit details
    Browse the repository at this point in the history