@@ -2987,6 +2987,32 @@ static void getUnmergePieces(SmallVectorImpl<Register> &Pieces,
2987
2987
Pieces.push_back (Unmerge.getReg (I));
2988
2988
}
2989
2989
2990
+ LegalizerHelper::LegalizeResult
2991
+ LegalizerHelper::lowerConstant (MachineInstr &MI) {
2992
+ Register Dst = MI.getOperand (0 ).getReg ();
2993
+
2994
+ MachineFunction &MF = MIRBuilder.getMF ();
2995
+ const DataLayout &DL = MIRBuilder.getDataLayout ();
2996
+
2997
+ unsigned AddrSpace = DL.getDefaultGlobalsAddressSpace ();
2998
+ LLT AddrPtrTy = LLT::pointer (AddrSpace, DL.getPointerSizeInBits (AddrSpace));
2999
+ Align Alignment = Align (DL.getABITypeAlign (
3000
+ getFloatTypeForLLT (MF.getFunction ().getContext (), MRI.getType (Dst))));
3001
+
3002
+ auto Addr = MIRBuilder.buildConstantPool (
3003
+ AddrPtrTy, MF.getConstantPool ()->getConstantPoolIndex (
3004
+ MI.getOperand (1 ).getFPImm (), Alignment));
3005
+
3006
+ MachineMemOperand *MMO = MF.getMachineMemOperand (
3007
+ MachinePointerInfo::getConstantPool (MF), MachineMemOperand::MOLoad,
3008
+ MRI.getType (Dst), Alignment);
3009
+
3010
+ MIRBuilder.buildLoadInstr (TargetOpcode::G_LOAD, Dst, Addr, *MMO);
3011
+ MI.eraseFromParent ();
3012
+
3013
+ return Legalized;
3014
+ }
3015
+
2990
3016
LegalizerHelper::LegalizeResult
2991
3017
LegalizerHelper::lowerFConstant (MachineInstr &MI) {
2992
3018
Register Dst = MI.getOperand (0 ).getReg ();
0 commit comments