llvm-project/llvm/lib/Target/Sparc
Koakuma 1466d65d9b [SPARC] Don't do leaf optimization on procedures with inline assembly
On SPARC, leaf function optimization omits the register window sliding (and the associated register name changes). This might result in miscompilation of procedures containing inline assembly, as some of the register constraints used may interfere with the register usage of optimized functions, so we disable leaf procedure optimization on those procedures to prevent it from happening.

This is a continuation of patch D102342 by @LemonBoy, the original comment is reproduced below:

> Leaf functions allow the compiler to omit the setup and teardown of a frame pointer, therefore avoiding the exchange of the in/out register. According to the SPARC architecture manual every reference to %i0-%i5 should be replaced with %o0-o5, if the target register is already in use a further remapping step to %g1-%g7 is required to free the output register.
>
> Add a simple check to make sure not to stomp on any output register that's already in use.

Reviewed By: dcederman

Differential Revision: https://reviews.llvm.org/D128263
2022-06-27 15:09:30 +02:00
..
AsmParser Fix "not all control paths return a value" MSVC warning. NFC. 2022-06-06 11:31:46 +01:00
Disassembler [MCDisassembler] Disambiguate Size parameter in tryAddingSymbolicOperand() 2022-05-25 13:44:32 -07:00
MCTargetDesc [SPARC][MC] Support more relocation types 2022-06-05 14:09:39 -04:00
TargetInfo
CMakeLists.txt
DelaySlotFiller.cpp [Sparc] Add tail call support 2022-03-08 13:50:54 +01:00
LeonFeatures.td
LeonPasses.cpp
LeonPasses.h
README.txt
Sparc.h
Sparc.td
SparcAsmPrinter.cpp
SparcCallingConv.td [Sparc] Add tail call support 2022-03-08 13:50:54 +01:00
SparcFrameLowering.cpp [SPARC] Don't do leaf optimization on procedures with inline assembly 2022-06-27 15:09:30 +02:00
SparcFrameLowering.h
SparcISelDAGToDAG.cpp
SparcISelLowering.cpp [SPARC][MC] Support more relocation types 2022-06-05 14:09:39 -04:00
SparcISelLowering.h [SPARC][MC] Support more relocation types 2022-06-05 14:09:39 -04:00
SparcInstr64Bit.td [SPARC][MC] Support more relocation types 2022-06-05 14:09:39 -04:00
SparcInstrAliases.td
SparcInstrFormats.td
SparcInstrInfo.cpp
SparcInstrInfo.h
SparcInstrInfo.td [SPARC][MC] Support more relocation types 2022-06-05 14:09:39 -04:00
SparcInstrVIS.td
SparcMCInstLower.cpp
SparcMachineFunctionInfo.cpp llvm-reduce: Add cloning of target MachineFunctionInfo 2022-06-07 10:14:48 -04:00
SparcMachineFunctionInfo.h llvm-reduce: Add cloning of target MachineFunctionInfo 2022-06-07 10:14:48 -04:00
SparcRegisterInfo.cpp
SparcRegisterInfo.h
SparcRegisterInfo.td
SparcSchedule.td
SparcSubtarget.cpp
SparcSubtarget.h
SparcTargetMachine.cpp [llvm] Use value_or instead of getValueOr (NFC) 2022-06-18 23:07:11 -07:00
SparcTargetMachine.h
SparcTargetObjectFile.cpp
SparcTargetObjectFile.h [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00

README.txt

To-do
-----

* Keep the address of the constant pool in a register instead of forming its
  address all of the time.
* We can fold small constant offsets into the %hi/%lo references to constant
  pool addresses as well.
* When in V9 mode, register allocate %icc[0-3].
* Add support for isel'ing UMUL_LOHI instead of marking it as Expand.
* Emit the 'Branch on Integer Register with Prediction' instructions.  It's
  not clear how to write a pattern for this though:

float %t1(int %a, int* %p) {
        %C = seteq int %a, 0
        br bool %C, label %T, label %F
T:
        store int 123, int* %p
        br label %F
F:
        ret float undef
}

codegens to this:

t1:
        save -96, %o6, %o6
1)      subcc %i0, 0, %l0
1)      bne .LBBt1_2    ! F
        nop
.LBBt1_1:       ! T
        or %g0, 123, %l0
        st %l0, [%i1]
.LBBt1_2:       ! F
        restore %g0, %g0, %g0
        retl
        nop

1) should be replaced with a brz in V9 mode.

* Same as above, but emit conditional move on register zero (p192) in V9
  mode.  Testcase:

int %t1(int %a, int %b) {
        %C = seteq int %a, 0
        %D = select bool %C, int %a, int %b
        ret int %D
}

* Emit MULX/[SU]DIVX instructions in V9 mode instead of fiddling
  with the Y register, if they are faster.

* Codegen bswap(load)/store(bswap) -> load/store ASI

* Implement frame pointer elimination, e.g. eliminate save/restore for
  leaf fns.
* Fill delay slots

* Use %g0 directly to materialize 0. No instruction is required.