[PATCH] D139305: [clang][driver] Support option '-mcpu' on target AVR.
Ben Shi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 6 19:46:45 PST 2022
benshi001 updated this revision to Diff 480749.
Repository:
rG LLVM Github Monorepo
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"
@@ -20,34 +23,18 @@
// CHECK4: "-cc1" {{.*}} "-target-cpu" "attiny88"
// CHECK4: "-cc1as" {{.*}} "-target-cpu" "attiny88"
-// RUN: %clang -### --target=avr -mmcu=attiny88 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK5 %s
-// CHECK5: "-cc1" {{.*}} "-target-cpu" "attiny88"
-// CHECK5: "-cc1as" {{.*}} "-target-cpu" "attiny88"
-
// RUN: %clang -### --target=avr -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK6 %s
// CHECK6: "-cc1" {{.*}} "-target-cpu" "atmega8u2"
// CHECK6: "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
-// RUN: %clang -### --target=avr -mmcu=atmega8u2 -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK7 %s
-// CHECK7: "-cc1" {{.*}} "-target-cpu" "atmega8u2"
-// CHECK7: "-cc1as" {{.*}} "-target-cpu" "atmega8u2"
-
// RUN: %clang -### --target=avr -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK8 %s
// CHECK8: "-cc1" {{.*}} "-target-cpu" "atmega8a"
// CHECK8: "-cc1as" {{.*}} "-target-cpu" "atmega8a"
-// RUN: %clang -### --target=avr -mmcu=atmega8a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECK9 %s
-// CHECK9: "-cc1" {{.*}} "-target-cpu" "atmega8a"
-// CHECK9: "-cc1as" {{.*}} "-target-cpu" "atmega8a"
-
// RUN: %clang -### --target=avr -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKa %s
// CHECKa: "-cc1" {{.*}} "-target-cpu" "atmega16a"
// CHECKa: "-cc1as" {{.*}} "-target-cpu" "atmega16a"
-// RUN: %clang -### --target=avr -mmcu=atmega16a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKb %s
-// CHECKb: "-cc1" {{.*}} "-target-cpu" "atmega16a"
-// CHECKb: "-cc1as" {{.*}} "-target-cpu" "atmega16a"
-
// RUN: %clang -### --target=avr -mmcu=atmega128a -save-temps %s 2>&1 | FileCheck -check-prefix=CHECKc %s
// CHECKc: "-cc1" {{.*}} "-target-cpu" "atmega128a"
// CHECKc: "-cc1as" {{.*}} "-target-cpu" "atmega128a"
@@ -72,10 +59,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 "";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139305.480749.patch
Type: text/x-patch
Size: 4627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221207/a57b7d24/attachment.bin>
More information about the cfe-commits
mailing list