This revision was automatically updated to reflect the committed changes. Closed by commit rG7f51a9e2730e: [RISCV] Fix RISCVTargetInfo::initFeatureMap, add non-ISA features back after… (authored by eopXD).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119541/new/ https://reviews.llvm.org/D119541 Files: clang/lib/Basic/Targets/RISCV.cpp clang/test/Driver/riscv-default-features.c Index: clang/test/Driver/riscv-default-features.c =================================================================== --- /dev/null +++ clang/test/Driver/riscv-default-features.c @@ -0,0 +1,9 @@ +// RUN: %clang -target riscv32-unknown-elf -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32 + +// RV32: "target-features"="+a,+c,+m,+relax,-save-restore" +// RV64: "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" + +// Dummy function +int foo(){ + return 3; +} Index: clang/lib/Basic/Targets/RISCV.cpp =================================================================== --- clang/lib/Basic/Targets/RISCV.cpp +++ clang/lib/Basic/Targets/RISCV.cpp @@ -232,8 +232,16 @@ return false; } - return TargetInfo::initFeatureMap(Features, Diags, CPU, - (*ParseResult)->toFeatureVector()); + // RISCVISAInfo makes implications for ISA features + std::vector<std::string> ImpliedFeatures = (*ParseResult)->toFeatureVector(); + // Add non-ISA features like `relax` and `save-restore` back + for (std::string Feature : FeaturesVec) { + if (std::find(begin(ImpliedFeatures), end(ImpliedFeatures), Feature) == + end(ImpliedFeatures)) + ImpliedFeatures.push_back(Feature); + } + + return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures); } /// Return true if has this feature, need to sync with handleTargetFeatures.
Index: clang/test/Driver/riscv-default-features.c =================================================================== --- /dev/null +++ clang/test/Driver/riscv-default-features.c @@ -0,0 +1,9 @@ +// RUN: %clang -target riscv32-unknown-elf -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32 + +// RV32: "target-features"="+a,+c,+m,+relax,-save-restore" +// RV64: "target-features"="+64bit,+a,+c,+m,+relax,-save-restore" + +// Dummy function +int foo(){ + return 3; +} Index: clang/lib/Basic/Targets/RISCV.cpp =================================================================== --- clang/lib/Basic/Targets/RISCV.cpp +++ clang/lib/Basic/Targets/RISCV.cpp @@ -232,8 +232,16 @@ return false; } - return TargetInfo::initFeatureMap(Features, Diags, CPU, - (*ParseResult)->toFeatureVector()); + // RISCVISAInfo makes implications for ISA features + std::vector<std::string> ImpliedFeatures = (*ParseResult)->toFeatureVector(); + // Add non-ISA features like `relax` and `save-restore` back + for (std::string Feature : FeaturesVec) { + if (std::find(begin(ImpliedFeatures), end(ImpliedFeatures), Feature) == + end(ImpliedFeatures)) + ImpliedFeatures.push_back(Feature); + } + + return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures); } /// Return true if has this feature, need to sync with handleTargetFeatures.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits