aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/SubtargetFeature.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2011-07-09 05:47:46 +0000
committerEvan Cheng <evan.cheng@apple.com>2011-07-09 05:47:46 +0000
commit91111d270614d072e7d96bd695a1daef808775a8 (patch)
tree90f0922eb8e4b79dc6cf36f2b7d5ea59e99fbbf5 /llvm/lib/MC/SubtargetFeature.cpp
parent0081892d335b22f2d3b0b92071f7e7fc9d0172ec (diff)
downloadllvm-91111d270614d072e7d96bd695a1daef808775a8.zip
llvm-91111d270614d072e7d96bd695a1daef808775a8.tar.gz
llvm-91111d270614d072e7d96bd695a1daef808775a8.tar.bz2
Change createAsmParser to take a MCSubtargetInfo instead of triple,
CPU, and feature string. Parsing some asm directives can change subtarget state (e.g. .code 16) and it must be reflected in other modules (e.g. MCCodeEmitter). That is, the MCSubtargetInfo instance must be shared. llvm-svn: 134795
Diffstat (limited to 'llvm/lib/MC/SubtargetFeature.cpp')
-rw-r--r--llvm/lib/MC/SubtargetFeature.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp
index 951e0aa..348cd4c 100644
--- a/llvm/lib/MC/SubtargetFeature.cpp
+++ b/llvm/lib/MC/SubtargetFeature.cpp
@@ -224,6 +224,38 @@ void ClearImpliedBits(uint64_t &Bits, const SubtargetFeatureKV *FeatureEntry,
}
}
+/// ToggleFeature - Toggle a feature and returns the newly updated feature
+/// bits.
+uint64_t
+SubtargetFeatures::ToggleFeature(uint64_t Bits, const StringRef Feature,
+ const SubtargetFeatureKV *FeatureTable,
+ size_t FeatureTableSize) {
+ // Find feature in table.
+ const SubtargetFeatureKV *FeatureEntry =
+ Find(StripFlag(Feature), FeatureTable, FeatureTableSize);
+ // If there is a match
+ if (FeatureEntry) {
+ if ((Bits & FeatureEntry->Value) == FeatureEntry->Value) {
+ Bits &= ~FeatureEntry->Value;
+
+ // For each feature that implies this, clear it.
+ ClearImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
+ } else {
+ Bits |= FeatureEntry->Value;
+
+ // For each feature that this implies, set it.
+ SetImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
+ }
+ } else {
+ errs() << "'" << Feature
+ << "' is not a recognized feature for this target"
+ << " (ignoring feature)\n";
+ }
+
+ return Bits;
+}
+
+
/// getFeatureBits - Get feature bits a CPU.
///
uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,