llvm-project/llvm/lib/Target/Hexagon
Sid Manning 7fee4fed4c Add support for Linux/Musl ABI
Differential revision: https://reviews.llvm.org/D72701

The patch adds a new option ABI for Hexagon. It primary deals with
the way variable arguments are passed and is use in the Hexagon Linux Musl
environment.

If a callee function has a variable argument list, it must perform the
following operations to set up its function prologue:

  1. Determine the number of registers which could have been used for passing
     unnamed arguments. This can be calculated by counting the number of
     registers used for passing named arguments. For example, if the callee
     function is as follows:

         int foo(int a, ...){ ... }

     ... then register R0 is used to access the argument ' a '. The registers
     available for passing unnamed arguments are R1, R2, R3, R4, and R5.

  2. Determine the number and size of the named arguments on the stack.

  3. If the callee has named arguments on the stack, it should copy all of these
     arguments to a location below the current position on the stack, and the
     difference should be the size of the register-saved area plus padding
     (if any is necessary).

     The register-saved area constitutes all the registers that could have
     been used to pass unnamed arguments. If the number of registers forming
     the register-saved area is odd, it requires 4 bytes of padding; if the
     number is even, no padding is required. This is done to ensure an 8-byte
     alignment on the stack.  For example, if the callee is as follows:

       int foo(int a, ...){ ... }

     ... then the named arguments should be copied to the following location:

       current_position - 5 (for R1-R5) * 4 (bytes) - 4 (bytes of padding)

     If the callee is as follows:

        int foo(int a, int b, ...){ ... }

     ... then the named arguments should be copied to the following location:

        current_position - 4 (for R2-R5) * 4 (bytes) - 0 (bytes of padding)

  4. After any named arguments have been copied, copy all the registers that
     could have been used to pass unnamed arguments on the stack. If the number
     of registers is odd, leave 4 bytes of padding and then start copying them
     on the stack; if the number is even, no padding is required. This
     constitutes the register-saved area. If padding is required, ensure
     that the start location of padding is 8-byte aligned.  If no padding is
     required, ensure that the start location of the on-stack copy of the
     first register which might have a variable argument is 8-byte aligned.

  5. Decrement the stack pointer by the size of register saved area plus the
     padding.  For example, if the callee is as follows:

        int foo(int a, ...){ ... } ;

     ... then the decrement value should be the following:

        5 (for R1-R5) * 4 (bytes) + 4 (bytes of padding) = 24 bytes

     The decrement should be performed before the allocframe instruction.
     Increment the stack-pointer back by the same amount before returning
     from the function.
2020-01-20 09:59:56 -06:00
..
AsmParser CMake: Make most target symbols hidden by default 2020-01-14 19:46:52 -08:00
Disassembler CMake: Make most target symbols hidden by default 2020-01-14 19:46:52 -08:00
MCTargetDesc [Hexagon] Use itinerary for assembler HVX resource checking 2020-01-17 13:14:04 -06:00
TargetInfo CMake: Make most target symbols hidden by default 2020-01-14 19:46:52 -08:00
BitTracker.cpp [Hexagon] Fixes -Wrange-loop-analysis warnings 2019-12-22 19:35:02 +01:00
BitTracker.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt [Hexagon] Remove support for V4 2018-10-19 17:31:11 +00:00
Hexagon.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Hexagon.td [Hexagon] Improve HVX version checks 2020-01-17 09:40:26 -06:00
HexagonAsmPrinter.cpp CMake: Make most target symbols hidden by default 2020-01-14 19:46:52 -08:00
HexagonAsmPrinter.h Include what you use in HexagonAsmPrinter.h 2019-06-03 11:41:18 +00:00
HexagonBitSimplify.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
HexagonBitTracker.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
HexagonBitTracker.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonBlockRanges.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
HexagonBlockRanges.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonBranchRelaxation.cpp [Alignment][NFC] Remove unneeded llvm:: scoping on Align types 2019-09-27 12:54:21 +00:00
HexagonCFGOptimizer.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonCallingConv.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonCommonGEP.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
HexagonConstExtenders.cpp [Hexagon] Add a target feature to disable compound instructions 2020-01-16 12:37:30 -06:00
HexagonConstPropagation.cpp Reland 'Fixed -Wdeprecated-copy warnings. NFCI.' 2019-11-23 23:09:39 +01:00
HexagonCopyToCombine.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
HexagonDepArch.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepArch.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepDecoders.inc [Hexagon] Rename textually included file from .h to .inc 2019-01-31 21:58:42 +00:00
HexagonDepIICHVX.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepIICScalar.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepITypes.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepITypes.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepInstrFormats.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepInstrInfo.td [Hexagon] Add prev65 subtarget feature 2020-01-17 09:27:27 -06:00
HexagonDepMapAsm2Intrin.td [Hexagon] Update autogeneated intrinsic information in LLVM 2020-01-16 13:11:18 -06:00
HexagonDepMappings.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonDepOperands.td Reapply r372285 "GlobalISel: Don't materialize immarg arguments to intrinsics" 2019-09-19 16:26:14 +00:00
HexagonDepTimingClasses.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonEarlyIfConv.cpp Fix "pointer is null" static analyzer warnings. NFCI. 2020-01-10 11:10:42 +00:00
HexagonExpandCondsets.cpp Make more use of MachineInstr::mayLoadOrStore. 2019-12-19 11:51:52 +00:00
HexagonFixupHwLoops.cpp [Alignment][NFC] Remove unneeded llvm:: scoping on Align types 2019-09-27 12:54:21 +00:00
HexagonFrameLowering.cpp Add support for Linux/Musl ABI 2020-01-20 09:59:56 -06:00
HexagonFrameLowering.h Add support for Linux/Musl ABI 2020-01-20 09:59:56 -06:00
HexagonGenExtract.cpp [IR] Split out target specific intrinsic enums into separate headers 2019-12-11 18:02:14 -08:00
HexagonGenInsert.cpp Reland 'Fixed -Wdeprecated-copy warnings. NFCI.' 2019-11-23 23:09:39 +01:00
HexagonGenMux.cpp [Hexagon] Validate the iterators before converting them to mux. 2019-11-14 13:01:16 -06:00
HexagonGenPredicate.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
HexagonHardwareLoops.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
HexagonHazardRecognizer.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonHazardRecognizer.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonIICHVX.td [Hexagon] Avoid creating 5-instruction packets with vgather pseudos 2019-03-06 17:43:50 +00:00
HexagonIICScalar.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonISelDAGToDAG.cpp [Hexagon] Add a target feature to disable compound instructions 2020-01-16 12:37:30 -06:00
HexagonISelDAGToDAG.h [Hexagon] Update PS_aligna with max stack alignment once isel completes 2019-11-12 11:47:29 -06:00
HexagonISelDAGToDAGHVX.cpp [IR] Split out target specific intrinsic enums into separate headers 2019-12-11 18:02:14 -08:00
HexagonISelLowering.cpp Add support for Linux/Musl ABI 2020-01-20 09:59:56 -06:00
HexagonISelLowering.h Add support for Linux/Musl ABI 2020-01-20 09:59:56 -06:00
HexagonISelLoweringHVX.cpp [DAGCombine] Initialize the default operation action for SIGN_EXTEND_INREG for vector type as 'expand' instead of 'legal' 2020-01-03 03:26:41 +00:00
HexagonInstrFormats.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonInstrFormatsV5.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonInstrFormatsV60.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonInstrFormatsV65.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonInstrInfo.cpp Make more use of MachineInstr::mayLoadOrStore. 2019-12-19 11:51:52 +00:00
HexagonInstrInfo.h Use MCRegister in copyPhysReg 2019-11-11 14:42:33 +05:30
HexagonIntrinsics.td [Hexagon] Remove incorrect intrinsic definition and invalid testcase 2019-11-21 09:18:15 -06:00
HexagonIntrinsicsV5.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonIntrinsicsV60.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonLoopIdiomRecognition.cpp Revert "[SCEV] Move ScalarEvolutionExpander.cpp to Transforms/Utils (NFC)." 2020-01-04 18:44:38 +00:00
HexagonMCInstLower.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonMachineFunctionInfo.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonMachineFunctionInfo.h Add support for Linux/Musl ABI 2020-01-20 09:59:56 -06:00
HexagonMachineScheduler.cpp Implementation of asm-goto support in LLVM 2019-02-08 20:48:56 +00:00
HexagonMachineScheduler.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonMapAsm2IntrinV62.gen.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonMapAsm2IntrinV65.gen.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonNewValueJump.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
HexagonOperands.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonOptAddrMode.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
HexagonOptimizeSZextends.cpp [IR] Split out target specific intrinsic enums into separate headers 2019-12-11 18:02:14 -08:00
HexagonPatterns.td [Hexagon] Add a target feature to disable compound instructions 2020-01-16 12:37:30 -06:00
HexagonPatternsHVX.td [Hexagon] Bitcast v4i16 to v8i8, unify no-op casts between scalar and HVX 2019-09-23 14:33:27 +00:00
HexagonPatternsV65.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonPeephole.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
HexagonPseudo.td [Hexagon] Fix vector spill expansion to use proper alignment 2019-11-12 09:43:21 -06:00
HexagonRDFOpt.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
HexagonRegisterInfo.cpp [Hexagon] Fix vector spill expansion to use proper alignment 2019-11-12 09:43:21 -06:00
HexagonRegisterInfo.h [TargetRegisterInfo] Default trackLivenessAfterRegAlloc() to true 2020-01-19 14:20:37 -08:00
HexagonRegisterInfo.td [NFC] Fix trivial typos in comments 2020-01-06 10:50:26 +00:00
HexagonSchedule.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonScheduleV5.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonScheduleV55.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonScheduleV60.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonScheduleV62.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonScheduleV65.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonScheduleV66.td Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonSelectionDAGInfo.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonSelectionDAGInfo.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonSplitConst32AndConst64.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
HexagonSplitDouble.cpp Make more use of MachineInstr::mayLoadOrStore. 2019-12-19 11:51:52 +00:00
HexagonStoreWidening.cpp Make more use of MachineInstr::mayLoadOrStore. 2019-12-19 11:51:52 +00:00
HexagonSubtarget.cpp Add support for Linux/Musl ABI 2020-01-20 09:59:56 -06:00
HexagonSubtarget.h Add support for Linux/Musl ABI 2020-01-20 09:59:56 -06:00
HexagonTargetMachine.cpp CMake: Make most target symbols hidden by default 2020-01-14 19:46:52 -08:00
HexagonTargetMachine.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonTargetObjectFile.cpp Revert "Honor -fuse-init-array when os is not specified on x86" 2019-12-17 07:36:59 -08:00
HexagonTargetObjectFile.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonTargetStreamer.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
HexagonTargetTransformInfo.cpp [ARM] Teach the Arm cost model that a Shift can be folded into other instructions 2019-12-09 10:24:33 +00:00
HexagonTargetTransformInfo.h [ARM] Teach the Arm cost model that a Shift can be folded into other instructions 2019-12-09 10:24:33 +00:00
HexagonVExtract.cpp [Hexagon] Handle stack realignment in hexagon-vextract 2019-11-12 09:43:21 -06:00
HexagonVLIWPacketizer.cpp [Hexagon] Fixes -Wrange-loop-analysis warnings 2019-12-22 19:35:02 +01:00
HexagonVLIWPacketizer.h Prune two MachineInstr.h includes, fix up deps 2019-10-19 00:22:07 +00:00
HexagonVectorLoopCarriedReuse.cpp [IR] Split out target specific intrinsic enums into separate headers 2019-12-11 18:02:14 -08:00
HexagonVectorPrint.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RDFCopy.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
RDFCopy.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RDFDeadCode.cpp Prune two MachineInstr.h includes, fix up deps 2019-10-19 00:22:07 +00:00
RDFDeadCode.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RDFGraph.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
RDFGraph.h Hexagon RDF: Replace function template (plus explicit specializations) with non-template overloads 2019-03-11 23:10:33 +00:00
RDFLiveness.cpp [Hexagon] Fixes -Wrange-loop-analysis warnings 2019-12-22 19:35:02 +01:00
RDFLiveness.h Hexagon RDF: Replace function template (plus explicit specializations) with non-template overloads 2019-03-11 23:10:33 +00:00
RDFRegisters.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
RDFRegisters.h Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00