[llvm-branch-commits] [llvm-branch] r94734 - in /llvm/branches/Apple/Zoidberg: include/llvm/Target/TargetMachine.h lib/CodeGen/LLVMTargetMachine.cpp lib/Target/Mips/MipsTargetMachine.cpp lib/Target/X86/X86TargetMachine.cpp lib/Target/X86/X86TargetMachine.h
Eric Christopher
echristo at apple.com
Wed Jan 27 18:04:02 PST 2010
Author: echristo
Date: Wed Jan 27 20:04:02 2010
New Revision: 94734
URL: http://llvm.org/viewvc/llvm-project?rev=94734&view=rev
Log:
Merge 91824 from mainline.
Fixes: rdar://7586070
Modified:
llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetMachine.h
llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp
llvm/branches/Apple/Zoidberg/lib/Target/Mips/MipsTargetMachine.cpp
llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp
llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.h
Modified: llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetMachine.h?rev=94734&r1=94733&r2=94734&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetMachine.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetMachine.h Wed Jan 27 20:04:02 2010
@@ -306,6 +306,13 @@
///
bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level);
+private:
+ // These routines are used by addPassesToEmitFileFinish and
+ // addPassesToEmitMachineCode to set the CodeModel if it's still marked
+ // as default.
+ virtual void setCodeModelForJIT();
+ virtual void setCodeModelForStatic();
+
public:
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp?rev=94734&r1=94733&r2=94734&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/LLVMTargetMachine.cpp Wed Jan 27 20:04:02 2010
@@ -76,7 +76,18 @@
AsmInfo = T.createAsmInfo(TargetTriple);
}
+// Set the default code model for the JIT for a generic target.
+// FIXME: Is small right here? or .is64Bit() ? Large : Small?
+void
+LLVMTargetMachine::setCodeModelForJIT() {
+ setCodeModel(CodeModel::Small);
+}
+// Set the default code model for static compilation for a generic target.
+void
+LLVMTargetMachine::setCodeModelForStatic() {
+ setCodeModel(CodeModel::Small);
+}
FileModel::Model
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
@@ -123,6 +134,9 @@
bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM,
MachineCodeEmitter *MCE,
CodeGenOpt::Level OptLevel) {
+ // Make sure the code model is set.
+ setCodeModelForStatic();
+
if (MCE)
addSimpleCodeEmitter(PM, OptLevel, *MCE);
if (PrintEmittedAsm)
@@ -139,6 +153,9 @@
bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM,
JITCodeEmitter *JCE,
CodeGenOpt::Level OptLevel) {
+ // Make sure the code model is set.
+ setCodeModelForJIT();
+
if (JCE)
addSimpleCodeEmitter(PM, OptLevel, *JCE);
if (PrintEmittedAsm)
@@ -155,6 +172,9 @@
bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM,
ObjectCodeEmitter *OCE,
CodeGenOpt::Level OptLevel) {
+ // Make sure the code model is set.
+ setCodeModelForStatic();
+
if (OCE)
addSimpleCodeEmitter(PM, OptLevel, *OCE);
if (PrintEmittedAsm)
@@ -174,6 +194,9 @@
bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM,
MachineCodeEmitter &MCE,
CodeGenOpt::Level OptLevel) {
+ // Make sure the code model is set.
+ setCodeModelForJIT();
+
// Add common CodeGen passes.
if (addCommonCodeGenPasses(PM, OptLevel))
return true;
@@ -196,6 +219,9 @@
bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM,
JITCodeEmitter &JCE,
CodeGenOpt::Level OptLevel) {
+ // Make sure the code model is set.
+ setCodeModelForJIT();
+
// Add common CodeGen passes.
if (addCommonCodeGenPasses(PM, OptLevel))
return true;
Modified: llvm/branches/Apple/Zoidberg/lib/Target/Mips/MipsTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/Mips/MipsTargetMachine.cpp?rev=94734&r1=94733&r2=94734&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/Mips/MipsTargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/Mips/MipsTargetMachine.cpp Wed Jan 27 20:04:02 2010
@@ -50,11 +50,6 @@
else
setRelocationModel(Reloc::Static);
}
-
- // TODO: create an option to enable long calls, like -mlong-calls,
- // that would be our CodeModel::Large. It must not work with Abicall.
- if (getCodeModel() == CodeModel::Default)
- setCodeModel(CodeModel::Small);
}
MipselTargetMachine::
Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp?rev=94734&r1=94733&r2=94734&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.cpp Wed Jan 27 20:04:02 2010
@@ -91,10 +91,6 @@
assert(getRelocationModel() != Reloc::Default &&
"Relocation mode not picked");
- // If no code model is picked, default to small.
- if (getCodeModel() == CodeModel::Default)
- setCodeModel(CodeModel::Small);
-
// ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
// is defined as a model for code which may be used in static or dynamic
// executables but not necessarily a shared library. On X86-32 we just
@@ -184,10 +180,6 @@
Subtarget.setPICStyle(PICStyles::None);
}
- // 64-bit JIT places everything in the same buffer except external functions.
- if (Subtarget.is64Bit())
- setCodeModel(CodeModel::Large);
-
PM.add(createX86CodeEmitterPass(*this, MCE));
return false;
@@ -204,9 +196,6 @@
Subtarget.setPICStyle(PICStyles::None);
}
- // 64-bit JIT places everything in the same buffer except external functions.
- if (Subtarget.is64Bit())
- setCodeModel(CodeModel::Large);
PM.add(createX86JITCodeEmitterPass(*this, JCE));
@@ -247,3 +236,23 @@
return DwarfLSDAEncoding::Default;
}
+
+void X86TargetMachine::setCodeModelForStatic() {
+
+ if (getCodeModel() != CodeModel::Default) return;
+
+ // For static codegen, if we're not already set, use Small codegen.
+ setCodeModel(CodeModel::Small);
+}
+
+
+void X86TargetMachine::setCodeModelForJIT() {
+
+ if (getCodeModel() != CodeModel::Default) return;
+
+ // 64-bit JIT places everything in the same buffer except external functions.
+ if (Subtarget.is64Bit())
+ setCodeModel(CodeModel::Large);
+ else
+ setCodeModel(CodeModel::Small);
+}
Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.h?rev=94734&r1=94733&r2=94734&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.h (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86TargetMachine.h Wed Jan 27 20:04:02 2010
@@ -38,6 +38,11 @@
X86ELFWriterInfo ELFWriterInfo;
Reloc::Model DefRelocModel; // Reloc model before it's overridden.
+private:
+ // We have specific defaults for X86.
+ virtual void setCodeModelForJIT();
+ virtual void setCodeModelForStatic();
+
public:
X86TargetMachine(const Target &T, const std::string &TT,
const std::string &FS, bool is64Bit);
More information about the llvm-branch-commits
mailing list