blob: 04171ecab2d4becb7bcc55234b917f26c4d546a7 [file] [log] [blame]
Daniel Dunbar0eb66992009-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 Dunbar335149e2009-07-18 23:22:46 +000010#include "SPU.h"
Daniel Dunbar0eb66992009-07-15 06:35:19 +000011#include "llvm/Module.h"
12#include "llvm/Target/TargetRegistry.h"
13using namespace llvm;
14
Daniel Dunbar0b0441e2009-07-18 23:03:22 +000015Target llvm::TheCellSPUTarget;
Daniel Dunbar0eb66992009-07-15 06:35:19 +000016
Daniel Dunbar0eb66992009-07-15 06:35:19 +000017static unsigned CellSPU_TripleMatchQuality(const std::string &TT) {
18 // We strongly match "spu-*" or "cellspu-*".
19 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu") ||
20 (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu") ||
21 (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-") ||
22 (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
23 return 20;
24
25 return 0;
26}
27
28static unsigned CellSPU_ModuleMatchQuality(const Module &M) {
29 // Check for a triple match.
30 if (unsigned Q = CellSPU_TripleMatchQuality(M.getTargetTriple()))
31 return Q;
32
33 // Otherwise if the target triple is non-empty, we don't match.
34 if (!M.getTargetTriple().empty()) return 0;
35
36 return 0;
37}
38
39extern "C" void LLVMInitializeCellSPUTargetInfo() {
40 TargetRegistry::RegisterTarget(TheCellSPUTarget, "cellspu",
41 "STI CBEA Cell SPU [experimental]",
42 &CellSPU_TripleMatchQuality,
Daniel Dunbar123157a2009-07-25 10:09:50 +000043 &CellSPU_ModuleMatchQuality);
Daniel Dunbar0eb66992009-07-15 06:35:19 +000044}