aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/TargetInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Basic/TargetInfo.cpp')
-rw-r--r--lib/Basic/TargetInfo.cpp144
1 files changed, 58 insertions, 86 deletions
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index dbd2f9ae9954..1648a27d8b37 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -71,12 +71,13 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
FloatFormat = &llvm::APFloat::IEEEsingle;
DoubleFormat = &llvm::APFloat::IEEEdouble;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
- DescriptionString = nullptr;
+ DataLayoutString = nullptr;
UserLabelPrefix = "_";
MCountName = "mcount";
RegParmMax = 0;
SSERegParmMax = 0;
HasAlignMac68kSupport = false;
+ HasBuiltinMSVaList = false;
// Default to no types using fpret.
RealTypeUsesObjCFPRet = 0;
@@ -286,9 +287,9 @@ void TargetInfo::adjust(const LangOptions &Opts) {
LongLongWidth = LongLongAlign = 128;
HalfWidth = HalfAlign = 16;
FloatWidth = FloatAlign = 32;
-
- // Embedded 32-bit targets (OpenCL EP) might have double C type
- // defined as float. Let's not override this as it might lead
+
+ // Embedded 32-bit targets (OpenCL EP) might have double C type
+ // defined as float. Let's not override this as it might lead
// to generating illegal code that uses 64bit doubles.
if (DoubleWidth != FloatWidth) {
DoubleWidth = DoubleAlign = 64;
@@ -311,6 +312,18 @@ void TargetInfo::adjust(const LangOptions &Opts) {
}
}
+bool TargetInfo::initFeatureMap(
+ llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
+ const std::vector<std::string> &FeatureVec) const {
+ for (const auto &F : FeatureVec) {
+ StringRef Name = F;
+ // Apply the feature via the target.
+ bool Enabled = Name[0] == '+';
+ setFeatureEnabled(Features, Name.substr(1), Enabled);
+ }
+ return true;
+}
+
//===----------------------------------------------------------------------===//
@@ -326,7 +339,7 @@ static StringRef removeGCCRegisterPrefix(StringRef Name) {
/// Sema.
bool TargetInfo::isValidClobber(StringRef Name) const {
return (isValidGCCRegisterName(Name) ||
- Name == "memory" || Name == "cc");
+ Name == "memory" || Name == "cc");
}
/// isValidGCCRegisterName - Returns whether the passed in string
@@ -336,56 +349,43 @@ bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
if (Name.empty())
return false;
- const char * const *Names;
- unsigned NumNames;
-
// Get rid of any register prefix.
Name = removeGCCRegisterPrefix(Name);
if (Name.empty())
- return false;
+ return false;
- getGCCRegNames(Names, NumNames);
+ ArrayRef<const char *> Names = getGCCRegNames();
// If we have a number it maps to an entry in the register name array.
if (isDigit(Name[0])) {
- int n;
+ unsigned n;
if (!Name.getAsInteger(0, n))
- return n >= 0 && (unsigned)n < NumNames;
+ return n < Names.size();
}
// Check register names.
- for (unsigned i = 0; i < NumNames; i++) {
- if (Name == Names[i])
- return true;
- }
+ if (std::find(Names.begin(), Names.end(), Name) != Names.end())
+ return true;
// Check any additional names that we have.
- const AddlRegName *AddlNames;
- unsigned NumAddlNames;
- getGCCAddlRegNames(AddlNames, NumAddlNames);
- for (unsigned i = 0; i < NumAddlNames; i++)
- for (unsigned j = 0; j < llvm::array_lengthof(AddlNames[i].Names); j++) {
- if (!AddlNames[i].Names[j])
- break;
+ for (const AddlRegName &ARN : getGCCAddlRegNames())
+ for (const char *AN : ARN.Names) {
+ if (!AN)
+ break;
// Make sure the register that the additional name is for is within
// the bounds of the register names from above.
- if (AddlNames[i].Names[j] == Name && AddlNames[i].RegNum < NumNames)
- return true;
- }
+ if (AN == Name && ARN.RegNum < Names.size())
+ return true;
+ }
// Now check aliases.
- const GCCRegAlias *Aliases;
- unsigned NumAliases;
-
- getGCCRegAliases(Aliases, NumAliases);
- for (unsigned i = 0; i < NumAliases; i++) {
- for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
- if (!Aliases[i].Aliases[j])
+ for (const GCCRegAlias &GRA : getGCCRegAliases())
+ for (const char *A : GRA.Aliases) {
+ if (!A)
break;
- if (Aliases[i].Aliases[j] == Name)
+ if (A == Name)
return true;
}
- }
return false;
}
@@ -397,48 +397,36 @@ TargetInfo::getNormalizedGCCRegisterName(StringRef Name) const {
// Get rid of any register prefix.
Name = removeGCCRegisterPrefix(Name);
- const char * const *Names;
- unsigned NumNames;
-
- getGCCRegNames(Names, NumNames);
+ ArrayRef<const char *> Names = getGCCRegNames();
// First, check if we have a number.
if (isDigit(Name[0])) {
- int n;
+ unsigned n;
if (!Name.getAsInteger(0, n)) {
- assert(n >= 0 && (unsigned)n < NumNames &&
- "Out of bounds register number!");
+ assert(n < Names.size() && "Out of bounds register number!");
return Names[n];
}
}
// Check any additional names that we have.
- const AddlRegName *AddlNames;
- unsigned NumAddlNames;
- getGCCAddlRegNames(AddlNames, NumAddlNames);
- for (unsigned i = 0; i < NumAddlNames; i++)
- for (unsigned j = 0; j < llvm::array_lengthof(AddlNames[i].Names); j++) {
- if (!AddlNames[i].Names[j])
- break;
+ for (const AddlRegName &ARN : getGCCAddlRegNames())
+ for (const char *AN : ARN.Names) {
+ if (!AN)
+ break;
// Make sure the register that the additional name is for is within
// the bounds of the register names from above.
- if (AddlNames[i].Names[j] == Name && AddlNames[i].RegNum < NumNames)
- return Name;
+ if (AN == Name && ARN.RegNum < Names.size())
+ return Name;
}
// Now check aliases.
- const GCCRegAlias *Aliases;
- unsigned NumAliases;
-
- getGCCRegAliases(Aliases, NumAliases);
- for (unsigned i = 0; i < NumAliases; i++) {
- for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
- if (!Aliases[i].Aliases[j])
+ for (const GCCRegAlias &RA : getGCCRegAliases())
+ for (const char *A : RA.Aliases) {
+ if (!A)
break;
- if (Aliases[i].Aliases[j] == Name)
- return Aliases[i].Register;
+ if (A == Name)
+ return RA.Register;
}
- }
return Name;
}
@@ -513,8 +501,7 @@ bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
}
bool TargetInfo::resolveSymbolicName(const char *&Name,
- ConstraintInfo *OutputConstraints,
- unsigned NumOutputs,
+ ArrayRef<ConstraintInfo> OutputConstraints,
unsigned &Index) const {
assert(*Name == '[' && "Symbolic name did not start with '['");
Name++;
@@ -529,16 +516,16 @@ bool TargetInfo::resolveSymbolicName(const char *&Name,
std::string SymbolicName(Start, Name - Start);
- for (Index = 0; Index != NumOutputs; ++Index)
+ for (Index = 0; Index != OutputConstraints.size(); ++Index)
if (SymbolicName == OutputConstraints[Index].getName())
return true;
return false;
}
-bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
- unsigned NumOutputs,
- ConstraintInfo &Info) const {
+bool TargetInfo::validateInputConstraint(
+ MutableArrayRef<ConstraintInfo> OutputConstraints,
+ ConstraintInfo &Info) const {
const char *Name = Info.ConstraintStr.c_str();
if (!*Name)
@@ -559,13 +546,13 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
return false;
// Check if matching constraint is out of bounds.
- if (i >= NumOutputs) return false;
+ if (i >= OutputConstraints.size()) return false;
// A number must refer to an output only operand.
if (OutputConstraints[i].isReadWrite())
return false;
- // If the constraint is already tied, it must be tied to the
+ // If the constraint is already tied, it must be tied to the
// same operand referenced to by the number.
if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
return false;
@@ -582,10 +569,10 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
break;
case '[': {
unsigned Index = 0;
- if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
+ if (!resolveSymbolicName(Name, OutputConstraints, Index))
return false;
- // If the constraint is already tied, it must be tied to the
+ // If the constraint is already tied, it must be tied to the
// same operand referenced to by the number.
if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
return false;
@@ -650,18 +637,3 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
return true;
}
-
-bool TargetCXXABI::tryParse(llvm::StringRef name) {
- const Kind unknown = static_cast<Kind>(-1);
- Kind kind = llvm::StringSwitch<Kind>(name)
- .Case("arm", GenericARM)
- .Case("ios", iOS)
- .Case("itanium", GenericItanium)
- .Case("microsoft", Microsoft)
- .Case("mips", GenericMIPS)
- .Default(unknown);
- if (kind == unknown) return false;
-
- set(kind);
- return true;
-}