[cfe-commits] r111749 - in /cfe/trunk: include/clang/Basic/TargetInfo.h include/clang/Basic/TargetOptions.h lib/AST/ASTContext.cpp lib/AST/CXXABI.h lib/AST/ItaniumCXXABI.cpp lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp lib/CodeGen/CGCXXABI.h lib/CodeGen/CodeGenModule.cpp lib/CodeGen/ItaniumCXXABI.cpp
John McCall
rjmccall at apple.com
Sat Aug 21 15:46:04 PDT 2010
Author: rjmccall
Date: Sat Aug 21 17:46:04 2010
New Revision: 111749
URL: http://llvm.org/viewvc/llvm-project?rev=111749&view=rev
Log:
The ARM C++ ABI is sufficiently different from the Itanium C++ ABI that
it deserves its own enumerator. Obviously the implementations should
closely follow the Itanium ABI except in cases of divergence.
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/TargetOptions.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/CXXABI.h
cfe/trunk/lib/AST/ItaniumCXXABI.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Sat Aug 21 17:46:04 2010
@@ -40,8 +40,17 @@
/// TargetCXXABI - The types of C++ ABIs for which we can generate code.
enum TargetCXXABI {
- CXXABI_Unknown = -1,
+ /// The generic ("Itanium") C++ ABI, documented at:
+ /// http://www.codesourcery.com/public/cxx-abi/
CXXABI_Itanium,
+
+ /// The ARM C++ ABI, based largely on the Itanium ABI but with
+ /// significant differences.
+ /// http://infocenter.arm.com
+ /// /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
+ CXXABI_ARM,
+
+ /// The Visual Studio ABI. Only scattered official documentation exists.
CXXABI_Microsoft
};
@@ -443,12 +452,22 @@
/// setCXXABI - Use this specific C++ ABI.
///
/// \return - False on error (invalid C++ ABI name).
- virtual bool setCXXABI(const std::string &Name) {
- CXXABI = llvm::StringSwitch<TargetCXXABI>(Name)
+ bool setCXXABI(const std::string &Name) {
+ static const TargetCXXABI Unknown = static_cast<TargetCXXABI>(-1);
+ TargetCXXABI ABI = llvm::StringSwitch<TargetCXXABI>(Name)
+ .Case("arm", CXXABI_ARM)
.Case("itanium", CXXABI_Itanium)
.Case("microsoft", CXXABI_Microsoft)
- .Default(CXXABI_Unknown);
- if (CXXABI == CXXABI_Unknown) return false;
+ .Default(Unknown);
+ if (ABI == Unknown) return false;
+ return setCXXABI(ABI);
+ }
+
+ /// setCXXABI - Set the C++ ABI to be used by this implementation.
+ ///
+ /// \return - False on error (ABI not valid on this target)
+ virtual bool setCXXABI(TargetCXXABI ABI) {
+ CXXABI = ABI;
return true;
}
Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Sat Aug 21 17:46:04 2010
@@ -18,11 +18,6 @@
/// TargetOptions - Options for controlling the target.
class TargetOptions {
public:
-
- TargetOptions() {
- CXXABI = "itanium";
- }
-
/// If given, the name of the target triple to compile for. If not given the
/// target will be selected to match the host.
std::string Triple;
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Aug 21 17:46:04 2010
@@ -136,13 +136,17 @@
}
CXXABI *ASTContext::createCXXABI(const TargetInfo &T) {
- if (!LangOpts.CPlusPlus) return NULL;
+ if (!LangOpts.CPlusPlus) return 0;
+
switch (T.getCXXABI()) {
- default:
+ case CXXABI_ARM:
+ return CreateARMCXXABI(*this);
+ case CXXABI_Itanium:
return CreateItaniumCXXABI(*this);
case CXXABI_Microsoft:
return CreateMicrosoftCXXABI(*this);
}
+ return 0;
}
ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
Modified: cfe/trunk/lib/AST/CXXABI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXABI.h?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CXXABI.h (original)
+++ cfe/trunk/lib/AST/CXXABI.h Sat Aug 21 17:46:04 2010
@@ -31,6 +31,7 @@
};
/// Creates an instance of a C++ ABI class.
+CXXABI *CreateARMCXXABI(ASTContext &Ctx);
CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
}
Modified: cfe/trunk/lib/AST/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumCXXABI.cpp?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumCXXABI.cpp Sat Aug 21 17:46:04 2010
@@ -11,6 +11,10 @@
// documented at:
// http://www.codesourcery.com/public/cxx-abi/abi.html
// http://www.codesourcery.com/public/cxx-abi/abi-eh.html
+//
+// It also supports the closely-related ARM C++ ABI, documented at:
+// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
+//
//===----------------------------------------------------------------------===//
#include "CXXABI.h"
@@ -21,6 +25,7 @@
namespace {
class ItaniumCXXABI : public CXXABI {
+protected:
ASTContext &Context;
public:
ItaniumCXXABI(ASTContext &Ctx) : Context(Ctx) { }
@@ -31,9 +36,17 @@
return 1;
}
};
+
+class ARMCXXABI : public ItaniumCXXABI {
+public:
+ ARMCXXABI(ASTContext &Ctx) : ItaniumCXXABI(Ctx) { }
+};
}
CXXABI *clang::CreateItaniumCXXABI(ASTContext &Ctx) {
return new ItaniumCXXABI(Ctx);
}
+CXXABI *clang::CreateARMCXXABI(ASTContext &Ctx) {
+ return new ARMCXXABI(Ctx);
+}
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Sat Aug 21 17:46:04 2010
@@ -58,6 +58,9 @@
// Default to no types using fpret.
RealTypeUsesObjCFPRet = 0;
+
+ // Default to using the Itanium ABI.
+ CXXABI = CXXABI_Itanium;
}
// Out of line virtual dtor for TargetInfo.
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sat Aug 21 17:46:04 2010
@@ -1585,6 +1585,9 @@
"i64:64:64-f32:32:32-f64:64:64-"
"v64:64:64-v128:128:128-a0:0:64-n32");
}
+
+ // ARM targets default to using the ARM C++ ABI.
+ CXXABI = CXXABI_ARM;
}
virtual const char *getABI() const { return ABI.c_str(); }
virtual bool setABI(const std::string &Name) {
@@ -2631,7 +2634,7 @@
}
// Set the target C++ ABI.
- if (!Target->setCXXABI(Opts.CXXABI)) {
+ if (!Opts.CXXABI.empty() && !Target->setCXXABI(Opts.CXXABI)) {
Diags.Report(diag::err_target_unknown_cxxabi) << Opts.CXXABI;
return 0;
}
Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Sat Aug 21 17:46:04 2010
@@ -30,6 +30,7 @@
};
/// Creates an instance of a C++ ABI class.
+CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
}
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Aug 21 17:46:04 2010
@@ -91,11 +91,15 @@
void CodeGenModule::createCXXABI() {
switch (Context.Target.getCXXABI()) {
- default:
+ case CXXABI_ARM:
+ ABI = CreateARMCXXABI(*this);
+ break;
+ case CXXABI_Itanium:
ABI = CreateItaniumCXXABI(*this);
break;
case CXXABI_Microsoft:
ABI = CreateMicrosoftCXXABI(*this);
+ break;
}
}
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=111749&r1=111748&r2=111749&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Sat Aug 21 17:46:04 2010
@@ -12,6 +12,10 @@
// documented at:
// http://www.codesourcery.com/public/cxx-abi/abi.html
// http://www.codesourcery.com/public/cxx-abi/abi-eh.html
+//
+// It also supports the closely-related ARM ABI, documented at:
+// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
+//
//===----------------------------------------------------------------------===//
#include "CGCXXABI.h"
@@ -31,9 +35,18 @@
return MangleCtx;
}
};
+
+class ARMCXXABI : public ItaniumCXXABI {
+public:
+ ARMCXXABI(CodeGen::CodeGenModule &CGM) : ItaniumCXXABI(CGM) {}
+};
}
CodeGen::CGCXXABI *CodeGen::CreateItaniumCXXABI(CodeGenModule &CGM) {
return new ItaniumCXXABI(CGM);
}
+CodeGen::CGCXXABI *CodeGen::CreateARMCXXABI(CodeGenModule &CGM) {
+ return new ARMCXXABI(CGM);
+}
+
More information about the cfe-commits
mailing list