@@ -541,42 +541,26 @@ SDValue XtensaTargetLowering::LowerGlobalAddress(SDValue Op,
541
541
SelectionDAG &DAG) const {
542
542
const GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Op);
543
543
SDLoc DL (Op);
544
- auto PtrVt = getPointerTy (DAG. getDataLayout () );
544
+ auto PtrVT = Op. getValueType ( );
545
545
const GlobalValue *GV = G->getGlobal ();
546
546
547
- // Check Op SDNode users
548
- // If there are only CALL nodes, don't expand Global Address
549
- SDNode &OpNode = *Op.getNode ();
550
- bool Val = false ;
551
- for (SDNode::use_iterator UI = OpNode.use_begin (); UI != OpNode.use_end ();
552
- ++UI) {
553
- SDNode &User = *UI.getUse ().getUser ();
554
- unsigned OpCode = User.getOpcode ();
555
- if (OpCode != XtensaISD::CALL) {
556
- Val = true ;
557
- break ;
558
- }
559
- }
560
- if (!Val) {
561
- SDValue TargAddr = DAG.getTargetGlobalAddress (G->getGlobal (), DL, PtrVt, 0 ,
562
- 0 /* TargetFlags */ );
563
- return TargAddr;
564
- }
565
-
566
- SDValue CPAddr = DAG.getTargetConstantPool (GV, PtrVt, Align (4 ));
547
+ SDValue CPAddr = DAG.getTargetConstantPool (GV, PtrVT, Align (4 ));
567
548
SDValue CPWrap = getAddrPCRel (CPAddr, DAG);
568
549
569
550
return CPWrap;
570
551
}
571
552
572
- SDValue XtensaTargetLowering::LowerBlockAddress (BlockAddressSDNode *Node ,
553
+ SDValue XtensaTargetLowering::LowerBlockAddress (SDValue Op ,
573
554
SelectionDAG &DAG) const {
555
+ BlockAddressSDNode *Node = cast<BlockAddressSDNode>(Op);
574
556
const BlockAddress *BA = Node->getBlockAddress ();
575
- EVT PtrVT = getPointerTy (DAG.getDataLayout ());
557
+ EVT PtrVT = Op.getValueType ();
558
+
576
559
XtensaConstantPoolValue *CPV =
577
560
XtensaConstantPoolConstant::Create (BA, 0 , XtensaCP::CPBlockAddress);
578
561
SDValue CPAddr = DAG.getTargetConstantPool (CPV, PtrVT, Align (4 ));
579
562
SDValue CPWrap = getAddrPCRel (CPAddr, DAG);
563
+
580
564
return CPWrap;
581
565
}
582
566
@@ -590,30 +574,31 @@ SDValue XtensaTargetLowering::LowerBR_JT(SDValue Op, SelectionDAG &DAG) const {
590
574
const MachineJumpTableInfo *MJTI = MF.getJumpTableInfo ();
591
575
SDValue TargetJT = DAG.getTargetJumpTable (JT->getIndex (), MVT::i32 );
592
576
const DataLayout &TD = DAG.getDataLayout ();
593
- EVT PTy = getPointerTy (TD );
577
+ EVT PtrVT = Table. getValueType ( );
594
578
unsigned EntrySize = MJTI->getEntrySize (TD);
595
579
596
580
Index = DAG.getNode (ISD::MUL, DL, Index.getValueType (), Index,
597
581
DAG.getConstant (EntrySize, DL, Index.getValueType ()));
598
582
SDValue Addr = DAG.getNode (ISD::ADD, DL, Index.getValueType (), Index, Table);
599
583
SDValue LD =
600
- DAG.getLoad (PTy , DL, Chain, Addr,
584
+ DAG.getLoad (PtrVT , DL, Chain, Addr,
601
585
MachinePointerInfo::getJumpTable (DAG.getMachineFunction ()));
586
+
602
587
return DAG.getNode (XtensaISD::BR_JT, DL, MVT::Other, LD.getValue (1 ), LD,
603
588
TargetJT);
604
589
}
605
590
606
- SDValue XtensaTargetLowering::LowerJumpTable (JumpTableSDNode *JT ,
591
+ SDValue XtensaTargetLowering::LowerJumpTable (SDValue Op ,
607
592
SelectionDAG &DAG) const {
608
- SDLoc DL (JT );
609
- EVT PtrVt = getPointerTy (DAG. getDataLayout () );
593
+ JumpTableSDNode *JT = cast<JumpTableSDNode>(Op );
594
+ EVT PtrVT = Op. getValueType ( );
610
595
611
596
// Create a constant pool entry for the callee address
612
597
XtensaConstantPoolValue *CPV =
613
598
XtensaConstantPoolJumpTable::Create (*DAG.getContext (), JT->getIndex ());
614
599
615
600
// Get the address of the callee into a register
616
- SDValue CPAddr = DAG.getTargetConstantPool (CPV, PtrVt , Align (4 ));
601
+ SDValue CPAddr = DAG.getTargetConstantPool (CPV, PtrVT , Align (4 ));
617
602
618
603
return getAddrPCRel (CPAddr, DAG);
619
604
}
@@ -686,9 +671,9 @@ SDValue XtensaTargetLowering::LowerOperation(SDValue Op,
686
671
case ISD::GlobalAddress:
687
672
return LowerGlobalAddress (Op, DAG);
688
673
case ISD::BlockAddress:
689
- return LowerBlockAddress (cast<BlockAddressSDNode>(Op) , DAG);
674
+ return LowerBlockAddress (Op , DAG);
690
675
case ISD::JumpTable:
691
- return LowerJumpTable (cast<JumpTableSDNode>(Op) , DAG);
676
+ return LowerJumpTable (Op , DAG);
692
677
case ISD::ConstantPool:
693
678
return LowerConstantPool (cast<ConstantPoolSDNode>(Op), DAG);
694
679
case ISD::STACKSAVE:
0 commit comments