[clang] [RISCV] Support predefined marcro __riscv_misaligned_{fast,avoid}. (PR #65756)

Yeting Kuo via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 17:49:58 PDT 2023


================
@@ -322,6 +327,8 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
   if (ISAInfo->hasExtension("zfh") || ISAInfo->hasExtension("zhinx"))
     HasLegalHalfType = true;
 
+  FastUnalignedAccess = llvm::is_contained(Features, "+unaligned-scalar-mem");
----------------
yetingk wrote:

I think clang will does feature  canonicalization before calling `handleTargetFeatures`.  It's the piece of code about that in `clang/lib/Basic/Targets.cpp`.
```
  for (const auto &F : Opts->FeatureMap)
    Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
  // Sort here, so we handle the features in a predictable order. (This matters
  // when we're dealing with features that overlap.)
  llvm::sort(Opts->Features);

  if (!Target->handleTargetFeatures(Opts->Features, Diags))
    return nullptr;
```

https://github.com/llvm/llvm-project/pull/65756


More information about the cfe-commits mailing list