]> granicus.if.org Git - clang/commitdiff
[AVR] Add -mmcu option to the driver
authorLeslie Zhai <lesliezhai@llvm.org.cn>
Thu, 20 Apr 2017 04:23:24 +0000 (04:23 +0000)
committerLeslie Zhai <lesliezhai@llvm.org.cn>
Thu, 20 Apr 2017 04:23:24 +0000 (04:23 +0000)
A patch by Peter Wu!

Reviewers: jroelofs, xiangzhai

Reviewed By: jroelofs, dylanmckay, xiangzhai

Subscribers: dlj, dylanmckay, cfe-commits

Differential Revision: https://reviews.llvm.org/D29827

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300818 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
lib/Driver/ToolChains/CommonArgs.cpp
test/Driver/avr-mmcu.c [new file with mode: 0644]

index 6f1ccfb00172014d39243bc51d6fef9187d4fef3..1272a36ecc7088bd6f6d08a69428b1a86f7d5d69 100644 (file)
@@ -1661,6 +1661,7 @@ def mdll : Joined<["-"], "mdll">, Group<m_Group>, Flags<[DriverOption]>;
 def municode : Joined<["-"], "municode">, Group<m_Group>, Flags<[DriverOption]>;
 def mthreads : Joined<["-"], "mthreads">, Group<m_Group>, Flags<[DriverOption]>;
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group<m_Group>;
+def mmcu_EQ : Joined<["-"], "mmcu=">, Group<m_Group>;
 def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group<m_Group>;
 def mfix_and_continue : Flag<["-"], "mfix-and-continue">, Group<clang_ignored_m_Group>;
 def mieee_fp : Flag<["-"], "mieee-fp">, Group<clang_ignored_m_Group>;
index cb273300cdc1d419d18f1c8668dea636061f0446..93b66eb6954a39aa2cdbb2fa069a20ea9d2b08d1 100644 (file)
@@ -261,6 +261,12 @@ std::string tools::getCPUName(const ArgList &Args, const llvm::Triple &T,
     arm::getARMArchCPUFromArgs(Args, MArch, MCPU, FromAs);
     return arm::getARMTargetCPU(MCPU, MArch, T);
   }
+
+  case llvm::Triple::avr:
+    if (const Arg *A = Args.getLastArg(options::OPT_mmcu_EQ))
+      return A->getValue();
+    return "";
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
diff --git a/test/Driver/avr-mmcu.c b/test/Driver/avr-mmcu.c
new file mode 100644 (file)
index 0000000..efe75fd
--- /dev/null
@@ -0,0 +1,5 @@
+// A test for the propagation of the -mmcu option to -cc1 and -cc1as
+
+// RUN: %clang -### -target avr -mmcu=atmega328p -save-temps %s 2>&1 | FileCheck %s
+// CHECK: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega328p"
+// CHECK: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega328p"