1 //===-- CellSPUTargetInfo.cpp - CellSPU Target Implementation -------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "llvm/Module.h"
12 #include "llvm/Target/TargetRegistry.h"
15 Target llvm::TheCellSPUTarget;
17 static unsigned CellSPU_JITMatchQuality() {
21 static unsigned CellSPU_TripleMatchQuality(const std::string &TT) {
22 // We strongly match "spu-*" or "cellspu-*".
23 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu") ||
24 (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu") ||
25 (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-") ||
26 (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
32 static unsigned CellSPU_ModuleMatchQuality(const Module &M) {
33 // Check for a triple match.
34 if (unsigned Q = CellSPU_TripleMatchQuality(M.getTargetTriple()))
37 // Otherwise if the target triple is non-empty, we don't match.
38 if (!M.getTargetTriple().empty()) return 0;
43 extern "C" void LLVMInitializeCellSPUTargetInfo() {
44 TargetRegistry::RegisterTarget(TheCellSPUTarget, "cellspu",
45 "STI CBEA Cell SPU [experimental]",
46 &CellSPU_TripleMatchQuality,
47 &CellSPU_ModuleMatchQuality,
48 &CellSPU_JITMatchQuality);