|
|
|||
File indexing completed on 2026-05-10 08:43:32
0001 //===- MachineSSAUpdater.h - Unstructured SSA Update Tool -------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file declares the MachineSSAUpdater class. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_CODEGEN_MACHINESSAUPDATER_H 0014 #define LLVM_CODEGEN_MACHINESSAUPDATER_H 0015 0016 #include "llvm/CodeGen/MachineRegisterInfo.h" 0017 #include "llvm/CodeGen/Register.h" 0018 0019 namespace llvm { 0020 0021 class MachineBasicBlock; 0022 class MachineFunction; 0023 class MachineInstr; 0024 class MachineOperand; 0025 class MachineRegisterInfo; 0026 class TargetInstrInfo; 0027 class TargetRegisterClass; 0028 template<typename T> class SmallVectorImpl; 0029 template<typename T> class SSAUpdaterTraits; 0030 0031 /// MachineSSAUpdater - This class updates SSA form for a set of virtual 0032 /// registers defined in multiple blocks. This is used when code duplication 0033 /// or another unstructured transformation wants to rewrite a set of uses of one 0034 /// vreg with uses of a set of vregs. 0035 class MachineSSAUpdater { 0036 friend class SSAUpdaterTraits<MachineSSAUpdater>; 0037 0038 private: 0039 /// AvailableVals - This keeps track of which value to use on a per-block 0040 /// basis. When we insert PHI nodes, we keep track of them here. 0041 //typedef DenseMap<MachineBasicBlock*, Register> AvailableValsTy; 0042 void *AV = nullptr; 0043 0044 /// Register class or bank and LLT of current virtual register. 0045 MachineRegisterInfo::VRegAttrs RegAttrs; 0046 0047 /// InsertedPHIs - If this is non-null, the MachineSSAUpdater adds all PHI 0048 /// nodes that it creates to the vector. 0049 SmallVectorImpl<MachineInstr*> *InsertedPHIs; 0050 0051 const TargetInstrInfo *TII = nullptr; 0052 MachineRegisterInfo *MRI = nullptr; 0053 0054 public: 0055 /// MachineSSAUpdater constructor. If InsertedPHIs is specified, it will be 0056 /// filled in with all PHI Nodes created by rewriting. 0057 explicit MachineSSAUpdater(MachineFunction &MF, 0058 SmallVectorImpl<MachineInstr*> *NewPHI = nullptr); 0059 MachineSSAUpdater(const MachineSSAUpdater &) = delete; 0060 MachineSSAUpdater &operator=(const MachineSSAUpdater &) = delete; 0061 ~MachineSSAUpdater(); 0062 0063 /// Initialize - Reset this object to get ready for a new set of SSA 0064 /// updates. 0065 void Initialize(Register V); 0066 0067 /// AddAvailableValue - Indicate that a rewritten value is available at the 0068 /// end of the specified block with the specified value. 0069 void AddAvailableValue(MachineBasicBlock *BB, Register V); 0070 0071 /// HasValueForBlock - Return true if the MachineSSAUpdater already has a 0072 /// value for the specified block. 0073 bool HasValueForBlock(MachineBasicBlock *BB) const; 0074 0075 /// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is 0076 /// live at the end of the specified block. 0077 Register GetValueAtEndOfBlock(MachineBasicBlock *BB); 0078 0079 /// GetValueInMiddleOfBlock - Construct SSA form, materializing a value that 0080 /// is live in the middle of the specified block. If ExistingValueOnly is 0081 /// true then this will only return an existing value or $noreg; otherwise new 0082 /// instructions may be inserted to materialize a value. 0083 /// 0084 /// GetValueInMiddleOfBlock is the same as GetValueAtEndOfBlock except in one 0085 /// important case: if there is a definition of the rewritten value after the 0086 /// 'use' in BB. Consider code like this: 0087 /// 0088 /// X1 = ... 0089 /// SomeBB: 0090 /// use(X) 0091 /// X2 = ... 0092 /// br Cond, SomeBB, OutBB 0093 /// 0094 /// In this case, there are two values (X1 and X2) added to the AvailableVals 0095 /// set by the client of the rewriter, and those values are both live out of 0096 /// their respective blocks. However, the use of X happens in the *middle* of 0097 /// a block. Because of this, we need to insert a new PHI node in SomeBB to 0098 /// merge the appropriate values, and this value isn't live out of the block. 0099 Register GetValueInMiddleOfBlock(MachineBasicBlock *BB, 0100 bool ExistingValueOnly = false); 0101 0102 /// RewriteUse - Rewrite a use of the symbolic value. This handles PHI nodes, 0103 /// which use their value in the corresponding predecessor. Note that this 0104 /// will not work if the use is supposed to be rewritten to a value defined in 0105 /// the same block as the use, but above it. Any 'AddAvailableValue's added 0106 /// for the use's block will be considered to be below it. 0107 void RewriteUse(MachineOperand &U); 0108 0109 private: 0110 // If ExistingValueOnly is true, will not create any new instructions. Used 0111 // for debug values, which cannot modify Codegen. 0112 Register GetValueAtEndOfBlockInternal(MachineBasicBlock *BB, 0113 bool ExistingValueOnly = false); 0114 }; 0115 0116 } // end namespace llvm 0117 0118 #endif // LLVM_CODEGEN_MACHINESSAUPDATER_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|