@@ -75,7 +75,7 @@ XtensaTargetLowering::XtensaTargetLowering(const TargetMachine &TM,
7575
7676 setOperationAction (ISD::Constant, MVT::i32 , Custom);
7777 setOperationAction (ISD::Constant, MVT::i64 , Expand);
78- setOperationAction (ISD::ConstantFP, MVT::f32 , Custom );
78+ setOperationAction (ISD::ConstantFP, MVT::f32 , Expand );
7979 setOperationAction (ISD::ConstantFP, MVT::f64 , Expand);
8080
8181 setBooleanContents (ZeroOrOneBooleanContent);
@@ -687,15 +687,19 @@ XtensaTargetLowering::LowerCall(CallLoweringInfo &CLI,
687687 if ((!name.empty ()) && isLongCall (name.c_str ())) {
688688 // Create a constant pool entry for the callee address
689689 XtensaCP::XtensaCPModifier Modifier = XtensaCP::no_modifier;
690+ XtensaMachineFunctionInfo *XtensaFI =
691+ MF.getInfo <XtensaMachineFunctionInfo>();
692+ unsigned LabelId = XtensaFI->createCPLabelId ();
690693
691694 XtensaConstantPoolValue *CPV = XtensaConstantPoolSymbol::Create (
692- *DAG.getContext (), name.c_str (), 0 /* XtensaCLabelIndex */ , false ,
693- Modifier);
695+ *DAG.getContext (), name.c_str (), LabelId, false , Modifier);
694696
695697 // Get the address of the callee into a register
696698 SDValue CPAddr = DAG.getTargetConstantPool (CPV, PtrVT, Align (4 ), 0 , TF);
697699 SDValue CPWrap = getAddrPCRel (CPAddr, DAG);
698- Callee = CPWrap;
700+ Callee = DAG.getLoad (
701+ PtrVT, DL, DAG.getEntryNode (), CPWrap,
702+ MachinePointerInfo::getConstantPool (DAG.getMachineFunction ()));
699703 }
700704
701705 // The first call operand is the chain and the second is the target address.
@@ -893,22 +897,9 @@ SDValue XtensaTargetLowering::LowerImmediate(SDValue Op,
893897 Type *Ty = Type::getInt32Ty (*DAG.getContext ());
894898 Constant *CV = ConstantInt::get (Ty, Value);
895899 SDValue CP = DAG.getConstantPool (CV, MVT::i32 );
896- return CP;
897- }
898- return Op;
899- }
900-
901- SDValue XtensaTargetLowering::LowerImmediateFP (SDValue Op,
902- SelectionDAG &DAG) const {
903- const ConstantFPSDNode *CN = cast<ConstantFPSDNode>(Op);
904- SDLoc DL (CN);
905- APFloat apval = CN->getValueAPF ();
906- int64_t value = llvm::bit_cast<uint32_t >(CN->getValueAPF ().convertToFloat ());
907- if (Op.getValueType () == MVT::f32 ) {
908- Type *Ty = Type::getInt32Ty (*DAG.getContext ());
909- Constant *CV = ConstantInt::get (Ty, value);
910- SDValue CP = DAG.getConstantPool (CV, MVT::i32 );
911- return DAG.getNode (ISD::BITCAST, DL, MVT::f32 , CP);
900+ SDValue Res =
901+ DAG.getLoad (MVT::i32 , DL, DAG.getEntryNode (), CP, MachinePointerInfo ());
902+ return Res;
912903 }
913904 return Op;
914905}
@@ -922,22 +913,30 @@ SDValue XtensaTargetLowering::LowerGlobalAddress(SDValue Op,
922913
923914 SDValue CPAddr = DAG.getTargetConstantPool (GV, PtrVT, Align (4 ));
924915 SDValue CPWrap = getAddrPCRel (CPAddr, DAG);
925-
926- return CPWrap;
916+ SDValue Res = DAG.getLoad (
917+ PtrVT, DL, DAG.getEntryNode (), CPWrap,
918+ MachinePointerInfo::getConstantPool (DAG.getMachineFunction ()));
919+ return Res;
927920}
928921
929922SDValue XtensaTargetLowering::LowerBlockAddress (SDValue Op,
930923 SelectionDAG &DAG) const {
931924 BlockAddressSDNode *Node = cast<BlockAddressSDNode>(Op);
925+ SDLoc DL (Op);
932926 const BlockAddress *BA = Node->getBlockAddress ();
933927 EVT PtrVT = Op.getValueType ();
928+ MachineFunction &MF = DAG.getMachineFunction ();
929+ XtensaMachineFunctionInfo *XtensaFI = MF.getInfo <XtensaMachineFunctionInfo>();
930+ unsigned LabelId = XtensaFI->createCPLabelId ();
934931
935932 XtensaConstantPoolValue *CPV =
936- XtensaConstantPoolConstant::Create (BA, 0 , XtensaCP::CPBlockAddress);
933+ XtensaConstantPoolConstant::Create (BA, LabelId , XtensaCP::CPBlockAddress);
937934 SDValue CPAddr = DAG.getTargetConstantPool (CPV, PtrVT, Align (4 ));
938935 SDValue CPWrap = getAddrPCRel (CPAddr, DAG);
939-
940- return CPWrap;
936+ SDValue Res = DAG.getLoad (
937+ PtrVT, DL, DAG.getEntryNode (), CPWrap,
938+ MachinePointerInfo::getConstantPool (DAG.getMachineFunction ()));
939+ return Res;
941940}
942941
943942SDValue XtensaTargetLowering::LowerBR_JT (SDValue Op, SelectionDAG &DAG) const {
@@ -972,15 +971,19 @@ SDValue XtensaTargetLowering::LowerJumpTable(SDValue Op,
972971 SelectionDAG &DAG) const {
973972 JumpTableSDNode *JT = cast<JumpTableSDNode>(Op);
974973 EVT PtrVT = Op.getValueType ();
974+ SDLoc DL (Op);
975975
976- // Create a constant pool entry for the callee address
976+ // Create a constant pool entry for the jumptable address
977977 XtensaConstantPoolValue *CPV =
978978 XtensaConstantPoolJumpTable::Create (*DAG.getContext (), JT->getIndex ());
979979
980- // Get the address of the callee into a register
980+ // Get the address of the jumptable into a register
981981 SDValue CPAddr = DAG.getTargetConstantPool (CPV, PtrVT, Align (4 ));
982982
983- return getAddrPCRel (CPAddr, DAG);
983+ SDValue Res = DAG.getLoad (
984+ PtrVT, DL, DAG.getEntryNode (), getAddrPCRel (CPAddr, DAG),
985+ MachinePointerInfo::getConstantPool (DAG.getMachineFunction ()));
986+ return Res;
984987}
985988
986989SDValue XtensaTargetLowering::getAddrPCRel (SDValue Op,
@@ -1346,8 +1349,6 @@ SDValue XtensaTargetLowering::LowerOperation(SDValue Op,
13461349 return LowerBR_JT (Op, DAG);
13471350 case ISD::Constant:
13481351 return LowerImmediate (Op, DAG);
1349- case ISD::ConstantFP:
1350- return LowerImmediateFP (Op, DAG);
13511352 case ISD::RETURNADDR:
13521353 return LowerRETURNADDR (Op, DAG);
13531354 case ISD::GlobalAddress:
0 commit comments