Constify subtarget info properly so that we dont cast away the const in

the SubtargetInfoKV tables. Found by gcc48 -Wcast-qual.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163251 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Roman Divacky 2012-09-05 21:43:57 +00:00
parent b438615abd
commit 98eb98b0f2
5 changed files with 11 additions and 11 deletions

View File

@ -72,7 +72,7 @@ public:
/// getSchedModelForCPU - Get the machine model of a CPU.
///
MCSchedModel *getSchedModelForCPU(StringRef CPU) const;
const MCSchedModel *getSchedModelForCPU(StringRef CPU) const;
/// getInstrItineraryForCPU - Get scheduling itinerary of a CPU.
///

View File

@ -50,7 +50,7 @@ struct SubtargetFeatureKV {
//
struct SubtargetInfoKV {
const char *Key; // K-V key string
void *Value; // K-V pointer value
const void *Value; // K-V pointer value
// Compare routine for std binary search
bool operator<(const SubtargetInfoKV &S) const {
@ -96,8 +96,8 @@ public:
size_t FeatureTableSize);
/// Get scheduling itinerary of a CPU.
void *getItinerary(const StringRef CPU,
const SubtargetInfoKV *Table, size_t TableSize);
const void *getItinerary(const StringRef CPU,
const SubtargetInfoKV *Table, size_t TableSize);
/// Print feature string.
void print(raw_ostream &OS) const;

View File

@ -70,7 +70,7 @@ uint64_t MCSubtargetInfo::ToggleFeature(StringRef FS) {
}
MCSchedModel *
const MCSchedModel *
MCSubtargetInfo::getSchedModelForCPU(StringRef CPU) const {
assert(ProcSchedModel && "Processor machine model not available!");
@ -93,11 +93,11 @@ MCSubtargetInfo::getSchedModelForCPU(StringRef CPU) const {
return &MCSchedModel::DefaultSchedModel;
}
assert(Found->Value && "Missing processor SchedModel value");
return (MCSchedModel *)Found->Value;
return (const MCSchedModel *)Found->Value;
}
InstrItineraryData
MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU) const {
MCSchedModel *SchedModel = getSchedModelForCPU(CPU);
const MCSchedModel *SchedModel = getSchedModelForCPU(CPU);
return InstrItineraryData(SchedModel, Stages, OperandCycles, ForwardingPaths);
}

View File

@ -337,9 +337,9 @@ uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,
}
/// Get scheduling itinerary of a CPU.
void *SubtargetFeatures::getItinerary(const StringRef CPU,
const SubtargetInfoKV *Table,
size_t TableSize) {
const void *SubtargetFeatures::getItinerary(const StringRef CPU,
const SubtargetInfoKV *Table,
size_t TableSize) {
assert(Table && "missing table");
#ifndef NDEBUG
for (size_t i = 1; i < TableSize; i++) {

View File

@ -626,7 +626,7 @@ void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) {
// Emit as { "cpu", procinit },
OS << " { "
<< "\"" << Name << "\", "
<< "(void *)&" << ProcModelName;
<< "(const void *)&" << ProcModelName;
OS << " }";