summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@freebsd.org>2012-09-05 21:43:57 +0000
committerRoman Divacky <rdivacky@freebsd.org>2012-09-05 21:43:57 +0000
commit98eb98b0f2e6573f5aee67ce3e75624392d637b7 (patch)
tree95d5e86b1b4be80756c23980cb54d5508eeec12c
parentb438615abdc826a2fef33895b50dc60e3f39f988 (diff)
downloadllvm-98eb98b0f2e6573f5aee67ce3e75624392d637b7.tar.gz
llvm-98eb98b0f2e6573f5aee67ce3e75624392d637b7.tar.bz2
llvm-98eb98b0f2e6573f5aee67ce3e75624392d637b7.tar.xz
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
-rw-r--r--include/llvm/MC/MCSubtargetInfo.h2
-rw-r--r--include/llvm/MC/SubtargetFeature.h6
-rw-r--r--lib/MC/MCSubtargetInfo.cpp6
-rw-r--r--lib/MC/SubtargetFeature.cpp6
-rw-r--r--utils/TableGen/SubtargetEmitter.cpp2
5 files changed, 11 insertions, 11 deletions
diff --git a/include/llvm/MC/MCSubtargetInfo.h b/include/llvm/MC/MCSubtargetInfo.h
index 31d632de60..6c96f49716 100644
--- a/include/llvm/MC/MCSubtargetInfo.h
+++ b/include/llvm/MC/MCSubtargetInfo.h
@@ -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.
///
diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h
index 507d882775..87c5fd3969 100644
--- a/include/llvm/MC/SubtargetFeature.h
+++ b/include/llvm/MC/SubtargetFeature.h
@@ -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;
diff --git a/lib/MC/MCSubtargetInfo.cpp b/lib/MC/MCSubtargetInfo.cpp
index 05c83f760a..cbf853cd8e 100644
--- a/lib/MC/MCSubtargetInfo.cpp
+++ b/lib/MC/MCSubtargetInfo.cpp
@@ -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);
}
diff --git a/lib/MC/SubtargetFeature.cpp b/lib/MC/SubtargetFeature.cpp
index 0a44e7731b..f43197b5c2 100644
--- a/lib/MC/SubtargetFeature.cpp
+++ b/lib/MC/SubtargetFeature.cpp
@@ -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++) {
diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp
index 3472343959..5dfd716d89 100644
--- a/utils/TableGen/SubtargetEmitter.cpp
+++ b/utils/TableGen/SubtargetEmitter.cpp
@@ -626,7 +626,7 @@ void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) {
// Emit as { "cpu", procinit },
OS << " { "
<< "\"" << Name << "\", "
- << "(void *)&" << ProcModelName;
+ << "(const void *)&" << ProcModelName;
OS << " }";