From 34ad6db8b958fdc0d38e122edf753b5326e69b03 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 20 Jul 2011 07:51:56 +0000 Subject: - Move CodeModel from a TargetMachine global option to MCCodeGenInfo. - Introduce JITDefault code model. This tells targets to set different default code model for JIT. This eliminates the ugly hack in TargetMachine where code model is changed after construction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135580 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llc/llc.cpp | 21 +++++++++++++++++++-- tools/lli/lli.cpp | 18 ++++++++++++++++++ tools/llvm-mc/llvm-mc.cpp | 19 ++++++++++++++++++- 3 files changed, 55 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index f1d4dbcad5..f2c4c27f7d 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -91,6 +91,22 @@ RelocModel("relocation-model", "Relocatable external references, non-relocatable code"), clEnumValEnd)); +static cl::opt +CMModel("code-model", + cl::desc("Choose code model"), + cl::init(CodeModel::Default), + cl::values(clEnumValN(CodeModel::Default, "default", + "Target default code model"), + clEnumValN(CodeModel::Small, "small", + "Small code model"), + clEnumValN(CodeModel::Kernel, "kernel", + "Kernel code model"), + clEnumValN(CodeModel::Medium, "medium", + "Medium code model"), + clEnumValN(CodeModel::Large, "large", + "Large code model"), + clEnumValEnd)); + static cl::opt RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, " @@ -287,8 +303,9 @@ int main(int argc, char **argv) { } std::auto_ptr - target(TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, - FeaturesStr, RelocModel)); + target(TheTarget->createTargetMachine(TheTriple.getTriple(), + MCPU, FeaturesStr, + RelocModel, CMModel)); assert(target.get() && "Could not allocate target machine!"); TargetMachine &Target = *target.get(); diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index da03ddd4b0..646e0f64cb 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -123,6 +123,23 @@ namespace { clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic", "Relocatable external references, non-relocatable code"), clEnumValEnd)); + + cl::opt + CMModel("code-model", + cl::desc("Choose code model"), + cl::init(CodeModel::JITDefault), + cl::values(clEnumValN(CodeModel::JITDefault, "default", + "Target default JIT code model"), + clEnumValN(CodeModel::Small, "small", + "Small code model"), + clEnumValN(CodeModel::Kernel, "kernel", + "Kernel code model"), + clEnumValN(CodeModel::Medium, "medium", + "Medium code model"), + clEnumValN(CodeModel::Large, "large", + "Large code model"), + clEnumValEnd)); + } static ExecutionEngine *EE = 0; @@ -180,6 +197,7 @@ int main(int argc, char **argv, char * const *envp) { builder.setMCPU(MCPU); builder.setMAttrs(MAttrs); builder.setRelocationModel(RelocModel); + builder.setCodeModel(CMModel); builder.setErrorStr(&ErrorMsg); builder.setEngineKind(ForceInterpreter ? EngineKind::Interpreter diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index d930aea1e5..092c363721 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -128,6 +128,22 @@ RelocModel("relocation-model", "Relocatable external references, non-relocatable code"), clEnumValEnd)); +static cl::opt +CMModel("code-model", + cl::desc("Choose code model"), + cl::init(CodeModel::Default), + cl::values(clEnumValN(CodeModel::Default, "default", + "Target default code model"), + clEnumValN(CodeModel::Small, "small", + "Small code model"), + clEnumValN(CodeModel::Kernel, "kernel", + "Kernel code model"), + clEnumValN(CodeModel::Medium, "medium", + "Medium code model"), + clEnumValN(CodeModel::Large, "large", + "Large code model"), + clEnumValEnd)); + static cl::opt NoInitialTextSection("n", cl::desc("Don't assume assembly file starts " "in the text section")); @@ -339,7 +355,8 @@ static int AssembleInput(const char *ProgName) { OwningPtr TM(TheTarget->createTargetMachine(TripleName, MCPU, FeaturesStr, - RelocModel)); + RelocModel, + CMModel)); if (!TM) { errs() << ProgName << ": error: could not create target for triple '" -- cgit v1.2.3