Daniel Dunbar | 0eb6699 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 1 | //===-- CellSPUTargetInfo.cpp - CellSPU Target Implementation -------------===// |
| 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 | #include "llvm/Module.h" |
| 11 | #include "llvm/Target/TargetRegistry.h" |
| 12 | using namespace llvm; |
| 13 | |
Daniel Dunbar | 0b0441e | 2009-07-18 23:03:22 +0000 | [diff] [blame^] | 14 | Target llvm::TheCellSPUTarget; |
Daniel Dunbar | 0eb6699 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 15 | |
| 16 | static unsigned CellSPU_JITMatchQuality() { |
| 17 | return 0; |
| 18 | } |
| 19 | |
| 20 | static unsigned CellSPU_TripleMatchQuality(const std::string &TT) { |
| 21 | // We strongly match "spu-*" or "cellspu-*". |
| 22 | if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu") || |
| 23 | (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu") || |
| 24 | (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-") || |
| 25 | (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-")) |
| 26 | return 20; |
| 27 | |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | static unsigned CellSPU_ModuleMatchQuality(const Module &M) { |
| 32 | // Check for a triple match. |
| 33 | if (unsigned Q = CellSPU_TripleMatchQuality(M.getTargetTriple())) |
| 34 | return Q; |
| 35 | |
| 36 | // Otherwise if the target triple is non-empty, we don't match. |
| 37 | if (!M.getTargetTriple().empty()) return 0; |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | extern "C" void LLVMInitializeCellSPUTargetInfo() { |
| 43 | TargetRegistry::RegisterTarget(TheCellSPUTarget, "cellspu", |
| 44 | "STI CBEA Cell SPU [experimental]", |
| 45 | &CellSPU_TripleMatchQuality, |
| 46 | &CellSPU_ModuleMatchQuality, |
| 47 | &CellSPU_JITMatchQuality); |
| 48 | } |