Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 1 | //===-- Target.h ------------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// |
| 12 | /// Classes that handle the creation of target-specific objects. This is |
| 13 | /// similar to llvm::Target/TargetRegistry. |
| 14 | /// |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #ifndef LLVM_TOOLS_LLVM_EXEGESIS_TARGET_H |
| 18 | #define LLVM_TOOLS_LLVM_EXEGESIS_TARGET_H |
| 19 | |
| 20 | #include "llvm/ADT/Triple.h" |
Clement Courbet | 6fd00e3 | 2018-06-20 11:54:35 +0000 | [diff] [blame^] | 21 | #include "llvm/CodeGen/TargetPassConfig.h" |
| 22 | #include "llvm/IR/LegacyPassManager.h" |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 23 | |
| 24 | namespace exegesis { |
| 25 | |
| 26 | class ExegesisTarget { |
| 27 | public: |
Clement Courbet | 6fd00e3 | 2018-06-20 11:54:35 +0000 | [diff] [blame^] | 28 | // Targets can use this to add target-specific passes in assembleToStream(); |
| 29 | virtual void addTargetSpecificPasses(llvm::PassManagerBase &PM) const {} |
| 30 | |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 31 | // Returns the ExegesisTarget for the given triple or nullptr if the target |
| 32 | // does not exist. |
Clement Courbet | 6fd00e3 | 2018-06-20 11:54:35 +0000 | [diff] [blame^] | 33 | static const ExegesisTarget *lookup(llvm::Triple TT); |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 34 | // Registers a target. Not thread safe. |
| 35 | static void registerTarget(ExegesisTarget *T); |
| 36 | |
Roman Lebedev | 3de9664 | 2018-06-19 11:58:10 +0000 | [diff] [blame] | 37 | virtual ~ExegesisTarget(); |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 38 | |
| 39 | private: |
| 40 | virtual bool matchesArch(llvm::Triple::ArchType Arch) const = 0; |
| 41 | const ExegesisTarget* Next = nullptr; |
| 42 | }; |
| 43 | |
| 44 | } // namespace exegesis |
| 45 | |
| 46 | #endif // LLVM_TOOLS_LLVM_EXEGESIS_TARGET_H |