Returns ConstantInt from G_CONSTANT instruction given its def register.
Differential Revision: https://reviews.llvm.org/D99733
class TargetPassConfig;
class TargetRegisterInfo;
class TargetRegisterClass;
+class ConstantInt;
class ConstantFP;
class APFloat;
bool LookThroughInstrs = true,
bool HandleFConstants = true,
bool LookThroughAnyExt = false);
+const ConstantInt *getConstantIntVRegVal(Register VReg,
+ const MachineRegisterInfo &MRI);
const ConstantFP* getConstantFPVRegVal(Register VReg,
const MachineRegisterInfo &MRI);
return ValueAndVReg{Val, VReg};
}
+const ConstantInt *llvm::getConstantIntVRegVal(Register VReg,
+ const MachineRegisterInfo &MRI) {
+ MachineInstr *MI = MRI.getVRegDef(VReg);
+ if (MI->getOpcode() != TargetOpcode::G_CONSTANT)
+ return nullptr;
+ return MI->getOperand(1).getCImm();
+}
+
const ConstantFP *
llvm::getConstantFPVRegVal(Register VReg, const MachineRegisterInfo &MRI) {
MachineInstr *MI = MRI.getVRegDef(VReg);