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 | |
Daniel Dunbar | 4cb1e13 | 2009-07-18 23:03:22 +0000 | [diff] [blame^] | 10 | #include "Alpha.h" |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 11 | #include "llvm/Module.h" |
| 12 | #include "llvm/Target/TargetRegistry.h" |
| 13 | using namespace llvm; |
| 14 | |
Daniel Dunbar | 4cb1e13 | 2009-07-18 23:03:22 +0000 | [diff] [blame^] | 15 | llvm::Target llvm::TheAlphaTarget; |
Daniel Dunbar | c984df8 | 2009-07-15 06:35:19 +0000 | [diff] [blame] | 16 | |
| 17 | static unsigned Alpha_JITMatchQuality() { |
| 18 | #ifdef __alpha |
| 19 | return 10; |
| 20 | #else |
| 21 | return 0; |
| 22 | #endif |
| 23 | } |
| 24 | |
| 25 | static 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 | |
| 34 | static 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 | |
| 52 | extern "C" void LLVMInitializeAlphaTargetInfo() { |
| 53 | TargetRegistry::RegisterTarget(TheAlphaTarget, "alpha", |
| 54 | "Alpha [experimental]", |
| 55 | &Alpha_TripleMatchQuality, |
| 56 | &Alpha_ModuleMatchQuality, |
| 57 | &Alpha_JITMatchQuality); |
| 58 | } |