Add TargetInfo libraries for all targets.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 15 Jul 2009 06:35:19 +0000 (06:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 15 Jul 2009 06:35:19 +0000 (06:35 +0000)
 - Intended to match current TargetMachine implementations.

 - No facilities for linking these in yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75751 91177308-0d34-0410-b5e6-96231b3b80d8

56 files changed:
lib/Target/ARM/Makefile
lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp [new file with mode: 0644]
lib/Target/ARM/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/ARM/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/Alpha/Makefile
lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp [new file with mode: 0644]
lib/Target/Alpha/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/Alpha/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/CBackend/Makefile
lib/Target/CBackend/TargetInfo/CBackendTargetInfo.cpp [new file with mode: 0644]
lib/Target/CBackend/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/CBackend/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/CellSPU/Makefile
lib/Target/CellSPU/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp [new file with mode: 0644]
lib/Target/CellSPU/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/CppBackend/Makefile
lib/Target/CppBackend/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp [new file with mode: 0644]
lib/Target/CppBackend/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/IA64/Makefile
lib/Target/IA64/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp [new file with mode: 0644]
lib/Target/IA64/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/MSIL/Makefile
lib/Target/MSIL/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp [new file with mode: 0644]
lib/Target/MSIL/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/MSP430/Makefile
lib/Target/MSP430/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp [new file with mode: 0644]
lib/Target/MSP430/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/Mips/Makefile
lib/Target/Mips/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/Mips/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp [new file with mode: 0644]
lib/Target/PIC16/Makefile
lib/Target/PIC16/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/PIC16/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp [new file with mode: 0644]
lib/Target/PowerPC/Makefile
lib/Target/PowerPC/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/PowerPC/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp [new file with mode: 0644]
lib/Target/Sparc/Makefile
lib/Target/Sparc/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/Sparc/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp [new file with mode: 0644]
lib/Target/X86/Makefile
lib/Target/X86/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/X86/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/X86/TargetInfo/X86TargetInfo.cpp [new file with mode: 0644]
lib/Target/XCore/Makefile
lib/Target/XCore/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/XCore/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp [new file with mode: 0644]

index 9a3b9be5b3454707fed83aafcca7e5820292d0c8..d879521a2db8ac4c4dcff152e61b43e7430644cb 100644 (file)
@@ -18,6 +18,6 @@ BUILT_SOURCES = ARMGenRegisterInfo.h.inc ARMGenRegisterNames.inc \
                 ARMGenDAGISel.inc ARMGenSubtarget.inc \
                 ARMGenCodeEmitter.inc ARMGenCallingConv.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
diff --git a/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp b/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp
new file mode 100644 (file)
index 0000000..a08c915
--- /dev/null
@@ -0,0 +1,98 @@
+//===-- ARMTargetInfo.cpp - ARM Target Implementation ---------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheARMTarget;
+
+static unsigned ARM_JITMatchQuality() {
+#if defined(__arm__)
+  return 10;
+#endif
+  return 0;
+}
+
+static unsigned ARM_TripleMatchQuality(const std::string &TT) {
+  // Match arm-foo-bar, as well as things like armv5blah-*
+  if (TT.size() >= 4 &&
+      (TT.substr(0, 4) == "arm-" || TT.substr(0, 4) == "armv"))
+    return 20;
+
+  return 0;
+}
+
+static unsigned ARM_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = ARM_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  if (M.getEndianness()  == Module::LittleEndian &&
+      M.getPointerSize() == Module::Pointer32)
+    return 10;                                   // Weak match
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+
+  return ARM_JITMatchQuality()/2;
+}
+
+Target TheThumbTarget;
+
+static unsigned Thumb_JITMatchQuality() {
+#if defined(__thumb__)
+  return 10;
+#endif
+  return 0;
+}
+
+static unsigned Thumb_TripleMatchQuality(const std::string &TT) {
+  // Match thumb-foo-bar, as well as things like thumbv5blah-*
+  if (TT.size() >= 6 &&
+      (TT.substr(0, 6) == "thumb-" || TT.substr(0, 6) == "thumbv"))
+    return 20;
+
+  return 0;
+}
+
+static unsigned Thumb_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = Thumb_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  if (M.getEndianness()  == Module::LittleEndian &&
+      M.getPointerSize() == Module::Pointer32)
+    return 10;                                   // Weak match
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+
+  return Thumb_JITMatchQuality()/2;
+}
+
+extern "C" void LLVMInitializeARMTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheARMTarget, "arm",    
+                                  "ARM",
+                                  &ARM_TripleMatchQuality,
+                                  &ARM_ModuleMatchQuality,
+                                  &ARM_JITMatchQuality);
+
+  TargetRegistry::RegisterTarget(TheThumbTarget, "thumb",    
+                                  "Thumb",
+                                  &Thumb_TripleMatchQuality,
+                                  &Thumb_ModuleMatchQuality,
+                                  &Thumb_JITMatchQuality);
+}
diff --git a/lib/Target/ARM/TargetInfo/CMakeLists.txt b/lib/Target/ARM/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4eddb48
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMARMInfo
+  ARMTargetInfo.cpp
+  )
+
diff --git a/lib/Target/ARM/TargetInfo/Makefile b/lib/Target/ARM/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..6292ab1
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/ARM/TargetInfo/Makefile ------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMARMInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index d6c82c7d7435cd17eeadd9ae16717c43b4933022..55c7ec99d10a4341637e99005c892cb86d43e727 100644 (file)
@@ -17,6 +17,6 @@ BUILT_SOURCES = AlphaGenRegisterInfo.h.inc AlphaGenRegisterNames.inc \
                 AlphaGenAsmWriter.inc AlphaGenDAGISel.inc \
                 AlphaGenSubtarget.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
diff --git a/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp b/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp
new file mode 100644 (file)
index 0000000..df560b8
--- /dev/null
@@ -0,0 +1,57 @@
+//===-- AlphaTargetInfo.cpp - Alpha Target Implementation -----------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheAlphaTarget;
+
+static unsigned Alpha_JITMatchQuality() {
+#ifdef __alpha
+  return 10;
+#else
+  return 0;
+#endif
+}
+
+static unsigned Alpha_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "alpha*".
+  if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
+      TT[3] == 'h' && TT[4] == 'a')
+    return 20;
+
+  return 0;
+}
+
+static unsigned Alpha_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = Alpha_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  if (M.getEndianness()  == Module::LittleEndian &&
+      M.getPointerSize() == Module::Pointer64)
+    return 10;                                   // Weak match
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+
+  return Alpha_JITMatchQuality()/2;
+}
+
+extern "C" void LLVMInitializeAlphaTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheAlphaTarget, "alpha",
+                                  "Alpha [experimental]",
+                                  &Alpha_TripleMatchQuality,
+                                  &Alpha_ModuleMatchQuality,
+                                  &Alpha_JITMatchQuality);
+}
diff --git a/lib/Target/Alpha/TargetInfo/CMakeLists.txt b/lib/Target/Alpha/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4478ef8
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMAlphaInfo
+  AlphaTargetInfo.cpp
+  )
+
diff --git a/lib/Target/Alpha/TargetInfo/Makefile b/lib/Target/Alpha/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..7250358
--- /dev/null
@@ -0,0 +1,15 @@
+#===- lib/Target/Alpha/TargetInfo/Makefile -----------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMAlphaInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index 336de0c6f440b3cc1228d619b14aed8ccad242a7..3b5ef0f34692c6c5cc1e4712a0a04f0aeb0f3c99 100644 (file)
@@ -9,6 +9,9 @@
 
 LEVEL = ../../..
 LIBRARYNAME = LLVMCBackend
+
+DIRS = TargetInfo
+
 include $(LEVEL)/Makefile.common
 
 CompileCommonOpts += -Wno-format
diff --git a/lib/Target/CBackend/TargetInfo/CBackendTargetInfo.cpp b/lib/Target/CBackend/TargetInfo/CBackendTargetInfo.cpp
new file mode 100644 (file)
index 0000000..178c1dd
--- /dev/null
@@ -0,0 +1,38 @@
+//===-- CBackendTargetInfo.cpp - CBackend Target Implementation -----------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheCBackendTarget;
+
+static unsigned CBackend_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned CBackend_TripleMatchQuality(const std::string &TT) {
+  // This class always works, but must be requested explicitly on 
+  // llc command line.
+  return 0;
+}
+
+static unsigned CBackend_ModuleMatchQuality(const Module &M) {
+  // This class always works, but must be requested explicitly on 
+  // llc command line.
+  return 0;
+}
+
+extern "C" void LLVMInitializeCBackendTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheCBackendTarget, "c",
+                                  "C backend",
+                                  &CBackend_TripleMatchQuality,
+                                  &CBackend_ModuleMatchQuality,
+                                  &CBackend_JITMatchQuality);
+}
diff --git a/lib/Target/CBackend/TargetInfo/CMakeLists.txt b/lib/Target/CBackend/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5b35fa7
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMCBackendInfo
+  CBackendTargetInfo.cpp
+  )
+
diff --git a/lib/Target/CBackend/TargetInfo/Makefile b/lib/Target/CBackend/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..d4d5e15
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/CBackend/TargetInfo/Makefile -------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMCBackendInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index a460db3cfeda8b2703a32e470b74b11dc064ae63..8415168aea20076596f4f97c64ba1a542c9521a7 100644 (file)
@@ -17,6 +17,6 @@ BUILT_SOURCES = SPUGenInstrNames.inc SPUGenRegisterNames.inc \
                SPUGenInstrInfo.inc SPUGenDAGISel.inc \
                SPUGenSubtarget.inc SPUGenCallingConv.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
diff --git a/lib/Target/CellSPU/TargetInfo/CMakeLists.txt b/lib/Target/CellSPU/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b2cb2ff
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMCellSPUInfo
+  CellSPUTargetInfo.cpp
+  )
+
diff --git a/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp b/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp
new file mode 100644 (file)
index 0000000..c5ad7b8
--- /dev/null
@@ -0,0 +1,48 @@
+//===-- CellSPUTargetInfo.cpp - CellSPU Target Implementation -------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheCellSPUTarget;
+
+static unsigned CellSPU_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned CellSPU_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "spu-*" or "cellspu-*".
+  if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu") ||
+      (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu") ||
+      (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-") ||
+      (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
+    return 20;
+
+  return 0;
+}
+
+static unsigned CellSPU_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = CellSPU_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  return 0;
+}
+
+extern "C" void LLVMInitializeCellSPUTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheCellSPUTarget, "cellspu",
+                                  "STI CBEA Cell SPU [experimental]",
+                                  &CellSPU_TripleMatchQuality,
+                                  &CellSPU_ModuleMatchQuality,
+                                  &CellSPU_JITMatchQuality);
+}
diff --git a/lib/Target/CellSPU/TargetInfo/Makefile b/lib/Target/CellSPU/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..9cb6827
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/CellSPU/TargetInfo/Makefile --------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMCellSPUInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index ca7e1a82c8089aeadf24f76964a9aae16a0983d0..dc9cf48c8b1e80f352a6d8e5a1914e3c8803b9e5 100644 (file)
@@ -9,6 +9,9 @@
 
 LEVEL = ../../..
 LIBRARYNAME = LLVMCppBackend
+
+DIRS = TargetInfo
+
 include $(LEVEL)/Makefile.common
 
 CompileCommonOpts += -Wno-format
diff --git a/lib/Target/CppBackend/TargetInfo/CMakeLists.txt b/lib/Target/CppBackend/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..edaf5d3
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMCppBackendInfo
+  CppBackendTargetInfo.cpp
+  )
+
diff --git a/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp b/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp
new file mode 100644 (file)
index 0000000..3c29070
--- /dev/null
@@ -0,0 +1,36 @@
+//===-- CppBackendTargetInfo.cpp - CppBackend Target Implementation -------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheCppBackendTarget;
+
+static unsigned CppBackend_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned CppBackend_TripleMatchQuality(const std::string &TT) {
+  // This class always works, but shouldn't be the default in most cases.
+  return 1;
+}
+
+static unsigned CppBackend_ModuleMatchQuality(const Module &M) {
+  // This class always works, but shouldn't be the default in most cases.
+  return 1;
+}
+
+extern "C" void LLVMInitializeCppBackendTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheCppBackendTarget, "cpp",    
+                                  "C++ backend",
+                                  &CppBackend_TripleMatchQuality,
+                                  &CppBackend_ModuleMatchQuality,
+                                  &CppBackend_JITMatchQuality);
+}
diff --git a/lib/Target/CppBackend/TargetInfo/Makefile b/lib/Target/CppBackend/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..6e68283
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/CppBackend/TargetInfo/Makefile -----------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMCppBackendInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index d38325422c60ae10bf5a4ee7e0c9bbae01a9b87d..5c5bd635c0fb7709a4827409bb8f708d8cd94ec0 100644 (file)
@@ -14,7 +14,7 @@ BUILT_SOURCES = IA64GenRegisterInfo.h.inc IA64GenRegisterNames.inc \
                 IA64GenInstrInfo.inc IA64GenAsmWriter.inc \
                IA64GenDAGISel.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
 
diff --git a/lib/Target/IA64/TargetInfo/CMakeLists.txt b/lib/Target/IA64/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c5b7bc7
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMIA64Info
+  IA64TargetInfo.cpp
+  )
+
diff --git a/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp b/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp
new file mode 100644 (file)
index 0000000..00bdb20
--- /dev/null
@@ -0,0 +1,57 @@
+//===-- IA64TargetInfo.cpp - IA64 Target Implementation -------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheIA64Target;
+
+static unsigned IA64_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned IA64_TripleMatchQuality(const std::string &TT) {
+  // we match [iI][aA]*64
+  if (TT.size() >= 4) {
+    if ((TT[0]=='i' || TT[0]=='I') &&
+        (TT[1]=='a' || TT[1]=='A')) {
+      for(unsigned int i=2; i<(TT.size()-1); i++)
+        if(TT[i]=='6' && TT[i+1]=='4')
+          return 20; // strong match
+    }
+  }
+
+  return 0;
+}
+
+static unsigned IA64_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = IA64_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  // FIXME: This is bad, the target matching algorithm shouldn't depend on the
+  // host.
+#if defined(__ia64__) || defined(__IA64__)
+  return 5;
+#else
+  return 0;
+#endif
+}
+
+extern "C" void LLVMInitializeIA64TargetInfo() { 
+  TargetRegistry::RegisterTarget(TheIA64Target, "ia64",
+                                  "IA-64 (Itanium) [experimental]",
+                                  &IA64_TripleMatchQuality,
+                                  &IA64_ModuleMatchQuality,
+                                  &IA64_JITMatchQuality);
+}
diff --git a/lib/Target/IA64/TargetInfo/Makefile b/lib/Target/IA64/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..89f467b
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/IA64/TargetInfo/Makefile -----------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMIA64Info
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index 94265edf98c510d2de9ba72c9cd6461449455122..8057cc748039089a8cef93ef738c0f1a69eb12cd 100644 (file)
@@ -9,6 +9,9 @@
 
 LEVEL = ../../..
 LIBRARYNAME = LLVMMSIL
+
+DIRS = TargetInfo
+
 include $(LEVEL)/Makefile.common
 
 CompileCommonOpts := $(CompileCommonOpts) -Wno-format
diff --git a/lib/Target/MSIL/TargetInfo/CMakeLists.txt b/lib/Target/MSIL/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9f0c3a0
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMMSILInfo
+  MSILTargetInfo.cpp
+  )
+
diff --git a/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp b/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp
new file mode 100644 (file)
index 0000000..47e650b
--- /dev/null
@@ -0,0 +1,36 @@
+//===-- MSILTargetInfo.cpp - MSIL Target Implementation -------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheMSILTarget;
+
+static unsigned MSIL_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned MSIL_TripleMatchQuality(const std::string &TT) {
+  // This class always works, but shouldn't be the default in most cases.
+  return 1;
+}
+
+static unsigned MSIL_ModuleMatchQuality(const Module &M) {
+  // This class always works, but shouldn't be the default in most cases.
+  return 1;
+}
+
+extern "C" void LLVMInitializeMSILTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheMSILTarget, "msil",    
+                                  "MSIL backend",
+                                  &MSIL_TripleMatchQuality,
+                                  &MSIL_ModuleMatchQuality,
+                                  &MSIL_JITMatchQuality);
+}
diff --git a/lib/Target/MSIL/TargetInfo/Makefile b/lib/Target/MSIL/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..30b0950
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/MSIL/TargetInfo/Makefile -----------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMMSILInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index 45cb3aa45b85a6fb2fa24faa9d5737fe5ded1b3c..1ca57d7251f9881eb164902ece70c759cc6d273d 100644 (file)
@@ -17,5 +17,7 @@ BUILT_SOURCES = MSP430GenRegisterInfo.h.inc MSP430GenRegisterNames.inc \
                MSP430GenDAGISel.inc MSP430GenCallingConv.inc \
                MSP430GenSubtarget.inc
 
+DIRS = TargetInfo
+
 include $(LEVEL)/Makefile.common
 
diff --git a/lib/Target/MSP430/TargetInfo/CMakeLists.txt b/lib/Target/MSP430/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1bf9fe6
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMMSP430Info
+  MSP430TargetInfo.cpp
+  )
+
diff --git a/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp b/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp
new file mode 100644 (file)
index 0000000..0bdf882
--- /dev/null
@@ -0,0 +1,46 @@
+//===-- MSP430TargetInfo.cpp - MSP430 Target Implementation ---------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheMSP430Target;
+
+static unsigned MSP430_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned MSP430_TripleMatchQuality(const std::string &TT) {
+  // We strongly match msp430
+  if (TT.size() >= 6 && TT[0] == 'm' && TT[1] == 's' && TT[2] == 'p' &&
+      TT[3] == '4' &&  TT[4] == '3' && TT[5] == '0')
+    return 20;
+
+  return 0;
+}
+
+static unsigned MSP430_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = MSP430_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  return 0;
+}
+
+extern "C" void LLVMInitializeMSP430TargetInfo() { 
+  TargetRegistry::RegisterTarget(TheMSP430Target, "msp430",    
+                                  "MSP430 [experimental]",
+                                  &MSP430_TripleMatchQuality,
+                                  &MSP430_ModuleMatchQuality,
+                                  &MSP430_JITMatchQuality);
+}
diff --git a/lib/Target/MSP430/TargetInfo/Makefile b/lib/Target/MSP430/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..abb08f2
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/MSP430/TargetInfo/Makefile ---------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMMSP430Info
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index 48ab5f994704c94f9c41af510f0b363b28aae3c0..078034532d5047e028b84b796c08d1b9c7e8f0b7 100644 (file)
@@ -17,7 +17,7 @@ BUILT_SOURCES = MipsGenRegisterInfo.h.inc MipsGenRegisterNames.inc \
                 MipsGenDAGISel.inc MipsGenCallingConv.inc \
                 MipsGenSubtarget.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
 
diff --git a/lib/Target/Mips/TargetInfo/CMakeLists.txt b/lib/Target/Mips/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fda93cb
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMMipsInfo
+  MipsTargetInfo.cpp
+  )
+
diff --git a/lib/Target/Mips/TargetInfo/Makefile b/lib/Target/Mips/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..32f4e16
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/Mips/TargetInfo/Makefile -----------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMMipsInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
diff --git a/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp b/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp
new file mode 100644 (file)
index 0000000..1f4dc9e
--- /dev/null
@@ -0,0 +1,87 @@
+//===-- MipsTargetInfo.cpp - Mips Target Implementation -------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheMipsTarget;
+
+static unsigned Mips_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned Mips_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "mips*-*".
+  if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
+    return 20;
+  
+  if (TT.size() >= 13 && std::string(TT.begin(), 
+      TT.begin()+13) == "mipsallegrex-")
+    return 20;
+
+  return 0;
+}
+
+static unsigned Mips_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = Mips_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  return 0;
+}
+
+Target TheMipselTarget;
+
+static unsigned Mipsel_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned Mipsel_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "mips*el-*".
+  if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-")
+    return 20;
+
+  if (TT.size() >= 15 && std::string(TT.begin(), 
+      TT.begin()+15) == "mipsallegrexel-")
+    return 20;
+
+  if (TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "psp")
+    return 20;
+
+  return 0;
+}
+
+static unsigned Mipsel_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = Mipsel_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  return 0;
+}
+
+extern "C" void LLVMInitializeMipsTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheMipsTarget, "mips",
+                                  "Mips",
+                                  &Mips_TripleMatchQuality,
+                                  &Mips_ModuleMatchQuality,
+                                  &Mips_JITMatchQuality);
+
+  TargetRegistry::RegisterTarget(TheMipselTarget, "mipsel",
+                                  "Mipsel",
+                                  &Mipsel_TripleMatchQuality,
+                                  &Mipsel_ModuleMatchQuality,
+                                  &Mipsel_JITMatchQuality);
+}
index c429324cc2d13217571ae5b50a1a455f37a90a3f..4ce60a930b033578016443c82b5ae5899bce1bb4 100644 (file)
@@ -17,5 +17,7 @@ BUILT_SOURCES = PIC16GenRegisterInfo.h.inc PIC16GenRegisterNames.inc \
                PIC16GenDAGISel.inc PIC16GenCallingConv.inc \
                PIC16GenSubtarget.inc
 
+DIRS = TargetInfo
+
 include $(LEVEL)/Makefile.common
 
diff --git a/lib/Target/PIC16/TargetInfo/CMakeLists.txt b/lib/Target/PIC16/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7a8c4ca
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMPIC16Info
+  PIC16TargetInfo.cpp
+  )
+
diff --git a/lib/Target/PIC16/TargetInfo/Makefile b/lib/Target/PIC16/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..76609f6
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/PIC16/TargetInfo/Makefile ----------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMPIC16Info
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
diff --git a/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp b/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp
new file mode 100644 (file)
index 0000000..454f425
--- /dev/null
@@ -0,0 +1,54 @@
+//===-- PIC16TargetInfo.cpp - PIC16 Target Implementation -----------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target ThePIC16Target;
+
+static unsigned PIC16_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned PIC16_TripleMatchQuality(const std::string &TT) {
+  return 0;
+}
+
+static unsigned PIC16_ModuleMatchQuality(const Module &M) {
+  return 0;
+}
+
+Target TheCooperTarget;
+
+static unsigned Cooper_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned Cooper_TripleMatchQuality(const std::string &TT) {
+  return 0;
+}
+
+static unsigned Cooper_ModuleMatchQuality(const Module &M) {
+  return 0;
+}
+
+extern "C" void LLVMInitializePIC16TargetInfo() { 
+  TargetRegistry::RegisterTarget(ThePIC16Target, "pic16",
+                                  "PIC16 14-bit [experimental]",
+                                  &PIC16_TripleMatchQuality,
+                                  &PIC16_ModuleMatchQuality,
+                                  &PIC16_JITMatchQuality);
+
+  TargetRegistry::RegisterTarget(TheCooperTarget, "cooper",    
+                                  "PIC16 Cooper [experimental]",
+                                  &Cooper_TripleMatchQuality,
+                                  &Cooper_ModuleMatchQuality,
+                                  &Cooper_JITMatchQuality);
+}
index db688970e9e7169fc02b62ac92efde7789c743c2..4015d4aa190d41f8f721f550bc13f429affffc97 100644 (file)
@@ -17,6 +17,6 @@ BUILT_SOURCES = PPCGenInstrNames.inc PPCGenRegisterNames.inc \
                 PPCGenInstrInfo.inc PPCGenDAGISel.inc \
                 PPCGenSubtarget.inc PPCGenCallingConv.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
diff --git a/lib/Target/PowerPC/TargetInfo/CMakeLists.txt b/lib/Target/PowerPC/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6018c41
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMPowerPCInfo
+  PowerPCTargetInfo.cpp
+  )
+
diff --git a/lib/Target/PowerPC/TargetInfo/Makefile b/lib/Target/PowerPC/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..4253ce8
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/PowerPC/TargetInfo/Makefile ------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMPowerPCInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
diff --git a/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp b/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp
new file mode 100644 (file)
index 0000000..0502e37
--- /dev/null
@@ -0,0 +1,98 @@
+//===-- PowerPCTargetInfo.cpp - PowerPC Target Implementation -------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target ThePPC32Target;
+
+static unsigned PPC32_JITMatchQuality() {
+#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__)
+  if (sizeof(void*) == 4)
+    return 10;
+#endif
+  return 0;
+}
+
+static unsigned PPC32_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "powerpc-*".
+  if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
+    return 20;
+
+  return 0;
+}
+
+static unsigned PPC32_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = PPC32_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  if (M.getEndianness()  == Module::BigEndian &&
+      M.getPointerSize() == Module::Pointer64)
+    return 10;                                   // Weak match
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+  
+  return PPC32_JITMatchQuality()/2;
+}
+
+Target ThePPC64Target;
+
+static unsigned PPC64_JITMatchQuality() {
+#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__)
+  if (sizeof(void*) == 8)
+    return 10;
+#endif
+  return 0;
+}
+
+static unsigned PPC64_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "powerpc64-*".
+  if (TT.size() >= 10 && std::string(TT.begin(), TT.begin()+10) == "powerpc64-")
+    return 20;
+
+  return 0;
+}
+
+static unsigned PPC64_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = PPC64_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+  
+  if (M.getEndianness()  == Module::BigEndian &&
+      M.getPointerSize() == Module::Pointer64)
+    return 10;                                   // Weak match
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+  
+  return PPC64_JITMatchQuality()/2;
+}
+
+extern "C" void LLVMInitializePowerPCTargetInfo() { 
+  TargetRegistry::RegisterTarget(ThePPC32Target, "ppc32",
+                                  "PowerPC 32",
+                                  &PPC32_TripleMatchQuality,
+                                  &PPC32_ModuleMatchQuality,
+                                  &PPC32_JITMatchQuality);
+
+  TargetRegistry::RegisterTarget(ThePPC64Target, "ppc64",
+                                  "PowerPC 64",
+                                  &PPC64_TripleMatchQuality,
+                                  &PPC64_ModuleMatchQuality,
+                                  &PPC64_JITMatchQuality);
+}
index fdf6afaee0768e282962095ff947b93f1770d41e..6714b4dadb29e691815c371ebfec6405f3145e27 100644 (file)
@@ -16,7 +16,7 @@ BUILT_SOURCES = SparcGenRegisterInfo.h.inc SparcGenRegisterNames.inc \
                 SparcGenInstrInfo.inc SparcGenAsmWriter.inc \
                 SparcGenDAGISel.inc SparcGenSubtarget.inc SparcGenCallingConv.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
 
diff --git a/lib/Target/Sparc/TargetInfo/CMakeLists.txt b/lib/Target/Sparc/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..835afb5
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMSparcInfo
+  SparcTargetInfo.cpp
+  )
+
diff --git a/lib/Target/Sparc/TargetInfo/Makefile b/lib/Target/Sparc/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..641ed87
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/Sparc/TargetInfo/Makefile ----------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMSparcInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
diff --git a/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp b/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp
new file mode 100644 (file)
index 0000000..71c72d9
--- /dev/null
@@ -0,0 +1,61 @@
+//===-- SparcTargetInfo.cpp - Sparc Target Implementation -----------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheSparcTarget;
+
+static unsigned Sparc_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned Sparc_TripleMatchQuality(const std::string &TT) {
+  if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
+    return 20;
+
+  return 0;
+}
+
+static unsigned Sparc_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = Sparc_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise if the target triple is non-empty, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  // FIXME: This is bad, the target matching algorithm shouldn't depend on the
+  // host.
+  if (M.getEndianness()  == Module::BigEndian &&
+      M.getPointerSize() == Module::Pointer32)
+#ifdef __sparc__
+    return 20;   // BE/32 ==> Prefer sparc on sparc
+#else
+    return 5;    // BE/32 ==> Prefer ppc elsewhere
+#endif
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+
+#if defined(__sparc__)
+  return 10;
+#else
+  return 0;
+#endif
+}
+
+extern "C" void LLVMInitializeSparcTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheSparcTarget, "sparc",
+                                  "Sparc",
+                                  &Sparc_TripleMatchQuality,
+                                  &Sparc_ModuleMatchQuality,
+                                  &Sparc_JITMatchQuality);
+}
index 44f1c5d5a509a4e566d938fe6879e87fd84db41f..2596f1f436b18b0b7f579e7ff3c6ee8777c441de 100644 (file)
@@ -18,6 +18,6 @@ BUILT_SOURCES = X86GenRegisterInfo.h.inc X86GenRegisterNames.inc \
                 X86GenFastISel.inc \
                 X86GenCallingConv.inc X86GenSubtarget.inc
 
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
 
 include $(LEVEL)/Makefile.common
diff --git a/lib/Target/X86/TargetInfo/CMakeLists.txt b/lib/Target/X86/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..da454f1
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMX86Info
+  X86TargetInfo.cpp
+  )
+
diff --git a/lib/Target/X86/TargetInfo/Makefile b/lib/Target/X86/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..6677d4b
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/X86/TargetInfo/Makefile ------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMX86Info
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
diff --git a/lib/Target/X86/TargetInfo/X86TargetInfo.cpp b/lib/Target/X86/TargetInfo/X86TargetInfo.cpp
new file mode 100644 (file)
index 0000000..9d811ab
--- /dev/null
@@ -0,0 +1,98 @@
+//===-- X86TargetInfo.cpp - X86 Target Implementation ---------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheX86_32Target;
+
+static unsigned X86_32_JITMatchQuality() {
+#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
+  return 10;
+#endif
+  return 0;
+}
+
+static unsigned X86_32_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "i[3-9]86-*".
+  if (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' &&
+      TT[4] == '-' && TT[1] - '3' < 6)
+    return 20;
+
+  return 0;
+}
+
+static unsigned X86_32_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = X86_32_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // If the target triple is something non-X86, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  if (M.getEndianness()  == Module::LittleEndian &&
+      M.getPointerSize() == Module::Pointer32)
+    return 10;                                   // Weak match
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+
+  return X86_32_JITMatchQuality()/2;
+}
+
+Target TheX86_64Target;
+
+static unsigned X86_64_JITMatchQuality() {
+#if defined(__x86_64__) || defined(_M_AMD64)
+  return 10;
+#endif
+  return 0;
+}
+
+static unsigned X86_64_TripleMatchQuality(const std::string &TT) {
+  // We strongly match "x86_64-*".
+  if (TT.size() >= 7 && TT[0] == 'x' && TT[1] == '8' && TT[2] == '6' &&
+      TT[3] == '_' && TT[4] == '6' && TT[5] == '4' && TT[6] == '-')
+    return 20;
+  
+  return 0;
+}
+
+static unsigned X86_64_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = X86_64_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // If the target triple is something non-X86-64, we don't match.
+  if (!M.getTargetTriple().empty()) return 0;
+
+  if (M.getEndianness()  == Module::LittleEndian &&
+      M.getPointerSize() == Module::Pointer64)
+    return 10;                                   // Weak match
+  else if (M.getEndianness() != Module::AnyEndianness ||
+           M.getPointerSize() != Module::AnyPointerSize)
+    return 0;                                    // Match for some other target
+
+  return X86_64_JITMatchQuality()/2;
+}
+
+extern "C" void LLVMInitializeX86TargetInfo() { 
+  TargetRegistry::RegisterTarget(TheX86_32Target, "x86",    
+                                  "32-bit X86: Pentium-Pro and above",
+                                  &X86_32_TripleMatchQuality,
+                                  &X86_32_ModuleMatchQuality,
+                                  &X86_32_JITMatchQuality);
+
+  TargetRegistry::RegisterTarget(TheX86_64Target, "x86-64",    
+                                  "64-bit X86: EM64T and AMD64",
+                                  &X86_64_TripleMatchQuality,
+                                  &X86_64_ModuleMatchQuality,
+                                  &X86_64_JITMatchQuality);
+}
index 568df70ab63a93c3cd74e1fead5e16f6a5e236d3..9ca4560f0f1dcf374a2bed2e8866efb852b6e6c9 100644 (file)
@@ -17,5 +17,7 @@ BUILT_SOURCES = XCoreGenRegisterInfo.h.inc XCoreGenRegisterNames.inc \
                 XCoreGenDAGISel.inc XCoreGenCallingConv.inc \
                XCoreGenSubtarget.inc
 
+DIRS = TargetInfo
+
 include $(LEVEL)/Makefile.common
 
diff --git a/lib/Target/XCore/TargetInfo/CMakeLists.txt b/lib/Target/XCore/TargetInfo/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2772a51
--- /dev/null
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMXCoreInfo
+  XCoreTargetInfo.cpp
+  )
+
diff --git a/lib/Target/XCore/TargetInfo/Makefile b/lib/Target/XCore/TargetInfo/Makefile
new file mode 100644 (file)
index 0000000..07473d2
--- /dev/null
@@ -0,0 +1,15 @@
+##===- lib/Target/XCore/TargetInfo/Makefile ----------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMXCoreInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
diff --git a/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp b/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp
new file mode 100644 (file)
index 0000000..ce664e1
--- /dev/null
@@ -0,0 +1,42 @@
+//===-- XCoreTargetInfo.cpp - XCore Target Implementation -----------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheXCoreTarget;
+
+static unsigned XCore_JITMatchQuality() {
+  return 0;
+}
+
+static unsigned XCore_TripleMatchQuality(const std::string &TT) {
+  if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
+    return 20;
+
+  return 0;
+}
+
+static unsigned XCore_ModuleMatchQuality(const Module &M) {
+  // Check for a triple match.
+  if (unsigned Q = XCore_TripleMatchQuality(M.getTargetTriple()))
+    return Q;
+
+  // Otherwise we don't match.
+  return 0;
+}
+
+extern "C" void LLVMInitializeXCoreTargetInfo() { 
+  TargetRegistry::RegisterTarget(TheXCoreTarget, "xcore",
+                                  "XCore",
+                                  &XCore_TripleMatchQuality,
+                                  &XCore_ModuleMatchQuality,
+                                  &XCore_JITMatchQuality);
+}