Add some enum goodness as requested by Chris. Now instead of storing the
active C++ ABI as a raw string, we store it as an enum. This should improve performance somewhat. And yes, this time, I started from a clean build directory, and all the tests passed. :) llvm-svn: 111507
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
// FIXME: Daniel isn't smart enough to use a prototype for this.
|
// FIXME: Daniel isn't smart enough to use a prototype for this.
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/ADT/Triple.h"
|
#include "llvm/ADT/Triple.h"
|
||||||
#include "llvm/System/DataTypes.h"
|
#include "llvm/System/DataTypes.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@@ -37,6 +38,13 @@ class TargetOptions;
|
|||||||
|
|
||||||
namespace Builtin { struct Info; }
|
namespace Builtin { struct Info; }
|
||||||
|
|
||||||
|
/// TargetCXXABI - The types of C++ ABIs for which we can generate code.
|
||||||
|
enum TargetCXXABI {
|
||||||
|
CXXABI_Unknown = -1,
|
||||||
|
CXXABI_Itanium,
|
||||||
|
CXXABI_Microsoft
|
||||||
|
};
|
||||||
|
|
||||||
/// TargetInfo - This class exposes information about the current target.
|
/// TargetInfo - This class exposes information about the current target.
|
||||||
///
|
///
|
||||||
class TargetInfo {
|
class TargetInfo {
|
||||||
@@ -58,7 +66,7 @@ protected:
|
|||||||
const char *UserLabelPrefix;
|
const char *UserLabelPrefix;
|
||||||
const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
|
const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
|
||||||
unsigned char RegParmMax, SSERegParmMax;
|
unsigned char RegParmMax, SSERegParmMax;
|
||||||
std::string CXXABI;
|
TargetCXXABI CXXABI;
|
||||||
|
|
||||||
unsigned HasAlignMac68kSupport : 1;
|
unsigned HasAlignMac68kSupport : 1;
|
||||||
unsigned RealTypeUsesObjCFPRet : 3;
|
unsigned RealTypeUsesObjCFPRet : 3;
|
||||||
@@ -412,7 +420,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// getCXXABI - Get the C++ ABI in use.
|
/// getCXXABI - Get the C++ ABI in use.
|
||||||
virtual llvm::StringRef getCXXABI() const {
|
virtual TargetCXXABI getCXXABI() const {
|
||||||
return CXXABI;
|
return CXXABI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,11 +442,13 @@ public:
|
|||||||
|
|
||||||
/// setCXXABI - Use this specific C++ ABI.
|
/// setCXXABI - Use this specific C++ ABI.
|
||||||
///
|
///
|
||||||
/// \return - False on error (invalid ABI name).
|
/// \return - False on error (invalid C++ ABI name).
|
||||||
virtual bool setCXXABI(const std::string &Name) {
|
virtual bool setCXXABI(const std::string &Name) {
|
||||||
if (Name != "itanium" && Name != "microsoft")
|
CXXABI = llvm::StringSwitch<TargetCXXABI>(Name)
|
||||||
return false;
|
.Case("itanium", CXXABI_Itanium)
|
||||||
CXXABI = Name;
|
.Case("microsoft", CXXABI_Microsoft)
|
||||||
|
.Default(CXXABI_Unknown);
|
||||||
|
if (CXXABI == CXXABI_Unknown) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,10 +137,12 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
|
|||||||
|
|
||||||
CXXABI *ASTContext::createCXXABI(const TargetInfo &T) {
|
CXXABI *ASTContext::createCXXABI(const TargetInfo &T) {
|
||||||
if (!LangOpts.CPlusPlus) return NULL;
|
if (!LangOpts.CPlusPlus) return NULL;
|
||||||
if (T.getCXXABI() == "microsoft")
|
switch (T.getCXXABI()) {
|
||||||
return CreateMicrosoftCXXABI(*this);
|
default:
|
||||||
else
|
|
||||||
return CreateItaniumCXXABI(*this);
|
return CreateItaniumCXXABI(*this);
|
||||||
|
case CXXABI_Microsoft:
|
||||||
|
return CreateMicrosoftCXXABI(*this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
|
ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
|
||||||
|
|||||||
@@ -1463,8 +1463,6 @@ RecordLayoutBuilder::ComputeKeyFunction(const CXXRecordDecl *RD) {
|
|||||||
|
|
||||||
// This class implements layout specific to the Microsoft ABI.
|
// This class implements layout specific to the Microsoft ABI.
|
||||||
class MSRecordLayoutBuilder: public RecordLayoutBuilder {
|
class MSRecordLayoutBuilder: public RecordLayoutBuilder {
|
||||||
friend class ASTContext;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MSRecordLayoutBuilder(ASTContext& Ctx, EmptySubobjectMap *EmptySubobjects):
|
MSRecordLayoutBuilder(ASTContext& Ctx, EmptySubobjectMap *EmptySubobjects):
|
||||||
RecordLayoutBuilder(Ctx, EmptySubobjects) {}
|
RecordLayoutBuilder(Ctx, EmptySubobjects) {}
|
||||||
@@ -1514,10 +1512,13 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
|
|||||||
|
|
||||||
// When compiling for Microsoft, use the special MS builder.
|
// When compiling for Microsoft, use the special MS builder.
|
||||||
RecordLayoutBuilder *Builder;
|
RecordLayoutBuilder *Builder;
|
||||||
if (Target.getCXXABI() == "microsoft")
|
switch (Target.getCXXABI()) {
|
||||||
Builder = new MSRecordLayoutBuilder(*this, &EmptySubobjects);
|
default:
|
||||||
else
|
|
||||||
Builder = new RecordLayoutBuilder(*this, &EmptySubobjects);
|
Builder = new RecordLayoutBuilder(*this, &EmptySubobjects);
|
||||||
|
break;
|
||||||
|
case CXXABI_Microsoft:
|
||||||
|
Builder = new MSRecordLayoutBuilder(*this, &EmptySubobjects);
|
||||||
|
}
|
||||||
Builder->Layout(RD);
|
Builder->Layout(RD);
|
||||||
|
|
||||||
// FIXME: This is not always correct. See the part about bitfields at
|
// FIXME: This is not always correct. See the part about bitfields at
|
||||||
|
|||||||
@@ -90,10 +90,13 @@ void CodeGenModule::createObjCRuntime() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CodeGenModule::createCXXABI() {
|
void CodeGenModule::createCXXABI() {
|
||||||
if (Context.Target.getCXXABI() == "microsoft")
|
switch (Context.Target.getCXXABI()) {
|
||||||
ABI = CreateMicrosoftCXXABI(*this);
|
default:
|
||||||
else
|
|
||||||
ABI = CreateItaniumCXXABI(*this);
|
ABI = CreateItaniumCXXABI(*this);
|
||||||
|
break;
|
||||||
|
case CXXABI_Microsoft:
|
||||||
|
ABI = CreateMicrosoftCXXABI(*this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeGenModule::Release() {
|
void CodeGenModule::Release() {
|
||||||
|
|||||||
@@ -897,7 +897,7 @@ QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
|
|||||||
// type. In such cases, the compiler makes a worst-case assumption.
|
// type. In such cases, the compiler makes a worst-case assumption.
|
||||||
// We make no such assumption right now, so emit an error if the
|
// We make no such assumption right now, so emit an error if the
|
||||||
// class isn't a complete type.
|
// class isn't a complete type.
|
||||||
if (Context.Target.getCXXABI() == "microsoft" &&
|
if (Context.Target.getCXXABI() == CXXABI_Microsoft &&
|
||||||
RequireCompleteType(Loc, Class, diag::err_incomplete_type))
|
RequireCompleteType(Loc, Class, diag::err_incomplete_type))
|
||||||
return QualType();
|
return QualType();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user