[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC.h PPCAsmPrinter.cpp PPCCodeEmitter.cpp PPCISelLowering.cpp PPCSubtarget.cpp PPCTargetMachine.cpp
Evan Cheng
evan.cheng at apple.com
Wed Feb 22 12:19:56 PST 2006
Changes in directory llvm/lib/Target/PowerPC:
PPC.h updated: 1.26 -> 1.27
PPCAsmPrinter.cpp updated: 1.153 -> 1.154
PPCCodeEmitter.cpp updated: 1.46 -> 1.47
PPCISelLowering.cpp updated: 1.90 -> 1.91
PPCSubtarget.cpp updated: 1.17 -> 1.18
PPCTargetMachine.cpp updated: 1.79 -> 1.80
---
Log message:
- Added option -relocation-model to set relocation model. Valid values include static, pic,
dynamic-no-pic, and default.
PPC and x86 default is dynamic-no-pic for Darwin, pic for others.
- Removed options -enable-pic and -ppc-static.
---
Diffs of the changes: (+21 -21)
PPC.h | 1 -
PPCAsmPrinter.cpp | 12 ++++++------
PPCCodeEmitter.cpp | 4 +++-
PPCISelLowering.cpp | 8 ++++----
PPCSubtarget.cpp | 8 +-------
PPCTargetMachine.cpp | 9 +++++++--
6 files changed, 21 insertions(+), 21 deletions(-)
Index: llvm/lib/Target/PowerPC/PPC.h
diff -u llvm/lib/Target/PowerPC/PPC.h:1.26 llvm/lib/Target/PowerPC/PPC.h:1.27
--- llvm/lib/Target/PowerPC/PPC.h:1.26 Fri Feb 17 18:08:58 2006
+++ llvm/lib/Target/PowerPC/PPC.h Wed Feb 22 14:19:42 2006
@@ -31,7 +31,6 @@
FunctionPass *createDarwinAsmPrinter(std::ostream &OS, TargetMachine &TM);
FunctionPass *createAIXAsmPrinter(std::ostream &OS, TargetMachine &TM);
-extern bool PPCGenerateStaticCode;
extern PPCTargetEnum PPCTarget;
} // end namespace llvm;
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.153 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.154
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.153 Wed Feb 22 13:02:11 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Wed Feb 22 14:19:42 2006
@@ -132,7 +132,7 @@
}
void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
const MachineOperand &MO = MI->getOperand(OpNo);
- if (!PPCGenerateStaticCode) {
+ if (TM.getRelocationModel() != Reloc::Static) {
if (MO.getType() == MachineOperand::MO_GlobalAddress) {
GlobalValue *GV = MO.getGlobal();
if (((GV->isExternal() || GV->hasWeakLinkage() ||
@@ -167,7 +167,7 @@
} else {
O << "ha16(";
printOp(MI->getOperand(OpNo));
- if (PICEnabled)
+ if (TM.getRelocationModel() == Reloc::PIC)
O << "-\"L" << getFunctionNumber() << "$pb\")";
else
O << ')';
@@ -179,7 +179,7 @@
} else {
O << "lo16(";
printOp(MI->getOperand(OpNo));
- if (PICEnabled)
+ if (TM.getRelocationModel() == Reloc::PIC)
O << "-\"L" << getFunctionNumber() << "$pb\")";
else
O << ')';
@@ -362,7 +362,7 @@
return;
case MachineOperand::MO_ExternalSymbol:
// Computing the address of an external symbol, not calling it.
- if (!PPCGenerateStaticCode) {
+ if (TM.getRelocationModel() != Reloc::Static) {
std::string Name(GlobalPrefix); Name += MO.getSymbolName();
GVStubs.insert(Name);
O << "L" << Name << "$non_lazy_ptr";
@@ -377,7 +377,7 @@
int offset = MO.getOffset();
// External or weakly linked global variables need non-lazily-resolved stubs
- if (!PPCGenerateStaticCode) {
+ if (TM.getRelocationModel() != Reloc::Static) {
if (((GV->isExternal() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage()))) {
GVStubs.insert(Name);
@@ -585,7 +585,7 @@
}
// Output stubs for dynamically-linked functions
- if (PICEnabled) {
+ if (TM.getRelocationModel() == Reloc::PIC) {
for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
i != e; ++i) {
SwitchSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
Index: llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp
diff -u llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.46 llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.47
--- llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.46 Fri Feb 17 18:08:58 2006
+++ llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp Wed Feb 22 14:19:42 2006
@@ -86,6 +86,9 @@
}
bool PPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
+ assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
+ MF.getTarget().getRelocationModel() != Reloc::Static) &&
+ "JIT relocation model must be set to static or default!");
MCE.startFunction(MF);
MCE.emitConstantPool(MF.getConstantPool());
for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB)
@@ -118,7 +121,6 @@
}
void PPCCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
- assert(!PICEnabled && "CodeEmitter does not support PIC!");
BBLocations[&MBB] = MCE.getCurrentPCValue();
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){
MachineInstr &MI = *I;
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.90 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.91
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.90 Tue Feb 21 18:56:38 2006
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Wed Feb 22 14:19:42 2006
@@ -396,7 +396,7 @@
SDOperand CPI = DAG.getTargetConstantPool(C, MVT::i32, CP->getAlignment());
SDOperand Zero = DAG.getConstant(0, MVT::i32);
- if (PPCGenerateStaticCode) {
+ if (getTargetMachine().getRelocationModel() == Reloc::Static) {
// Generate non-pic code that has direct accesses to the constant pool.
// The address of the global is just (hi(&g)+lo(&g)).
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, CPI, Zero);
@@ -407,7 +407,7 @@
// Only lower ConstantPool on Darwin.
if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, CPI, Zero);
- if (PICEnabled) {
+ if (getTargetMachine().getRelocationModel() == Reloc::PIC) {
// With PIC, the first instruction is actually "GR+hi(&G)".
Hi = DAG.getNode(ISD::ADD, MVT::i32,
DAG.getNode(PPCISD::GlobalBaseReg, MVT::i32), Hi);
@@ -423,7 +423,7 @@
SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i32, GSDN->getOffset());
SDOperand Zero = DAG.getConstant(0, MVT::i32);
- if (PPCGenerateStaticCode) {
+ if (getTargetMachine().getRelocationModel() == Reloc::Static) {
// Generate non-pic code that has direct accesses to globals.
// The address of the global is just (hi(&g)+lo(&g)).
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
@@ -435,7 +435,7 @@
if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
- if (PICEnabled) {
+ if (getTargetMachine().getRelocationModel() == Reloc::PIC) {
// With PIC, the first instruction is actually "GR+hi(&G)".
Hi = DAG.getNode(ISD::ADD, MVT::i32,
DAG.getNode(PPCISD::GlobalBaseReg, MVT::i32), Hi);
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
diff -u llvm/lib/Target/PowerPC/PPCSubtarget.cpp:1.17 llvm/lib/Target/PowerPC/PPCSubtarget.cpp:1.18
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp:1.17 Fri Jan 27 23:40:47 2006
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp Wed Feb 22 14:19:42 2006
@@ -19,7 +19,6 @@
using namespace llvm;
PPCTargetEnum llvm::PPCTarget = TargetDefault;
-bool llvm::PPCGenerateStaticCode = false;
namespace llvm {
cl::opt<PPCTargetEnum, true>
@@ -29,12 +28,7 @@
clEnumValN(TargetDarwin,"darwin",
" Enable Darwin codegen"),
clEnumValEnd),
- cl::location(PPCTarget), cl::init(TargetDefault));
-
- cl::opt<bool, true>
- PPCStaticCode("ppc-static",
- cl::desc("PowerPC: generate completely non-pic code"),
- cl::location(PPCGenerateStaticCode));
+ cl::location(PPCTarget), cl::init(TargetDefault));
}
#if defined(__APPLE__)
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.79 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.80
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.79 Wed Jan 11 19:46:07 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Wed Feb 22 14:19:42 2006
@@ -67,6 +67,11 @@
if (Subtarget.isAIX()) PPCTarget = TargetAIX;
if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
}
+ if (getRelocationModel() == Reloc::Default)
+ if (Subtarget.isDarwin())
+ setRelocationModel(Reloc::DynamicNoPIC);
+ else
+ setRelocationModel(Reloc::PIC);
}
/// addPassesToEmitFile - Add passes to the specified pass manager to implement
@@ -129,8 +134,8 @@
}
void PPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
- // The JIT does not support or need PIC.
- PICEnabled = false;
+ // The JIT should use static relocation model.
+ TM.setRelocationModel(Reloc::Static);
// Run loop strength reduction before anything else.
PM.add(createLoopStrengthReducePass());
More information about the llvm-commits
mailing list