diff options
| author | Eric Christopher <echristo@gmail.com> | 2014-10-06 06:45:36 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2014-10-06 06:45:36 +0000 |
| commit | 3faf2f1e02eff60a3a75cd5da8d113d38bf26b46 (patch) | |
| tree | 07131e9dc5225b502c74cfea586b2b74513d942e /llvm/lib/Target/AArch64 | |
| parent | 28a3fc6c3e0578b78b23dfddd7dca5415749b87c (diff) | |
| download | bcm5719-llvm-3faf2f1e02eff60a3a75cd5da8d113d38bf26b46.tar.gz bcm5719-llvm-3faf2f1e02eff60a3a75cd5da8d113d38bf26b46.zip | |
Add subtarget caches to aarch64, arm, ppc, and x86.
These will make it easier to test further changes to the
code generation and optimization pipelines as those are
moved to subtargets initialized with target feature and
target cpu.
llvm-svn: 219106
Diffstat (limited to 'llvm/lib/Target/AArch64')
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64TargetMachine.cpp | 29 | ||||
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64TargetMachine.h | 3 |
2 files changed, 31 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp index e83dd0dd335..3991b58be1f 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -14,6 +14,7 @@ #include "AArch64TargetMachine.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/RegAllocRegistry.h" +#include "llvm/IR/Function.h" #include "llvm/PassManager.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/TargetRegistry.h" @@ -95,7 +96,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, StringRef TT, CodeGenOpt::Level OL, bool LittleEndian) : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL), - Subtarget(TT, CPU, FS, *this, LittleEndian), + Subtarget(TT, CPU, FS, *this, LittleEndian), isLittle(LittleEndian), usingPBQP(false) { initAsmInfo(); @@ -105,6 +106,32 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, StringRef TT, } } +const AArch64Subtarget * +AArch64TargetMachine::getSubtargetImpl(const Function &F) const { + AttributeSet FnAttrs = F.getAttributes(); + Attribute CPUAttr = + FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-cpu"); + Attribute FSAttr = + FnAttrs.getAttribute(AttributeSet::FunctionIndex, "target-features"); + + std::string CPU = !CPUAttr.hasAttribute(Attribute::None) + ? CPUAttr.getValueAsString().str() + : TargetCPU; + std::string FS = !FSAttr.hasAttribute(Attribute::None) + ? FSAttr.getValueAsString().str() + : TargetFS; + + auto &I = SubtargetMap[CPU + FS]; + if (!I) { + // This needs to be done before we create a new subtarget since any + // creation will depend on the TM and the code generation flags on the + // function that reside in TargetOptions. + resetTargetOptions(F); + I = llvm::make_unique<AArch64Subtarget>(TargetTriple, CPU, FS, *this, isLittle); + } + return I.get(); +} + void AArch64leTargetMachine::anchor() { } AArch64leTargetMachine:: diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.h b/llvm/lib/Target/AArch64/AArch64TargetMachine.h index 42d7dc57328..7bf40ae165b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.h +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.h @@ -24,6 +24,7 @@ namespace llvm { class AArch64TargetMachine : public LLVMTargetMachine { protected: AArch64Subtarget Subtarget; + mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap; public: AArch64TargetMachine(const Target &T, StringRef TT, StringRef CPU, @@ -34,6 +35,7 @@ public: const AArch64Subtarget *getSubtargetImpl() const override { return &Subtarget; } + const AArch64Subtarget *getSubtargetImpl(const Function &F) const override; // Pass Pipeline Configuration TargetPassConfig *createPassConfig(PassManagerBase &PM) override; @@ -45,6 +47,7 @@ public: bool isPBQPUsed() const { return usingPBQP; } private: + bool isLittle; bool usingPBQP; }; |

