From bf463d61da6d4866fff4aa86bffd394e15af263c Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Mon, 24 Oct 2011 18:38:06 +0400 Subject: [PATCH] Readded 'relocation-model' and 'code-model' options --- gen/cl_options.cpp | 25 +++++++++++++++++++++++++ gen/cl_options.h | 3 +++ gen/main.cpp | 3 ++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gen/cl_options.cpp b/gen/cl_options.cpp index 252fc5ca..b6b51261 100644 --- a/gen/cl_options.cpp +++ b/gen/cl_options.cpp @@ -242,6 +242,31 @@ cl::list mAttrs("mattr", cl::opt mTargetTriple("mtriple", cl::desc("Override target triple")); +cl::opt mRelocModel("relocation-model", + cl::desc("Relocation model"), + cl::init(llvm::Reloc::Default), + cl::values( + clEnumValN(llvm::Reloc::Default, "default", + "Target default relocation model"), + clEnumValN(llvm::Reloc::Static, "static", + "Non-relocatable code"), + clEnumValN(llvm::Reloc::PIC_, "pic", + "Fully relocatable, position independent code"), + clEnumValN(llvm::Reloc::DynamicNoPIC, "dynamic-no-pic", + "Relocatable external references, non-relocatable code"), + clEnumValEnd)); + +cl::opt mCodeModel("code-model", + cl::desc("Code model"), + cl::init(llvm::CodeModel::Default), + cl::values( + clEnumValN(llvm::CodeModel::Default, "default", "Target default code model"), + clEnumValN(llvm::CodeModel::Small, "small", "Small code model"), + clEnumValN(llvm::CodeModel::Kernel, "kernel", "Kernel code model"), + clEnumValN(llvm::CodeModel::Medium, "medium", "Medium code model"), + clEnumValN(llvm::CodeModel::Large, "large", "Large code model"), + clEnumValEnd)); + // "Hidden debug switches" // Are these ever used? diff --git a/gen/cl_options.h b/gen/cl_options.h index 8965a20e..c3ffcda9 100644 --- a/gen/cl_options.h +++ b/gen/cl_options.h @@ -7,6 +7,7 @@ #include #include "llvm/Support/CommandLine.h" +#include "llvm/Support/CodeGen.h" namespace opts { namespace cl = llvm::cl; @@ -43,6 +44,8 @@ namespace opts { extern cl::opt mCPU; extern cl::list mAttrs; extern cl::opt mTargetTriple; + extern cl::opt mRelocModel; + extern cl::opt mCodeModel; extern cl::opt singleObj; extern cl::opt linkonceTemplates; diff --git a/gen/main.cpp b/gen/main.cpp index 8fb984fc..1136214d 100644 --- a/gen/main.cpp +++ b/gen/main.cpp @@ -487,7 +487,8 @@ int main(int argc, char** argv) //assert(target.get() && "Could not allocate target machine!"); //gTargetMachine = target.get(); - llvm::TargetMachine* target = theTarget->createTargetMachine(triple, mCPU, FeaturesStr); + llvm::TargetMachine* target = theTarget->createTargetMachine(triple, mCPU, FeaturesStr, + mRelocModel, mCodeModel); gTargetMachine = target; gTargetData = target->getTargetData();