llvm.org GIT mirror llvm / e7e0d62
Remove ARMPCLabelIndex from ARMISelLowering. Use ARMFunctionInfo::createConstPoolEntryUId() instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86294 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 10 years ago
3 changed file(s) with 42 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
132132 }
133133
134134 ARMTargetLowering::ARMTargetLowering(TargetMachine &TM)
135 : TargetLowering(TM, createTLOF(TM)), ARMPCLabelIndex(0) {
135 : TargetLowering(TM, createTLOF(TM)) {
136136 Subtarget = &TM.getSubtarget();
137137
138138 if (Subtarget->isTargetDarwin()) {
10031003 bool isDirect = false;
10041004 bool isARMFunc = false;
10051005 bool isLocalARMFunc = false;
1006 MachineFunction &MF = DAG.getMachineFunction();
1007 ARMFunctionInfo *AFI = MF.getInfo();
10061008 if (GlobalAddressSDNode *G = dyn_cast(Callee)) {
10071009 GlobalValue *GV = G->getGlobal();
10081010 isDirect = true;
10141016 isLocalARMFunc = !Subtarget->isThumb() && !isExt;
10151017 // tBX takes a register source operand.
10161018 if (isARMFunc && Subtarget->isThumb1Only() && !Subtarget->hasV5TOps()) {
1019 unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId();
10171020 ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV,
10181021 ARMPCLabelIndex,
10191022 ARMCP::CPValue, 4);
10221025 Callee = DAG.getLoad(getPointerTy(), dl,
10231026 DAG.getEntryNode(), CPAddr,
10241027 PseudoSourceValue::getConstantPool(), 0);
1025 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1028 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
10261029 Callee = DAG.getNode(ARMISD::PIC_ADD, dl,
10271030 getPointerTy(), Callee, PICLabel);
10281031 } else
10351038 // tBX takes a register source operand.
10361039 const char *Sym = S->getSymbol();
10371040 if (isARMFunc && Subtarget->isThumb1Only() && !Subtarget->hasV5TOps()) {
1041 unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId();
10381042 ARMConstantPoolValue *CPV = new ARMConstantPoolValue(*DAG.getContext(),
10391043 Sym, ARMPCLabelIndex, 4);
10401044 SDValue CPAddr = DAG.getTargetConstantPool(CPV, getPointerTy(), 4);
10421046 Callee = DAG.getLoad(getPointerTy(), dl,
10431047 DAG.getEntryNode(), CPAddr,
10441048 PseudoSourceValue::getConstantPool(), 0);
1045 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1049 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
10461050 Callee = DAG.getNode(ARMISD::PIC_ADD, dl,
10471051 getPointerTy(), Callee, PICLabel);
10481052 } else
12071211 }
12081212
12091213 SDValue ARMTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) {
1214 MachineFunction &MF = DAG.getMachineFunction();
1215 ARMFunctionInfo *AFI = MF.getInfo();
1216 unsigned ARMPCLabelIndex = 0;
12101217 DebugLoc DL = Op.getDebugLoc();
12111218 EVT PtrVT = getPointerTy();
12121219 BlockAddress *BA = cast(Op)->getBlockAddress();
12161223 CPAddr = DAG.getTargetConstantPool(BA, PtrVT, 4);
12171224 } else {
12181225 unsigned PCAdj = Subtarget->isThumb() ? 4 : 8;
1226 ARMPCLabelIndex = AFI->createConstPoolEntryUId();
12191227 ARMConstantPoolValue *CPV = new ARMConstantPoolValue(BA, ARMPCLabelIndex,
12201228 ARMCP::CPBlockAddress,
12211229 PCAdj);
12261234 PseudoSourceValue::getConstantPool(), 0);
12271235 if (RelocM == Reloc::Static)
12281236 return Result;
1229 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1237 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
12301238 return DAG.getNode(ARMISD::PIC_ADD, DL, PtrVT, Result, PICLabel);
12311239 }
12321240
12371245 DebugLoc dl = GA->getDebugLoc();
12381246 EVT PtrVT = getPointerTy();
12391247 unsigned char PCAdj = Subtarget->isThumb() ? 4 : 8;
1248 MachineFunction &MF = DAG.getMachineFunction();
1249 ARMFunctionInfo *AFI = MF.getInfo();
1250 unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId();
12401251 ARMConstantPoolValue *CPV =
12411252 new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex,
12421253 ARMCP::CPValue, PCAdj, "tlsgd", true);
12461257 PseudoSourceValue::getConstantPool(), 0);
12471258 SDValue Chain = Argument.getValue(1);
12481259
1249 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1260 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
12501261 Argument = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Argument, PICLabel);
12511262
12521263 // call __tls_get_addr.
12781289 SDValue ThreadPointer = DAG.getNode(ARMISD::THREAD_POINTER, dl, PtrVT);
12791290
12801291 if (GV->isDeclaration()) {
1281 // initial exec model
1292 MachineFunction &MF = DAG.getMachineFunction();
1293 ARMFunctionInfo *AFI = MF.getInfo();
1294 unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId();
1295 // Initial exec model.
12821296 unsigned char PCAdj = Subtarget->isThumb() ? 4 : 8;
12831297 ARMConstantPoolValue *CPV =
12841298 new ARMConstantPoolValue(GA->getGlobal(), ARMPCLabelIndex,
12891303 PseudoSourceValue::getConstantPool(), 0);
12901304 Chain = Offset.getValue(1);
12911305
1292 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1306 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
12931307 Offset = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Offset, PICLabel);
12941308
12951309 Offset = DAG.getLoad(PtrVT, dl, Chain, Offset,
13541368
13551369 SDValue ARMTargetLowering::LowerGlobalAddressDarwin(SDValue Op,
13561370 SelectionDAG &DAG) {
1371 MachineFunction &MF = DAG.getMachineFunction();
1372 ARMFunctionInfo *AFI = MF.getInfo();
1373 unsigned ARMPCLabelIndex = 0;
13571374 EVT PtrVT = getPointerTy();
13581375 DebugLoc dl = Op.getDebugLoc();
13591376 GlobalValue *GV = cast(Op)->getGlobal();
13621379 if (RelocM == Reloc::Static)
13631380 CPAddr = DAG.getTargetConstantPool(GV, PtrVT, 4);
13641381 else {
1382 ARMPCLabelIndex = AFI->createConstPoolEntryUId();
13651383 unsigned PCAdj = (RelocM != Reloc::PIC_) ? 0 : (Subtarget->isThumb()?4:8);
13661384 ARMConstantPoolValue *CPV =
13671385 new ARMConstantPoolValue(GV, ARMPCLabelIndex, ARMCP::CPValue, PCAdj);
13741392 SDValue Chain = Result.getValue(1);
13751393
13761394 if (RelocM == Reloc::PIC_) {
1377 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1395 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
13781396 Result = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel);
13791397 }
13801398
13891407 SelectionDAG &DAG){
13901408 assert(Subtarget->isTargetELF() &&
13911409 "GLOBAL OFFSET TABLE not implemented for non-ELF targets");
1410 MachineFunction &MF = DAG.getMachineFunction();
1411 ARMFunctionInfo *AFI = MF.getInfo();
1412 unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId();
13921413 EVT PtrVT = getPointerTy();
13931414 DebugLoc dl = Op.getDebugLoc();
13941415 unsigned PCAdj = Subtarget->isThumb() ? 4 : 8;
13991420 CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
14001421 SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr,
14011422 PseudoSourceValue::getConstantPool(), 0);
1402 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1423 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
14031424 return DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel);
14041425 }
14051426
14151436 }
14161437 case Intrinsic::eh_sjlj_lsda: {
14171438 MachineFunction &MF = DAG.getMachineFunction();
1439 ARMFunctionInfo *AFI = MF.getInfo();
1440 unsigned ARMPCLabelIndex = AFI->createConstPoolEntryUId();
14181441 EVT PtrVT = getPointerTy();
14191442 DebugLoc dl = Op.getDebugLoc();
14201443 Reloc::Model RelocM = getTargetMachine().getRelocationModel();
14321455 SDValue Chain = Result.getValue(1);
14331456
14341457 if (RelocM == Reloc::PIC_) {
1435 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex++, MVT::i32);
1458 SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32);
14361459 Result = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel);
14371460 }
14381461 return Result;
198198 if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")";
199199 if (ACPV->getPCAdjustment() != 0) {
200200 O << "-(" << MAI->getPrivateGlobalPrefix() << "PC"
201 << ACPV->getLabelId()
201 << getFunctionNumber() << "_" << ACPV->getLabelId()
202202 << "+" << (unsigned)ACPV->getPCAdjustment();
203203 if (ACPV->mustAddCurrentAddress())
204204 O << "-.";
843843
844844 void ARMAsmPrinter::printPCLabel(const MachineInstr *MI, int OpNum) {
845845 int Id = (int)MI->getOperand(OpNum).getImm();
846 O << MAI->getPrivateGlobalPrefix() << "PC" << Id;
846 O << MAI->getPrivateGlobalPrefix()
847 << "PC" << getFunctionNumber() << "_" << Id;
847848 }
848849
849850 void ARMAsmPrinter::printRegisterList(const MachineInstr *MI, int OpNum) {
13631364 // FIXME: MOVE TO SHARED PLACE.
13641365 unsigned Id = (unsigned)MI->getOperand(2).getImm();
13651366 const char *Prefix = MAI->getPrivateGlobalPrefix();
1366 MCSymbol *Label =OutContext.GetOrCreateSymbol(Twine(Prefix)+"PC"+Twine(Id));
1367 MCSymbol *Label =OutContext.GetOrCreateSymbol(Twine(Prefix)
1368 + "PC" + Twine(getFunctionNumber()) + "_" + Twine(Id));
13671369 OutStreamer.EmitLabel(Label);
13681370
13691371
3939
4040 ; DarwinPIC: _test1:
4141 ; DarwinPIC: ldr r0, LCPI1_0
42 ; DarwinPIC: LPC0:
42 ; DarwinPIC: LPC1_0:
4343 ; DarwinPIC: ldr r0, [pc, +r0]
4444 ; DarwinPIC: ldr r0, [r0]
4545 ; DarwinPIC: bx lr
4646
4747 ; DarwinPIC: .align 2
4848 ; DarwinPIC: LCPI1_0:
49 ; DarwinPIC: .long L_G$non_lazy_ptr-(LPC0+8)
49 ; DarwinPIC: .long L_G$non_lazy_ptr-(LPC1_0+8)
5050
5151 ; DarwinPIC: .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
5252 ; DarwinPIC: .align 2
6060 ; LinuxPIC: ldr r0, .LCPI1_0
6161 ; LinuxPIC: ldr r1, .LCPI1_1
6262
63 ; LinuxPIC: .LPC0:
63 ; LinuxPIC: .LPC1_0:
6464 ; LinuxPIC: add r0, pc, r0
6565 ; LinuxPIC: ldr r0, [r1, +r0]
6666 ; LinuxPIC: ldr r0, [r0]
6868
6969 ; LinuxPIC: .align 2
7070 ; LinuxPIC: .LCPI1_0:
71 ; LinuxPIC: .long _GLOBAL_OFFSET_TABLE_-(.LPC0+8)
71 ; LinuxPIC: .long _GLOBAL_OFFSET_TABLE_-(.LPC1_0+8)
7272 ; LinuxPIC: .align 2
7373 ; LinuxPIC: .LCPI1_1:
7474 ; LinuxPIC: .long G(GOT)