Skip to content

Commit

Permalink
[ARM] Add a driver option for +no-neg-immediates
Browse files Browse the repository at this point in the history
Reviewers: olista01, rengolin, javed.absar, samparker

Reviewed By: samparker

Subscribers: samparker, llvm-commits, aemerson

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

llvm-svn: 298850
snnw committed Mar 27, 2017
1 parent d668a01 commit 784004e
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
@@ -1760,6 +1760,8 @@ def mcrc : Flag<["-"], "mcrc">, Group<m_arm_Features_Group>,
HelpText<"Allow use of CRC instructions (ARM only)">;
def mnocrc : Flag<["-"], "mnocrc">, Group<m_arm_Features_Group>,
HelpText<"Disallow use of CRC instructions (ARM only)">;
def mno_neg_immediates: Flag<["-"], "mno-neg-immediates">, Group<m_arm_Features_Group>,
HelpText<"Disallow converting instructions with negative immediates to their negation or inversion.">;

def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group<m_aarch64_Features_Group>,
HelpText<"Generate code which only uses the general purpose registers (AArch64 only)">;
3 changes: 3 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
@@ -193,4 +193,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D, const ArgList &Args,

if (Args.hasArg(options::OPT_ffixed_x18))
Features.push_back("+reserve-x18");

if (Args.hasArg(options::OPT_mno_neg_immediates))
Features.push_back("+no-neg-immediates");
}
3 changes: 3 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/ARM.cpp
Original file line number Diff line number Diff line change
@@ -449,6 +449,9 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
// The kext linker doesn't know how to deal with movw/movt.
if (KernelOrKext || Args.hasArg(options::OPT_mno_movt))
Features.push_back("+no-movt");

if (Args.hasArg(options::OPT_mno_neg_immediates))
Features.push_back("+no-neg-immediates");
}

const std::string arm::getARMArch(StringRef Arch, const llvm::Triple &Triple) {
8 changes: 8 additions & 0 deletions clang/test/Driver/arm-no-neg-immediates.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %clang -target arm-none-gnueabi -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT
// RUN: %clang -target arm-none-gnueabi -mno-neg-immediates -### %s 2>&1 | FileCheck %s

// RUN: %clang -target aarch64-none-gnueabi -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT
// RUN: %clang -target aarch64-none-gnueabi -mno-neg-immediates -### %s 2>&1 | FileCheck %s

// CHECK: "-target-feature" "+no-neg-immediates"
// CHECK-DEFAULT-NOT: "+no-neg-immediates"

0 comments on commit 784004e

Please sign in to comment.