Skip to content

Commit 77198de

Browse files
committed
Constify subtarget info properly so that we dont cast away the const in
the SubtargetInfoKV tables. Found by gcc48 -Wcast-qual. llvm-svn: 163251
1 parent 9b034c1 commit 77198de

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

llvm/include/llvm/MC/MCSubtargetInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class MCSubtargetInfo {
7272

7373
/// getSchedModelForCPU - Get the machine model of a CPU.
7474
///
75-
MCSchedModel *getSchedModelForCPU(StringRef CPU) const;
75+
const MCSchedModel *getSchedModelForCPU(StringRef CPU) const;
7676

7777
/// getInstrItineraryForCPU - Get scheduling itinerary of a CPU.
7878
///

llvm/include/llvm/MC/SubtargetFeature.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct SubtargetFeatureKV {
5050
//
5151
struct SubtargetInfoKV {
5252
const char *Key; // K-V key string
53-
void *Value; // K-V pointer value
53+
const void *Value; // K-V pointer value
5454

5555
// Compare routine for std binary search
5656
bool operator<(const SubtargetInfoKV &S) const {
@@ -96,8 +96,8 @@ class SubtargetFeatures {
9696
size_t FeatureTableSize);
9797

9898
/// Get scheduling itinerary of a CPU.
99-
void *getItinerary(const StringRef CPU,
100-
const SubtargetInfoKV *Table, size_t TableSize);
99+
const void *getItinerary(const StringRef CPU,
100+
const SubtargetInfoKV *Table, size_t TableSize);
101101

102102
/// Print feature string.
103103
void print(raw_ostream &OS) const;

llvm/lib/MC/MCSubtargetInfo.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ uint64_t MCSubtargetInfo::ToggleFeature(StringRef FS) {
7070
}
7171

7272

73-
MCSchedModel *
73+
const MCSchedModel *
7474
MCSubtargetInfo::getSchedModelForCPU(StringRef CPU) const {
7575
assert(ProcSchedModel && "Processor machine model not available!");
7676

@@ -93,11 +93,11 @@ MCSubtargetInfo::getSchedModelForCPU(StringRef CPU) const {
9393
return &MCSchedModel::DefaultSchedModel;
9494
}
9595
assert(Found->Value && "Missing processor SchedModel value");
96-
return (MCSchedModel *)Found->Value;
96+
return (const MCSchedModel *)Found->Value;
9797
}
9898

9999
InstrItineraryData
100100
MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU) const {
101-
MCSchedModel *SchedModel = getSchedModelForCPU(CPU);
101+
const MCSchedModel *SchedModel = getSchedModelForCPU(CPU);
102102
return InstrItineraryData(SchedModel, Stages, OperandCycles, ForwardingPaths);
103103
}

llvm/lib/MC/SubtargetFeature.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,
337337
}
338338

339339
/// Get scheduling itinerary of a CPU.
340-
void *SubtargetFeatures::getItinerary(const StringRef CPU,
341-
const SubtargetInfoKV *Table,
342-
size_t TableSize) {
340+
const void *SubtargetFeatures::getItinerary(const StringRef CPU,
341+
const SubtargetInfoKV *Table,
342+
size_t TableSize) {
343343
assert(Table && "missing table");
344344
#ifndef NDEBUG
345345
for (size_t i = 1; i < TableSize; i++) {

llvm/utils/TableGen/SubtargetEmitter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) {
626626
// Emit as { "cpu", procinit },
627627
OS << " { "
628628
<< "\"" << Name << "\", "
629-
<< "(void *)&" << ProcModelName;
629+
<< "(const void *)&" << ProcModelName;
630630

631631
OS << " }";
632632

0 commit comments

Comments
 (0)