Skip to content

Commit fc61113

Browse files
Yunzhong GaoYunzhong Gao
Yunzhong Gao
authored and
Yunzhong Gao
committedJul 18, 2016
Support -masm= flag for x86 assembly targets.
For assembly files without .intel_syntax or .att_syntax directives, allow the -masm= flag to supply a default assembly dialect. For example, C:\TMP> type intel.s .text mov al,0 C:\TMP> clang -masm=intel -c intel.s Without this patch, one would need to pass an "-mllvm -x86-asm-syntax=" flag directly to the backend. C:\TMP> clang -mllvm --x86-asm-syntax=intel -c intel.s Differentials Review: http://reviews.llvm.org/D22285 llvm-svn: 275877
1 parent a68b8df commit fc61113

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
 

‎clang/lib/Driver/Tools.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -6460,6 +6460,20 @@ void ClangAs::AddMIPSTargetArgs(const ArgList &Args,
64606460
CmdArgs.push_back(ABIName.data());
64616461
}
64626462

6463+
void ClangAs::AddX86TargetArgs(const ArgList &Args,
6464+
ArgStringList &CmdArgs) const {
6465+
if (Arg *A = Args.getLastArg(options::OPT_masm_EQ)) {
6466+
StringRef Value = A->getValue();
6467+
if (Value == "intel" || Value == "att") {
6468+
CmdArgs.push_back("-mllvm");
6469+
CmdArgs.push_back(Args.MakeArgString("-x86-asm-syntax=" + Value));
6470+
} else {
6471+
getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument)
6472+
<< A->getOption().getName() << Value;
6473+
}
6474+
}
6475+
}
6476+
64636477
void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
64646478
const InputInfo &Output, const InputInfoList &Inputs,
64656479
const ArgList &Args,
@@ -6607,6 +6621,11 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
66076621
case llvm::Triple::mips64el:
66086622
AddMIPSTargetArgs(Args, CmdArgs);
66096623
break;
6624+
6625+
case llvm::Triple::x86:
6626+
case llvm::Triple::x86_64:
6627+
AddX86TargetArgs(Args, CmdArgs);
6628+
break;
66106629
}
66116630

66126631
// Consume all the warning flags. Usually this would be handled more

‎clang/lib/Driver/Tools.h

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
125125
: Tool("clang::as", "clang integrated assembler", TC, RF_Full) {}
126126
void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
127127
llvm::opt::ArgStringList &CmdArgs) const;
128+
void AddX86TargetArgs(const llvm::opt::ArgList &Args,
129+
llvm::opt::ArgStringList &CmdArgs) const;
128130
bool hasGoodDiagnostics() const override { return true; }
129131
bool hasIntegratedAssembler() const override { return false; }
130132
bool hasIntegratedCPP() const override { return false; }

‎clang/test/Driver/masm.s

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang -target i386-unknown-linux -masm=intel -c %s -### 2>&1 | FileCheck --check-prefix=CHECK-INTEL %s
2+
// RUN: %clang -target i386-unknown-linux -masm=att -c %s -### 2>&1 | FileCheck --check-prefix=CHECK-ATT %s
3+
// RUN: %clang -target i386-unknown-linux -c -masm=somerequired %s -### 2>&1 | FileCheck --check-prefix=CHECK-SOMEREQUIRED %s
4+
// RUN: %clang -target arm-unknown-eabi -c -masm=intel %s -### 2>&1 | FileCheck --check-prefix=CHECK-ARM %s
5+
6+
// CHECK-INTEL: -x86-asm-syntax=intel
7+
// CHECK-ATT: -x86-asm-syntax=att
8+
// CHECK-SOMEREQUIRED: error: unsupported argument 'somerequired' to option 'masm='
9+
// CHECK-ARM: warning: argument unused during compilation: '-masm=intel'
10+
.text
11+
mov al, 0

0 commit comments

Comments
 (0)