blob: d371bced71f61757eee01085dafa8e3759c282bd [file] [log] [blame]
Daniel Dunbarc984df82009-07-15 06:35:19 +00001//===-- X86TargetInfo.cpp - X86 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 "X86.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::TheX86_32Target;
Daniel Dunbarc984df82009-07-15 06:35:19 +000016
Daniel Dunbarc984df82009-07-15 06:35:19 +000017static unsigned X86_32_TripleMatchQuality(const std::string &TT) {
18 // We strongly match "i[3-9]86-*".
19 if (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' &&
20 TT[4] == '-' && TT[1] - '3' < 6)
21 return 20;
22
23 return 0;
24}
25
Daniel Dunbar4cb1e132009-07-18 23:03:22 +000026Target llvm::TheX86_64Target;
Daniel Dunbarc984df82009-07-15 06:35:19 +000027
Daniel Dunbarc984df82009-07-15 06:35:19 +000028static unsigned X86_64_TripleMatchQuality(const std::string &TT) {
29 // We strongly match "x86_64-*".
30 if (TT.size() >= 7 && TT[0] == 'x' && TT[1] == '8' && TT[2] == '6' &&
31 TT[3] == '_' && TT[4] == '6' && TT[5] == '4' && TT[6] == '-')
32 return 20;
33
34 return 0;
35}
36
Daniel Dunbarc984df82009-07-15 06:35:19 +000037extern "C" void LLVMInitializeX86TargetInfo() {
38 TargetRegistry::RegisterTarget(TheX86_32Target, "x86",
39 "32-bit X86: Pentium-Pro and above",
40 &X86_32_TripleMatchQuality,
Daniel Dunbard6fd3772009-07-25 10:09:50 +000041 /*HasJIT=*/true);
Daniel Dunbarc984df82009-07-15 06:35:19 +000042
43 TargetRegistry::RegisterTarget(TheX86_64Target, "x86-64",
44 "64-bit X86: EM64T and AMD64",
45 &X86_64_TripleMatchQuality,
Daniel Dunbard6fd3772009-07-25 10:09:50 +000046 /*HasJIT=*/true);
Daniel Dunbarc984df82009-07-15 06:35:19 +000047}