blob: bd0e4150382d175874ff760fdf821019f16dac91 [file] [log] [blame]
Daniel Dunbarc984df82009-07-15 06:35:19 +00001//===-- 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
Daniel Dunbaredcb5402009-07-18 23:22:46 +000010#include "SPU.h"
Daniel Dunbarc984df82009-07-15 06:35:19 +000011#include "llvm/Module.h"
12#include "llvm/Target/TargetRegistry.h"
13using namespace llvm;
14
Daniel Dunbar4cb1e132009-07-18 23:03:22 +000015Target llvm::TheCellSPUTarget;
Daniel Dunbarc984df82009-07-15 06:35:19 +000016
17static unsigned CellSPU_JITMatchQuality() {
18 return 0;
19}
20
21static 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-"))
27 return 20;
28
29 return 0;
30}
31
32static unsigned CellSPU_ModuleMatchQuality(const Module &M) {
33 // Check for a triple match.
34 if (unsigned Q = CellSPU_TripleMatchQuality(M.getTargetTriple()))
35 return Q;
36
37 // Otherwise if the target triple is non-empty, we don't match.
38 if (!M.getTargetTriple().empty()) return 0;
39
40 return 0;
41}
42
43extern "C" void LLVMInitializeCellSPUTargetInfo() {
44 TargetRegistry::RegisterTarget(TheCellSPUTarget, "cellspu",
45 "STI CBEA Cell SPU [experimental]",
46 &CellSPU_TripleMatchQuality,
47 &CellSPU_ModuleMatchQuality,
48 &CellSPU_JITMatchQuality);
49}