//===-- SystemZShortenInst.cpp - Instruction-shortening pass --------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This pass tries to replace instructions with shorter forms. For example, // IILF can be replaced with LLILL or LLILH if the constant fits and if the // other 32 bits of the GR64 destination are not live. // //===----------------------------------------------------------------------===// #include "SystemZTargetMachine.h" #include "llvm/CodeGen/LiveRegUnits.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/TargetRegisterInfo.h" usingnamespacellvm; #define DEBUG_TYPE … namespace { class SystemZShortenInst : public MachineFunctionPass { … }; char SystemZShortenInst::ID = …; } // end anonymous namespace INITIALIZE_PASS(…) FunctionPass *llvm::createSystemZShortenInstPass(SystemZTargetMachine &TM) { … } SystemZShortenInst::SystemZShortenInst() : … { … } // Tie operands if MI has become a two-address instruction. static void tieOpsIfNeeded(MachineInstr &MI) { … } // MI loads one word of a GPR using an IIxF instruction and LLIxL and LLIxH // are the halfword immediate loads for the same word. Try to use one of them // instead of IIxF. bool SystemZShortenInst::shortenIIF(MachineInstr &MI, unsigned LLIxL, unsigned LLIxH) { … } // Change MI's opcode to Opcode if register operand 0 has a 4-bit encoding. bool SystemZShortenInst::shortenOn0(MachineInstr &MI, unsigned Opcode) { … } // Change MI's opcode to Opcode if register operands 0 and 1 have a // 4-bit encoding. bool SystemZShortenInst::shortenOn01(MachineInstr &MI, unsigned Opcode) { … } // Change MI's opcode to Opcode if register operands 0, 1 and 2 have a // 4-bit encoding and if operands 0 and 1 are tied. Also ties op 0 // with op 1, if MI becomes 2-address. bool SystemZShortenInst::shortenOn001(MachineInstr &MI, unsigned Opcode) { … } // Calls shortenOn001 if CCLive is false. CC def operand is added in // case of success. bool SystemZShortenInst::shortenOn001AddCC(MachineInstr &MI, unsigned Opcode) { … } // MI is a vector-style conversion instruction with the operand order: // destination, source, exact-suppress, rounding-mode. If both registers // have a 4-bit encoding then change it to Opcode, which has operand order: // destination, rouding-mode, source, exact-suppress. bool SystemZShortenInst::shortenFPConv(MachineInstr &MI, unsigned Opcode) { … } bool SystemZShortenInst::shortenFusedFPOp(MachineInstr &MI, unsigned Opcode) { … } // Process all instructions in MBB. Return true if something changed. bool SystemZShortenInst::processBlock(MachineBasicBlock &MBB) { … } bool SystemZShortenInst::runOnMachineFunction(MachineFunction &F) { … }