[cfe-commits] r105804 - in /cfe/trunk: include/clang/Basic/DiagnosticCommonKinds.td include/clang/Basic/TargetInfo.h include/clang/Basic/TargetOptions.h include/clang/Driver/CC1Options.td lib/Basic/Targets.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Frontend/ASTUnit.cpp lib/Frontend/CompilerInvocation.cpp
Charles Davis
cdavis at mines.edu
Thu Jun 10 18:06:47 PDT 2010
Author: cdavis
Date: Thu Jun 10 20:06:47 2010
New Revision: 105804
URL: http://llvm.org/viewvc/llvm-project?rev=105804&view=rev
Log:
Add an option to specify the target C++ ABI to the frontend. Use it to
select either the default Itanium ABI or the new, experimental Microsoft ABI.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/TargetOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Jun 10 20:06:47 2010
@@ -66,6 +66,7 @@
"unknown target triple '%0', please use -triple or -arch">;
def err_target_unknown_cpu : Error<"unknown target CPU '%0'">;
def err_target_unknown_abi : Error<"unknown target ABI '%0'">;
+def err_target_unknown_cxxabi : Error<"unknown C++ ABI '%0'">;
def err_target_invalid_feature : Error<"invalid target feature '%0'">;
// Source manager
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Jun 10 20:06:47 2010
@@ -58,6 +58,7 @@
const char *UserLabelPrefix;
const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
unsigned char RegParmMax, SSERegParmMax;
+ std::string CXXABI;
unsigned HasAlignMac68kSupport : 1;
@@ -396,6 +397,11 @@
return "";
}
+ /// getCXXABI - Get the C++ ABI in use.
+ virtual llvm::StringRef getCXXABI() const {
+ return CXXABI;
+ }
+
/// setCPU - Target the specific CPU.
///
/// \return - False on error (invalid CPU name).
@@ -412,6 +418,16 @@
return false;
}
+ /// setCXXABI - Use this specific C++ ABI.
+ ///
+ /// \return - False on error (invalid ABI name).
+ virtual bool setCXXABI(const std::string &Name) {
+ if (Name != "itanium" && Name != "microsoft")
+ return false;
+ CXXABI = Name;
+ return true;
+ }
+
/// setFeatureEnabled - Enable or disable a specific target feature,
/// the feature name must be valid.
///
Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Thu Jun 10 20:06:47 2010
@@ -29,6 +29,10 @@
/// If given, the name of the target ABI to use.
std::string ABI;
+ /// If given, the name of the target C++ ABI to use. If not given, defaults
+ /// to "itanium".
+ std::string CXXABI;
+
/// The list of target specific features to enable or disable -- this should
/// be a list of strings starting with by '+' or '-'.
std::vector<std::string> Features;
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Jun 10 20:06:47 2010
@@ -18,6 +18,8 @@
// Target Options
//===----------------------------------------------------------------------===//
+def cxx_abi : Separate<"-cxx-abi">,
+ HelpText<"Target a particular C++ ABI type">;
def target_abi : Separate<"-target-abi">,
HelpText<"Target a particular ABI type">;
def target_cpu : Separate<"-target-cpu">,
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jun 10 20:06:47 2010
@@ -2475,6 +2475,12 @@
return 0;
}
+ // Set the target C++ ABI.
+ if (!Target->setCXXABI(Opts.CXXABI)) {
+ Diags.Report(diag::err_target_unknown_cxxabi) << Opts.CXXABI;
+ return 0;
+ }
+
// Compute the default target features, we need the target to handle this
// because features may have dependencies on one another.
llvm::StringMap<bool> Features;
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jun 10 20:06:47 2010
@@ -86,8 +86,10 @@
}
void CodeGenModule::createCXXABI() {
- // For now, just create an Itanium ABI.
- ABI = CreateItaniumCXXABI(*this);
+ if (Context.Target.getCXXABI() == "microsoft")
+ ABI = CreateMicrosoftCXXABI(*this);
+ else
+ ABI = CreateItaniumCXXABI(*this);
}
void CodeGenModule::Release() {
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Thu Jun 10 20:06:47 2010
@@ -124,7 +124,7 @@
assert(false && "Can't yet mangle destructors!");
}
-CXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM) {
+CXXABI *clang::CodeGen::CreateMicrosoftCXXABI(CodeGenModule &CGM) {
return new MicrosoftCXXABI(CGM);
}
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jun 10 20:06:47 2010
@@ -219,6 +219,7 @@
// FIXME: This is broken, we should store the TargetOptions in the PCH.
TargetOptions TargetOpts;
TargetOpts.ABI = "";
+ TargetOpts.CXXABI = "itanium";
TargetOpts.CPU = "";
TargetOpts.Features.clear();
TargetOpts.Triple = TargetTriple;
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=105804&r1=105803&r2=105804&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun 10 20:06:47 2010
@@ -680,6 +680,8 @@
Res.push_back("-target-abi");
Res.push_back(Opts.ABI);
}
+ Res.push_back("-cxx-abi");
+ Res.push_back(Opts.CXXABI);
for (unsigned i = 0, e = Opts.Features.size(); i != e; ++i) {
Res.push_back("-target-feature");
Res.push_back(Opts.Features[i]);
@@ -1367,6 +1369,7 @@
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {
using namespace cc1options;
Opts.ABI = Args.getLastArgValue(OPT_target_abi);
+ Opts.CXXABI = Args.getLastArgValue(OPT_cxx_abi);
Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
Opts.Triple = Args.getLastArgValue(OPT_triple);
Opts.Features = Args.getAllArgValues(OPT_target_feature);
@@ -1374,6 +1377,10 @@
// Use the host triple if unspecified.
if (Opts.Triple.empty())
Opts.Triple = llvm::sys::getHostTriple();
+
+ // Use the Itanium C++ ABI if unspecified.
+ if (Opts.CXXABI.empty())
+ Opts.CXXABI = "itanium";
}
//
More information about the cfe-commits
mailing list