//==---- SystemZPostRewrite.cpp - Select pseudos after RegAlloc ---*- C++ -*-=// // // 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 file contains a pass that is run immediately after VirtRegRewriter // but before MachineCopyPropagation. The purpose is to lower pseudos to // target instructions before any later pass might substitute a register for // another. // //===----------------------------------------------------------------------===// #include "SystemZ.h" #include "SystemZInstrInfo.h" #include "SystemZSubtarget.h" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/LivePhysRegs.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" usingnamespacellvm; #define DEBUG_TYPE … STATISTIC(MemFoldCopies, "Number of copies inserted before folded mem ops."); STATISTIC(LOCRMuxJumps, "Number of LOCRMux jump-sequences (lower is better)"); namespace { class SystemZPostRewrite : public MachineFunctionPass { … }; char SystemZPostRewrite::ID = …; } // end anonymous namespace INITIALIZE_PASS(…) /// Returns an instance of the Post Rewrite pass. FunctionPass *llvm::createSystemZPostRewritePass(SystemZTargetMachine &TM) { … } // MI is a load-register-on-condition pseudo instruction. Replace it with // LowOpcode if source and destination are both low GR32s and HighOpcode if // source and destination are both high GR32s. Otherwise, a branch sequence // is created. void SystemZPostRewrite::selectLOCRMux(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, MachineBasicBlock::iterator &NextMBBI, unsigned LowOpcode, unsigned HighOpcode) { … } // MI is a select pseudo instruction. Replace it with LowOpcode if source // and destination are all low GR32s and HighOpcode if source and destination // are all high GR32s. Otherwise, a branch sequence is created. void SystemZPostRewrite::selectSELRMux(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, MachineBasicBlock::iterator &NextMBBI, unsigned LowOpcode, unsigned HighOpcode) { … } // Replace MBBI by a branch sequence that performs a conditional move of // operand 2 to the destination register. Operand 1 is expected to be the // same register as the destination. bool SystemZPostRewrite::expandCondMove(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, MachineBasicBlock::iterator &NextMBBI) { … } /// If MBBI references a pseudo instruction that should be selected here, /// do it and return true. Otherwise return false. bool SystemZPostRewrite::selectMI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, MachineBasicBlock::iterator &NextMBBI) { … } /// Iterate over the instructions in basic block MBB and select any /// pseudo instructions. Return true if anything was modified. bool SystemZPostRewrite::selectMBB(MachineBasicBlock &MBB) { … } bool SystemZPostRewrite::runOnMachineFunction(MachineFunction &MF) { … }