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 | a51efc2 | 2018-06-25 13:12:02 +0000 | [diff] [blame^] | 23 | #include "llvm/MC/MCInst.h" |
| 24 | #include "llvm/MC/MCRegisterInfo.h" |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 25 | |
| 26 | namespace exegesis { |
| 27 | |
| 28 | class ExegesisTarget { |
| 29 | public: |
Clement Courbet | 6fd00e3 | 2018-06-20 11:54:35 +0000 | [diff] [blame] | 30 | // Targets can use this to add target-specific passes in assembleToStream(); |
| 31 | virtual void addTargetSpecificPasses(llvm::PassManagerBase &PM) const {} |
| 32 | |
Clement Courbet | a51efc2 | 2018-06-25 13:12:02 +0000 | [diff] [blame^] | 33 | // Generates code to move a constant into a the given register. |
| 34 | virtual std::vector<llvm::MCInst> setRegToConstant(unsigned Reg) const { |
| 35 | return {}; |
| 36 | } |
| 37 | |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 38 | // Returns the ExegesisTarget for the given triple or nullptr if the target |
| 39 | // does not exist. |
Clement Courbet | 6fd00e3 | 2018-06-20 11:54:35 +0000 | [diff] [blame] | 40 | static const ExegesisTarget *lookup(llvm::Triple TT); |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 41 | // Registers a target. Not thread safe. |
| 42 | static void registerTarget(ExegesisTarget *T); |
| 43 | |
Roman Lebedev | 3de9664 | 2018-06-19 11:58:10 +0000 | [diff] [blame] | 44 | virtual ~ExegesisTarget(); |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 45 | |
| 46 | private: |
| 47 | virtual bool matchesArch(llvm::Triple::ArchType Arch) const = 0; |
Clement Courbet | cff2caa | 2018-06-25 11:22:23 +0000 | [diff] [blame] | 48 | const ExegesisTarget *Next = nullptr; |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
Clement Courbet | cff2caa | 2018-06-25 11:22:23 +0000 | [diff] [blame] | 51 | } // namespace exegesis |
Clement Courbet | 44b4c54 | 2018-06-19 11:28:59 +0000 | [diff] [blame] | 52 | |
| 53 | #endif // LLVM_TOOLS_LLVM_EXEGESIS_TARGET_H |