blob: 60f53e36167cb8f81f9706313daa4f66c549ad65 [file] [log] [blame]
Daniel Dunbarc984df82009-07-15 06:35:19 +00001//===-- AlphaTargetInfo.cpp - Alpha 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 Dunbar4cb1e132009-07-18 23:03:22 +000010#include "Alpha.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 +000015llvm::Target llvm::TheAlphaTarget;
Daniel Dunbarc984df82009-07-15 06:35:19 +000016
17static unsigned Alpha_JITMatchQuality() {
18#ifdef __alpha
19 return 10;
20#else
21 return 0;
22#endif
23}
24
25static unsigned Alpha_TripleMatchQuality(const std::string &TT) {
26 // We strongly match "alpha*".
27 if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
28 TT[3] == 'h' && TT[4] == 'a')
29 return 20;
30
31 return 0;
32}
33
34static unsigned Alpha_ModuleMatchQuality(const Module &M) {
35 // Check for a triple match.
36 if (unsigned Q = Alpha_TripleMatchQuality(M.getTargetTriple()))
37 return Q;
38
39 // Otherwise if the target triple is non-empty, we don't match.
40 if (!M.getTargetTriple().empty()) return 0;
41
42 if (M.getEndianness() == Module::LittleEndian &&
43 M.getPointerSize() == Module::Pointer64)
44 return 10; // Weak match
45 else if (M.getEndianness() != Module::AnyEndianness ||
46 M.getPointerSize() != Module::AnyPointerSize)
47 return 0; // Match for some other target
48
49 return Alpha_JITMatchQuality()/2;
50}
51
52extern "C" void LLVMInitializeAlphaTargetInfo() {
53 TargetRegistry::RegisterTarget(TheAlphaTarget, "alpha",
54 "Alpha [experimental]",
55 &Alpha_TripleMatchQuality,
56 &Alpha_ModuleMatchQuality,
57 &Alpha_JITMatchQuality);
58}