On 8/20/14, 12:31 PM, Aaron Ballman wrote:
On Wed, Aug 20, 2014 at 11:39 AM, Jon Roelofs <[email protected]> wrote:
Hi rengolin,

Depends on: http://reviews.llvm.org/D4984

http://reviews.llvm.org/D4985

Files:
   include/clang/Driver/CC1Options.td
   include/clang/Driver/ToolChain.h
   include/clang/Frontend/CodeGenOptions.h
   lib/CodeGen/BackendUtil.cpp
   lib/Driver/Tools.cpp
   lib/Frontend/CompilerInvocation.cpp

Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -419,6 +419,16 @@

    llvm::TargetOptions Options;

+  Options.ThreadModel = llvm::ThreadModel::POSIX;
+  if (CodeGenOpts.ThreadModel == "POSIX") {
+    Options.ThreadModel = llvm::ThreadModel::POSIX;
+  } else if (CodeGenOpts.ThreadModel == "Single") {
+    Options.ThreadModel = llvm::ThreadModel::Single;

The braces should be elided for the if and else if.
Ok.

+  } else {
+    assert(false && "Invalid Thread model!");
+    Options.ThreadModel = llvm::ThreadModel::POSIX;

This assignment is redundant with the original initialization.
Ok.

+  }



+
    if (CodeGenOpts.DisableIntegratedAS)
      Options.DisableIntegratedAS = true;

Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -437,6 +437,7 @@
                        Args.hasArg(OPT_cl_fast_relaxed_math);
    Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
    Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
+  Opts.ThreadModel = Args.getLastArgValue(OPT_mthread_model, "POSIX");
    Opts.TrapFuncName = Args.getLastArgValue(OPT_ftrap_function_EQ);
    Opts.UseInitArray = Args.hasArg(OPT_fuse_init_array);

Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2776,6 +2776,9 @@
      }
    }

+  CmdArgs.push_back("-mthread-model");
+  CmdArgs.push_back(Args.MakeArgString(getToolChain().getThreadModel()));
+
    if (!Args.hasFlag(options::OPT_fmerge_all_constants,
                      options::OPT_fno_merge_all_constants))
      CmdArgs.push_back("-fno-merge-all-constants");
Index: include/clang/Frontend/CodeGenOptions.h
===================================================================
--- include/clang/Frontend/CodeGenOptions.h
+++ include/clang/Frontend/CodeGenOptions.h
@@ -134,6 +134,9 @@
    /// The name of the relocation model to use.
    std::string RelocationModel;

+  /// The thread model to use
+  std::string ThreadModel;
+
    /// Path to blacklist file for sanitizers.
    std::string SanitizerBlacklistFile;

Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -248,6 +248,9 @@
    /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
    virtual bool UseSjLjExceptions() const { return false; }

+  /// getThreadModel() - Which thread model does this target use?
+  virtual std::string getThreadModel() const { return "POSIX"; }

Why is this virtual? I don't see any overrides.
I have a currently-out-of-tree ToolChain that overrides it.

+
    /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking
    /// command line arguments into account.
    virtual std::string
Index: include/clang/Driver/CC1Options.td
===================================================================
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -218,6 +218,8 @@
    HelpText<"Limit the number of registers available for integer arguments">;
  def mrelocation_model : Separate<["-"], "mrelocation-model">,
    HelpText<"The relocation model to use">;
+def mthread_model : Separate<["-"], "mthread-model">,
+  HelpText<"The thread model to use">;

The help text could be a bit more helpful, like what thread models are
possible values.
How about: "The thread model to use. (e.g. POSIX, Single)" ?

Is there a better way to do a stringy-enum option, so that those get put in the help text automatically?

  def munwind_tables : Flag<["-"], "munwind-tables">,
    HelpText<"Generate unwinding tables for all functions">;
  def mconstructor_aliases : Flag<["-"], "mconstructor-aliases">,

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


~Aaron


--
Jon Roelofs
[email protected]
CodeSourcery / Mentor Embedded
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to