r212176 - [Driver][Mips] If ABI name is not provided deduce it from the target triple

Justin Bogner mail at justinbogner.com
Tue Jul 22 14:45:08 PDT 2014


Simon Atanasyan <simon at atanasyan.com> writes:
> Author: atanasyan
> Date: Wed Jul  2 08:20:36 2014
> New Revision: 212176
>
> URL: http://llvm.org/viewvc/llvm-project?rev=212176&view=revLog:
> [Driver][Mips] If ABI name is not provided deduce it from the target triple
> not from the CPU name. This approach is closer to the method used by gcc driver.
>
> Modified:
>     cfe/trunk/lib/Driver/Tools.cpp
>     cfe/trunk/test/Driver/mips-abi.c
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=212176&r1=212175&r2=212176&view=diff==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul  2 08:20:36 2014
> @@ -947,22 +947,22 @@ static void getMipsCPUAndABI(const ArgLi
>      }
>    }
>  
> -  if (!ABIName.empty()) {
> +  if (ABIName.empty()) {
> +    // Deduce ABI name from the target triple.
> +    if (Triple.getArch() == llvm::Triple::mips ||
> +        Triple.getArch() == llvm::Triple::mipsel)
> +      ABIName = "o32";
> +    else
> +      ABIName = "n64";
> +  }
> +
> +  if (CPUName.empty()) {
>      // Deduce CPU name from ABI name.
>      CPUName = llvm::StringSwitch<const char *>(ABIName)
>        .Cases("o32", "eabi", DefMips32CPU)
>        .Cases("n32", "n64", DefMips64CPU)
>        .Default("");
>    }
> -  else if (!CPUName.empty()) {
> -    // Deduce ABI name from CPU name.
> -    ABIName = llvm::StringSwitch<const char *>(CPUName)
> -      .Cases("mips32", "mips32r2", "o32")
> -      .Cases("mips64", "mips64r2", "n64")
> -      .Default("");
> -  }
> -
> -  // FIXME: Warn on inconsistent cpu and abi usage.

Did you mean to remove this FIXME?

>  }
>  
>  // Convert ABI name to the GNU tools acceptable variant.
>
> Modified: cfe/trunk/test/Driver/mips-abi.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=212176&r1=212175&r2=212176&view=diff==============================================================================
> --- cfe/trunk/test/Driver/mips-abi.c (original)
> +++ cfe/trunk/test/Driver/mips-abi.c Wed Jul  2 08:20:36 2014
> @@ -1,5 +1,15 @@
>  // Check passing Mips ABI options to the backend.
>  //
> +// RUN: %clang -target mips-linux-gnu -### -c %s 2>&1 \
> +// RUN:   | FileCheck -check-prefix=MIPS-DEF %s
> +// MIPS-DEF: "-target-cpu" "mips32r2"
> +// MIPS-DEF: "-target-abi" "o32"
> +//
> +// RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
> +// RUN:   | FileCheck -check-prefix=MIPS64-DEF %s
> +// MIPS64-DEF: "-target-cpu" "mips64r2"
> +// MIPS64-DEF: "-target-abi" "n64"
> +//
>  // RUN: %clang -target mips-linux-gnu -### -c %s \
>  // RUN:        -mabi=32 2>&1 \
>  // RUN:   | FileCheck -check-prefix=MIPS-ABI-32 %s
> @@ -45,3 +55,33 @@
>  // RUN:        -mabi=unknown 2>&1 \
>  // RUN:   | FileCheck -check-prefix=MIPS-ABI-UNKNOWN %s
>  // MIPS-ABI-UNKNOWN: error: unknown target ABI 'unknown'
> +//
> +// RUN: %clang -target mips-linux-gnu -### -c %s \
> +// RUN:        -march=mips32 2>&1 \
> +// RUN:   | FileCheck -check-prefix=MIPS-ARCH-32 %s
> +// MIPS-ARCH-32: "-target-cpu" "mips32"
> +// MIPS-ARCH-32: "-target-abi" "o32"
> +//
> +// RUN: %clang -target mips-linux-gnu -### -c %s \
> +// RUN:        -march=mips32r2 2>&1 \
> +// RUN:   | FileCheck -check-prefix=MIPS-ARCH-32R2 %s
> +// MIPS-ARCH-32R2: "-target-cpu" "mips32r2"
> +// MIPS-ARCH-32R2: "-target-abi" "o32"
> +//
> +// RUN: %clang -target mips-linux-gnu -### -c %s \
> +// RUN:        -march=mips64 2>&1 \
> +// RUN:   | FileCheck -check-prefix=MIPS-ARCH-3264 %s
> +// MIPS-ARCH-3264: "-target-cpu" "mips64"
> +// MIPS-ARCH-3264: "-target-abi" "o32"
> +//
> +// RUN: %clang -target mips64-linux-gnu -### -c %s \
> +// RUN:        -march=mips64 2>&1 \
> +// RUN:   | FileCheck -check-prefix=MIPS-ARCH-64 %s
> +// MIPS-ARCH-64: "-target-cpu" "mips64"
> +// MIPS-ARCH-64: "-target-abi" "n64"
> +//
> +// RUN: %clang -target mips64-linux-gnu -### -c %s \
> +// RUN:        -march=mips64r2 2>&1 \
> +// RUN:   | FileCheck -check-prefix=MIPS-ARCH-64R2 %s
> +// MIPS-ARCH-64R2: "-target-cpu" "mips64r2"
> +// MIPS-ARCH-64R2: "-target-abi" "n64"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list