mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
The getDefaultSubtargetFeatures method of SubtargetFeature did actually return a
string of features for that target. However LTO was using that string to pass into the "create target machine" stuff. That stuff needed the feature string to be in a particular form. In particular, it needed the CPU specified first and then the attributes. If there isn't a CPU specified, it required it to be blank -- e.g., ",+altivec". Yuck. Modify the getDefaultSubtargetFeatures method to be a non-static member function. For all attributes for a specific subtarget, it will add them in like normal. It will also take a CPU string so that it can satisfy this horrible syntax. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103451 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -108,9 +108,10 @@ public:
|
|||||||
// Dump feature info.
|
// Dump feature info.
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
/// Retrieve a formatted string of the default features for
|
/// Retrieve a formatted string of the default features for the specified
|
||||||
/// the specified target triple.
|
/// target triple.
|
||||||
static std::string getDefaultSubtargetFeatures(const Triple &Triple);
|
void getDefaultSubtargetFeatures(const std::string &CPU,
|
||||||
|
const Triple& Triple);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End namespace llvm
|
} // End namespace llvm
|
||||||
|
@ -359,22 +359,28 @@ void SubtargetFeatures::dump() const {
|
|||||||
print(dbgs());
|
print(dbgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getDefaultSubtargetFeatures - Return a string listing
|
/// getDefaultSubtargetFeatures - Return a string listing the features
|
||||||
/// the features associated with the target triple.
|
/// associated with the target triple.
|
||||||
///
|
///
|
||||||
/// FIXME: This is an inelegant way of specifying the features of a
|
/// FIXME: This is an inelegant way of specifying the features of a
|
||||||
/// subtarget. It would be better if we could encode this information
|
/// subtarget. It would be better if we could encode this information
|
||||||
/// into the IR. See <rdar://5972456>.
|
/// into the IR. See <rdar://5972456>.
|
||||||
///
|
///
|
||||||
std::string SubtargetFeatures::getDefaultSubtargetFeatures(
|
void SubtargetFeatures::getDefaultSubtargetFeatures(const std::string &CPU,
|
||||||
const Triple& Triple) {
|
const Triple& Triple) {
|
||||||
|
setCPU(CPU);
|
||||||
|
|
||||||
|
const char *Attrs = 0;
|
||||||
|
|
||||||
switch (Triple.getVendor()) {
|
switch (Triple.getVendor()) {
|
||||||
case Triple::Apple:
|
case Triple::Apple:
|
||||||
switch (Triple.getArch()) {
|
switch (Triple.getArch()) {
|
||||||
case Triple::ppc: // powerpc-apple-*
|
case Triple::ppc: // powerpc-apple-*
|
||||||
return std::string("altivec");
|
Attrs = "altivec";
|
||||||
|
break;
|
||||||
case Triple::ppc64: // powerpc64-apple-*
|
case Triple::ppc64: // powerpc64-apple-*
|
||||||
return std::string("64bit,altivec");
|
Attrs = "64bit,altivec";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -383,5 +389,11 @@ std::string SubtargetFeatures::getDefaultSubtargetFeatures(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string("");
|
StringRef SR(Attrs);
|
||||||
|
|
||||||
|
while (!SR.empty()) {
|
||||||
|
std::pair<StringRef, StringRef> Res = SR.split(',');
|
||||||
|
AddFeature(Res.first);
|
||||||
|
SR = Res.second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,8 +300,9 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// construct LTModule, hand over ownership of module and target
|
// construct LTModule, hand over ownership of module and target
|
||||||
const std::string FeatureStr =
|
SubtargetFeatures Features;
|
||||||
SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
|
Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple));
|
||||||
|
std::string FeatureStr = Features.getString();
|
||||||
_target = march->createTargetMachine(Triple, FeatureStr);
|
_target = march->createTargetMachine(Triple, FeatureStr);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -140,8 +140,9 @@ LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// construct LTModule, hand over ownership of module and target
|
// construct LTModule, hand over ownership of module and target
|
||||||
const std::string FeatureStr =
|
SubtargetFeatures Features;
|
||||||
SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
|
Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple));
|
||||||
|
std::string FeatureStr = Features.getString();
|
||||||
TargetMachine* target = march->createTargetMachine(Triple, FeatureStr);
|
TargetMachine* target = march->createTargetMachine(Triple, FeatureStr);
|
||||||
return new LTOModule(m.take(), target);
|
return new LTOModule(m.take(), target);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user