llvm.org GIT mirror llvm / f171aff
[GISel]: Add a getConstantFPVRegVal utility This might be useful across various GISel Passes https://reviews.llvm.org/D33051 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302964 91177308-0d34-0410-b5e6-96231b3b80d8 Aditya Nandakumar 3 years ago
2 changed file(s) with 11 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2929 class TargetPassConfig;
3030 class TargetRegisterInfo;
3131 class Twine;
32 class ConstantFP;
3233
3334 /// Try to constrain Reg so that it is usable by argument OpIdx of the
3435 /// provided MCInstrDesc \p II. If this fails, create a new virtual
6162
6263 Optional getConstantVRegVal(unsigned VReg,
6364 const MachineRegisterInfo &MRI);
65 const ConstantFP* getConstantFPVRegVal(unsigned VReg,
66 const MachineRegisterInfo &MRI);
6467
6568 } // End namespace llvm.
6669 #endif
109109
110110 return None;
111111 }
112
113 const llvm::ConstantFP* llvm::getConstantFPVRegVal(unsigned VReg,
114 const MachineRegisterInfo &MRI) {
115 MachineInstr *MI = MRI.getVRegDef(VReg);
116 if (TargetOpcode::G_FCONSTANT != MI->getOpcode())
117 return nullptr;
118 return MI->getOperand(1).getFPImm();
119 }