benshi001 updated this revision to Diff 480748.
benshi001 retitled this revision from "[clang][driver] Make option '-mmcu' as 
an alias of option '-mcpu'" to "[clang][driver] Support option '-mcpu' on 
target AVR.".
benshi001 edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139305/new/

https://reviews.llvm.org/D139305

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/avr-mmcu.c


Index: clang/test/Driver/avr-mmcu.c
===================================================================
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,13 +1,16 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
+// RUN: %clang -### --target=avr -mcpu=attiny11 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK0 %s
 // RUN: %clang -### --target=avr -mmcu=attiny11 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK0 %s
 // CHECK0: "-cc1" {{.*}} "-target-cpu" "attiny11"
 // CHECK0: "-cc1as" {{.*}} "-target-cpu" "attiny11"
 
+// RUN: %clang -### --target=avr -mcpu=at90s2313 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK1 %s
 // RUN: %clang -### --target=avr -mmcu=at90s2313 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK1 %s
 // CHECK1: "-cc1" {{.*}} "-target-cpu" "at90s2313"
 // CHECK1: "-cc1as" {{.*}} "-target-cpu" "at90s2313"
 
+// RUN: %clang -### --target=avr -mcpu=at90s8515 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK2 %s
 // RUN: %clang -### --target=avr -mmcu=at90s8515 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK2 %s
 // CHECK2: "-cc1" {{.*}} "-target-cpu" "at90s8515"
 // CHECK2: "-cc1as" {{.*}} "-target-cpu" "at90s8515"
@@ -72,10 +75,15 @@
 // CHECKh: "-cc1" {{.*}} "-target-cpu" "atxmega64a1u"
 // CHECKh: "-cc1as" {{.*}} "-target-cpu" "atxmega64a1u"
 
+// RUN: %clang -### --target=avr -mcpu=atxmega128a3u -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECKj %s
 // RUN: %clang -### --target=avr -mmcu=atxmega128a3u -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECKj %s
 // CHECKj: "-cc1" {{.*}} "-target-cpu" "atxmega128a3u"
 // CHECKj: "-cc1as" {{.*}} "-target-cpu" "atxmega128a3u"
 
+// RUN: %clang -### --target=avr -mcpu=atxmega128a4u -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECKi %s
 // RUN: %clang -### --target=avr -mmcu=atxmega128a4u -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECKi %s
 // CHECKi: "-cc1" {{.*}} "-target-cpu" "atxmega128a4u"
 // CHECKi: "-cc1as" {{.*}} "-target-cpu" "atxmega128a4u"
+
+// RUN: %clang --target=avr -mcpu=atmega328 -mmcu=atmega168 -c %s 2>&1 | 
FileCheck -check-prefix=CHECKz %s
+// CHECKz: warning: argument unused during compilation: '-mmcu=atmega168'
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -382,6 +382,10 @@
   }
 
   case llvm::Triple::avr:
+    // We encourage users to use '-mcpu' as their first choice,
+    // rather than the old '-mmcu' (inherited from avr-gcc).
+    if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+      return A->getValue();
     if (const Arg *A = Args.getLastArg(options::OPT_mmcu_EQ))
       return A->getValue();
     return "";


Index: clang/test/Driver/avr-mmcu.c
===================================================================
--- clang/test/Driver/avr-mmcu.c
+++ clang/test/Driver/avr-mmcu.c
@@ -1,13 +1,16 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
+// RUN: %clang -### --target=avr -mcpu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
 // RUN: %clang -### --target=avr -mmcu=attiny11 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK0 %s
 // CHECK0: "-cc1" {{.*}} "-target-cpu" "attiny11"
 // CHECK0: "-cc1as" {{.*}} "-target-cpu" "attiny11"
 
+// RUN: %clang -### --target=avr -mcpu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
 // RUN: %clang -### --target=avr -mmcu=at90s2313 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
 // CHECK1: "-cc1" {{.*}} "-target-cpu" "at90s2313"
 // CHECK1: "-cc1as" {{.*}} "-target-cpu" "at90s2313"
 
+// RUN: %clang -### --target=avr -mcpu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
 // RUN: %clang -### --target=avr -mmcu=at90s8515 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
 // CHECK2: "-cc1" {{.*}} "-target-cpu" "at90s8515"
 // CHECK2: "-cc1as" {{.*}} "-target-cpu" "at90s8515"
@@ -72,10 +75,15 @@
 // CHECKh: "-cc1" {{.*}} "-target-cpu" "atxmega64a1u"
 // CHECKh: "-cc1as" {{.*}} "-target-cpu" "atxmega64a1u"
 
+// RUN: %clang -### --target=avr -mcpu=atxmega128a3u -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKj %s
 // RUN: %clang -### --target=avr -mmcu=atxmega128a3u -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKj %s
 // CHECKj: "-cc1" {{.*}} "-target-cpu" "atxmega128a3u"
 // CHECKj: "-cc1as" {{.*}} "-target-cpu" "atxmega128a3u"
 
+// RUN: %clang -### --target=avr -mcpu=atxmega128a4u -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKi %s
 // RUN: %clang -### --target=avr -mmcu=atxmega128a4u -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKi %s
 // CHECKi: "-cc1" {{.*}} "-target-cpu" "atxmega128a4u"
 // CHECKi: "-cc1as" {{.*}} "-target-cpu" "atxmega128a4u"
+
+// RUN: %clang --target=avr -mcpu=atmega328 -mmcu=atmega168 -c %s 2>&1 | FileCheck -check-prefix=CHECKz %s
+// CHECKz: warning: argument unused during compilation: '-mmcu=atmega168'
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -382,6 +382,10 @@
   }
 
   case llvm::Triple::avr:
+    // We encourage users to use '-mcpu' as their first choice,
+    // rather than the old '-mmcu' (inherited from avr-gcc).
+    if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+      return A->getValue();
     if (const Arg *A = Args.getLastArg(options::OPT_mmcu_EQ))
       return A->getValue();
     return "";
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to