diff options
| author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-07-27 19:07:09 +0000 | 
|---|---|---|
| committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-07-27 19:07:09 +0000 | 
| commit | 8988c2a5249d147acea23a7883fab17331fcea57 (patch) | |
| tree | 2163b30535e7d8070a5176019170c9de576af67d /llvm/lib | |
| parent | 45cf67b8e9ad91d65a9f03acb669b0edf223d7f0 (diff) | |
| download | bcm5719-llvm-8988c2a5249d147acea23a7883fab17331fcea57.tar.gz bcm5719-llvm-8988c2a5249d147acea23a7883fab17331fcea57.zip  | |
ARM: correct handling of features in arch_extension
The subtarget information is the ultimate source of truth for the feature set
that is enabled at this point.  We would previously not propagate the feature
information to the subtarget.  While this worked for the most part (features
would be enabled/disabled as requested), if another operation that changed the
feature bits was encountered (such as a mode switch via a .arm or .thumb
directive), we would end up resetting the behaviour of the architectural
extensions.
Handling this properly requires a slightly more complicated handling.  We need
to check if the feature is now being toggled.  If so, only then do we toggle the
features.  In return, we no longer have to calculate the feature bits ourselves.
The test changes are mostly to the diagnosis, which is now more uniform (a nice
side effect!).  Add an additional test to ensure that we handle this case
properly.
Thanks to Nico Weber for alerting me to this issue!
llvm-svn: 214057
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 23 | 
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index f8f4484f0ed..b2c03510827 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -9420,22 +9420,23 @@ bool ARMAsmParser::parseDirectiveArchExtension(SMLoc L) {      if (Extension.Name != Name)        continue; -    unsigned FB = getAvailableFeatures(); -    if ((FB & Extension.ArchCheck) != Extension.ArchCheck) { +    if (!Extension.Features) +      report_fatal_error("unsupported architectural extension: " + Name); + +    if ((getAvailableFeatures() & Extension.ArchCheck) != Extension.ArchCheck) {        Error(ExtLoc, "architectural extension '" + Name + "' is not "              "allowed for the current base architecture");        return false;      } -    if (!Extension.Features) -      report_fatal_error("unsupported architectural extension: " + Name); - -    if (EnableFeature) -      FB |= ComputeAvailableFeatures(Extension.Features); -    else -      FB &= ~ComputeAvailableFeatures(Extension.Features); - -    setAvailableFeatures(FB); +    bool ToggleFeatures = EnableFeature +                              ? (~STI.getFeatureBits() & Extension.Features) +                              : ( STI.getFeatureBits() & Extension.Features); +    if (ToggleFeatures) { +      unsigned Features = +          ComputeAvailableFeatures(STI.ToggleFeature(Extension.Features)); +      setAvailableFeatures(Features); +    }      return false;    }  | 

