From 07e7168048b18cf3b82d39c9f38a06d8c19e893a Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 30 Dec 2022 18:02:26 +0100 Subject: [PATCH] [AArch64] Stringref'ize AArch64Subtarget constructor. NFCI --- llvm/lib/Target/AArch64/AArch64Subtarget.cpp | 5 ++--- llvm/lib/Target/AArch64/AArch64Subtarget.h | 5 ++--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp | 23 +++++++---------------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp index 5dfe74f..e1d9a56 100644 --- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp @@ -275,9 +275,8 @@ void AArch64Subtarget::initializeProperties() { } } -AArch64Subtarget::AArch64Subtarget(const Triple &TT, const std::string &CPU, - const std::string &TuneCPU, - const std::string &FS, +AArch64Subtarget::AArch64Subtarget(const Triple &TT, StringRef CPU, + StringRef TuneCPU, StringRef FS, const TargetMachine &TM, bool LittleEndian, unsigned MinSVEVectorSizeInBitsOverride, unsigned MaxSVEVectorSizeInBitsOverride, diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h b/llvm/lib/Target/AArch64/AArch64Subtarget.h index 5111000..f8b1b34 100644 --- a/llvm/lib/Target/AArch64/AArch64Subtarget.h +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h @@ -157,9 +157,8 @@ private: public: /// This constructor initializes the data members to match that /// of the specified triple. - AArch64Subtarget(const Triple &TT, const std::string &CPU, - const std::string &TuneCPU, const std::string &FS, - const TargetMachine &TM, bool LittleEndian, + AArch64Subtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, + StringRef FS, const TargetMachine &TM, bool LittleEndian, unsigned MinSVEVectorSizeInBitsOverride = 0, unsigned MaxSVEVectorSizeInBitsOverride = 0, bool StreamingSVEModeDisabled = true); diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp index 896b9f9..1dabd55 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -386,14 +386,9 @@ AArch64TargetMachine::getSubtargetImpl(const Function &F) const { Attribute TuneAttr = F.getFnAttribute("tune-cpu"); Attribute FSAttr = F.getFnAttribute("target-features"); - std::string CPU = - CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU; - std::string TuneCPU = - TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU; - std::string FS = - FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS; - - SmallString<512> Key; + StringRef CPU = CPUAttr.isValid() ? CPUAttr.getValueAsString() : TargetCPU; + StringRef TuneCPU = TuneAttr.isValid() ? TuneAttr.getValueAsString() : CPU; + StringRef FS = FSAttr.isValid() ? FSAttr.getValueAsString() : TargetFS; bool StreamingSVEModeDisabled = !F.hasFnAttribute("aarch64_pstate_sm_enabled") && @@ -429,14 +424,10 @@ AArch64TargetMachine::getSubtargetImpl(const Function &F) const { (std::max(MinSVEVectorSize, MaxSVEVectorSize) / 128) * 128; } - Key += "SVEMin"; - Key += std::to_string(MinSVEVectorSize); - Key += "SVEMax"; - Key += std::to_string(MaxSVEVectorSize); - Key += "StreamingSVEModeDisabled=" + std::to_string(StreamingSVEModeDisabled); - Key += CPU; - Key += TuneCPU; - Key += FS; + SmallString<512> Key; + raw_svector_ostream(Key) << "SVEMin" << MinSVEVectorSize << "SVEMax" + << MaxSVEVectorSize << "StreamingSVEModeDisabled=" + << StreamingSVEModeDisabled << CPU << TuneCPU << FS; auto &I = SubtargetMap[Key]; if (!I) { -- 2.7.4