r246027 - Convert a bunch of loops to ranged-for and clean up accordingly.

Eric Christopher via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 13:29:08 PDT 2015


>
>
> > -    assert(Features[i][0] == '+' && "Invalid target feature!");
> > +    assert(Feature[0] == '+' && "Invalid target feature!");
>
> This assert is kind of pointless now, since we'll have continued in that
> case and the following code will DTRT anyway.
>
>
Was fairly pointless to begin with. I'll remove it :)

-eric


> >      X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature)
> > -      .Case("avx512f", AVX512F)
> > -      .Case("avx2", AVX2)
> > -      .Case("avx", AVX)
> > -      .Case("sse4.2", SSE42)
> > -      .Case("sse4.1", SSE41)
> > -      .Case("ssse3", SSSE3)
> > -      .Case("sse3", SSE3)
> > -      .Case("sse2", SSE2)
> > -      .Case("sse", SSE1)
> > +      .Case("+avx512f", AVX512F)
> > +      .Case("+avx2", AVX2)
> > +      .Case("+avx", AVX)
> > +      .Case("+sse4.2", SSE42)
> > +      .Case("+sse4.1", SSE41)
> > +      .Case("+ssse3", SSSE3)
> > +      .Case("+sse3", SSE3)
> > +      .Case("+sse2", SSE2)
> > +      .Case("+sse", SSE1)
> >        .Default(NoSSE);
> >      SSELevel = std::max(SSELevel, Level);
> >
> >      MMX3DNowEnum ThreeDNowLevel =
> >        llvm::StringSwitch<MMX3DNowEnum>(Feature)
> > -        .Case("3dnowa", AMD3DNowAthlon)
> > -        .Case("3dnow", AMD3DNow)
> > -        .Case("mmx", MMX)
> > +        .Case("+3dnowa", AMD3DNowAthlon)
> > +        .Case("+3dnow", AMD3DNow)
> > +        .Case("+mmx", MMX)
> >          .Default(NoMMX3DNow);
> >      MMX3DNowLevel = std::max(MMX3DNowLevel, ThreeDNowLevel);
> >
> >      XOPEnum XLevel = llvm::StringSwitch<XOPEnum>(Feature)
> > -        .Case("xop", XOP)
> > -        .Case("fma4", FMA4)
> > -        .Case("sse4a", SSE4A)
> > +        .Case("+xop", XOP)
> > +        .Case("+fma4", FMA4)
> > +        .Case("+sse4a", SSE4A)
> >          .Default(NoXOP);
> >      XOPLevel = std::max(XOPLevel, XLevel);
> >    }
> > @@ -5247,12 +5147,12 @@ public:
> >      FPU = FPUMode;
> >      CRC = 0;
> >      Crypto = 0;
> > -    for (unsigned i = 0, e = Features.size(); i != e; ++i) {
> > -      if (Features[i] == "+neon")
> > +    for (const auto &Feature : Features) {
> > +      if (Feature == "+neon")
> >          FPU = NeonMode;
> > -      if (Features[i] == "+crc")
> > +      if (Feature == "+crc")
> >          CRC = 1;
> > -      if (Features[i] == "+crypto")
> > +      if (Feature == "+crypto")
> >          Crypto = 1;
> >      }
> >
> > @@ -5926,10 +5826,10 @@ public:
> >    bool handleTargetFeatures(std::vector<std::string> &Features,
> >                              DiagnosticsEngine &Diags) override {
> >      HasTransactionalExecution = false;
> > -    for (unsigned i = 0, e = Features.size(); i != e; ++i) {
> > -      if (Features[i] == "+transactional-execution")
> > +    for (const auto &Feature : Features) {
> > +      if (Feature == "+transactional-execution")
> >          HasTransactionalExecution = true;
> > -      if (Features[i] == "+vector")
> > +      else if (Feature == "+vector")
> >          HasVector = true;
> >      }
> >      // If we use the vector ABI, vector types are 64-bit aligned.
> > @@ -6477,29 +6377,28 @@ public:
> >      DspRev = NoDSP;
> >      HasFP64 = isFP64Default();
> >
> > -    for (std::vector<std::string>::iterator it = Features.begin(),
> > -         ie = Features.end(); it != ie; ++it) {
> > -      if (*it == "+single-float")
> > +    for (const auto &Feature : Features) {
> > +      if (Feature == "+single-float")
> >          IsSingleFloat = true;
> > -      else if (*it == "+soft-float")
> > +      else if (Feature == "+soft-float")
> >          FloatABI = SoftFloat;
> > -      else if (*it == "+mips16")
> > +      else if (Feature == "+mips16")
> >          IsMips16 = true;
> > -      else if (*it == "+micromips")
> > +      else if (Feature == "+micromips")
> >          IsMicromips = true;
> > -      else if (*it == "+dsp")
> > +      else if (Feature == "+dsp")
> >          DspRev = std::max(DspRev, DSP1);
> > -      else if (*it == "+dspr2")
> > +      else if (Feature == "+dspr2")
> >          DspRev = std::max(DspRev, DSP2);
> > -      else if (*it == "+msa")
> > +      else if (Feature == "+msa")
> >          HasMSA = true;
> > -      else if (*it == "+fp64")
> > +      else if (Feature == "+fp64")
> >          HasFP64 = true;
> > -      else if (*it == "-fp64")
> > +      else if (Feature == "-fp64")
> >          HasFP64 = false;
> > -      else if (*it == "+nan2008")
> > +      else if (Feature == "+nan2008")
> >          IsNan2008 = true;
> > -      else if (*it == "-nan2008")
> > +      else if (Feature == "-nan2008")
> >          IsNan2008 = false;
> >      }
> >
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150827/19e7a844/attachment.html>


More information about the cfe-commits mailing list