From 072d1afbf058ca2202d144465877428cedae152b Mon Sep 17 00:00:00 2001 From: Leslie Zhai Date: Thu, 20 Apr 2017 04:23:24 +0000 Subject: [PATCH] [AVR] Add -mmcu option to the driver 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 | 1 + lib/Driver/ToolChains/CommonArgs.cpp | 6 ++++++ test/Driver/avr-mmcu.c | 5 +++++ 3 files changed, 12 insertions(+) create mode 100644 test/Driver/avr-mmcu.c diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 6f1ccfb001..1272a36ecc 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1661,6 +1661,7 @@ def mdll : Joined<["-"], "mdll">, Group, Flags<[DriverOption]>; def municode : Joined<["-"], "municode">, Group, Flags<[DriverOption]>; def mthreads : Joined<["-"], "mthreads">, Group, Flags<[DriverOption]>; def mcpu_EQ : Joined<["-"], "mcpu=">, Group; +def mmcu_EQ : Joined<["-"], "mmcu=">, Group; def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group; def mfix_and_continue : Flag<["-"], "mfix-and-continue">, Group; def mieee_fp : Flag<["-"], "mieee-fp">, Group; diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp index cb273300cd..93b66eb695 100644 --- a/lib/Driver/ToolChains/CommonArgs.cpp +++ b/lib/Driver/ToolChains/CommonArgs.cpp @@ -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 index 0000000000..efe75fded6 --- /dev/null +++ b/test/Driver/avr-mmcu.c @@ -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" -- 2.40.0