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