[llvm] r240365 - AMDGPU: Use getAsInteger instead of atoi

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jun 23 03:22:23 PDT 2015


Would it be possible to change getRegForInlineAsmConstraint to take a StringRef?

On 22 June 2015 at 22:05, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:
> Author: arsenm
> Date: Mon Jun 22 21:05:55 2015
> New Revision: 240365
>
> URL: http://llvm.org/viewvc/llvm-project?rev=240365&view=rev
> Log:
> AMDGPU: Use getAsInteger instead of atoi
>
> Modified:
>     llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
>
> Modified: llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp?rev=240365&r1=240364&r2=240365&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp Mon Jun 22 21:05:55 2015
> @@ -2211,8 +2211,9 @@ SDValue SITargetLowering::CreateLiveInRe
>
>  std::pair<unsigned, const TargetRegisterClass *>
>  SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
> -                                               const std::string &Constraint,
> +                                               const std::string &Constraint_,
>                                                 MVT VT) const {
> +  StringRef Constraint(Constraint_);
>    if (Constraint == "r") {
>      switch(VT.SimpleTy) {
>        default: llvm_unreachable("Unhandled type for 'r' inline asm constraint");
> @@ -2232,8 +2233,9 @@ SITargetLowering::getRegForInlineAsmCons
>      }
>
>      if (RC) {
> -      unsigned Idx = std::atoi(Constraint.substr(2).c_str());
> -      if (Idx < RC->getNumRegs())
> +      uint32_t Idx;
> +      bool Failed = Constraint.substr(2).getAsInteger(10, Idx);
> +      if (!Failed && Idx < RC->getNumRegs())
>          return std::make_pair(RC->getRegister(Idx), RC);
>      }
>    }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list