[PATCH] CFE Knob for: Add a thread-model knob for lowering atomics on baremetal & single threaded systems

Aaron Ballman aaron at aaronballman.com
Fri Aug 29 11:16:46 PDT 2014


On Fri, Aug 29, 2014 at 1:26 PM, Jon Roelofs <jonathan at codesourcery.com> wrote:
> ================
> Comment at: lib/CodeGen/BackendUtil.cpp:422-429
> @@ -421,1 +421,10 @@
>
> +  if (CodeGenOpts.ThreadModel == "posix")
> +    Options.ThreadModel = llvm::ThreadModel::POSIX;
> +  else if (CodeGenOpts.ThreadModel == "single")
> +    Options.ThreadModel = llvm::ThreadModel::Single;
> +  else {
> +    assert(false && "Invalid Thread model!");
> +    Options.ThreadModel = llvm::ThreadModel::POSIX;
> +  }
> +
> ----------------
> majnemer wrote:
>> You may want to consider using LLVM's [[ http://llvm.org/docs/doxygen/html/classllvm_1_1StringSwitch.html#details | StringSwitch ]] here.
> I considered it, but Stringswitch wouldn't let me assert that every case was handled.

StringSwitch does that automatically for you when getting the result
if you leave off the .Default call.

~Aaron



More information about the cfe-commits mailing list