From 56e2947a33c5fcb98e7775aa509e66c4ace9959a Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 15 Jul 2009 06:35:19 +0000 Subject: [PATCH] Add TargetInfo libraries for all targets. - Intended to match current TargetMachine implementations. - No facilities for linking these in yet. llvm-svn: 75751 --- llvm/lib/Target/ARM/Makefile | 2 +- .../Target/ARM/TargetInfo/ARMTargetInfo.cpp | 98 +++++++++++++++++++ llvm/lib/Target/ARM/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/ARM/TargetInfo/Makefile | 15 +++ llvm/lib/Target/Alpha/Makefile | 2 +- .../Alpha/TargetInfo/AlphaTargetInfo.cpp | 57 +++++++++++ .../Target/Alpha/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/Alpha/TargetInfo/Makefile | 15 +++ llvm/lib/Target/CBackend/Makefile | 3 + .../TargetInfo/CBackendTargetInfo.cpp | 38 +++++++ .../Target/CBackend/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/CBackend/TargetInfo/Makefile | 15 +++ llvm/lib/Target/CellSPU/Makefile | 2 +- .../Target/CellSPU/TargetInfo/CMakeLists.txt | 6 ++ .../CellSPU/TargetInfo/CellSPUTargetInfo.cpp | 48 +++++++++ llvm/lib/Target/CellSPU/TargetInfo/Makefile | 15 +++ llvm/lib/Target/CppBackend/Makefile | 3 + .../CppBackend/TargetInfo/CMakeLists.txt | 6 ++ .../TargetInfo/CppBackendTargetInfo.cpp | 36 +++++++ .../lib/Target/CppBackend/TargetInfo/Makefile | 15 +++ llvm/lib/Target/IA64/Makefile | 2 +- .../lib/Target/IA64/TargetInfo/CMakeLists.txt | 6 ++ .../Target/IA64/TargetInfo/IA64TargetInfo.cpp | 57 +++++++++++ llvm/lib/Target/IA64/TargetInfo/Makefile | 15 +++ llvm/lib/Target/MSIL/Makefile | 3 + .../lib/Target/MSIL/TargetInfo/CMakeLists.txt | 6 ++ .../Target/MSIL/TargetInfo/MSILTargetInfo.cpp | 36 +++++++ llvm/lib/Target/MSIL/TargetInfo/Makefile | 15 +++ llvm/lib/Target/MSP430/Makefile | 2 + .../Target/MSP430/TargetInfo/CMakeLists.txt | 6 ++ .../MSP430/TargetInfo/MSP430TargetInfo.cpp | 46 +++++++++ llvm/lib/Target/MSP430/TargetInfo/Makefile | 15 +++ llvm/lib/Target/Mips/Makefile | 2 +- .../lib/Target/Mips/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/Mips/TargetInfo/Makefile | 15 +++ .../Target/Mips/TargetInfo/MipsTargetInfo.cpp | 87 ++++++++++++++++ llvm/lib/Target/PIC16/Makefile | 2 + .../Target/PIC16/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/PIC16/TargetInfo/Makefile | 15 +++ .../PIC16/TargetInfo/PIC16TargetInfo.cpp | 54 ++++++++++ llvm/lib/Target/PowerPC/Makefile | 2 +- .../Target/PowerPC/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/PowerPC/TargetInfo/Makefile | 15 +++ .../PowerPC/TargetInfo/PowerPCTargetInfo.cpp | 98 +++++++++++++++++++ llvm/lib/Target/Sparc/Makefile | 2 +- .../Target/Sparc/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/Sparc/TargetInfo/Makefile | 15 +++ .../Sparc/TargetInfo/SparcTargetInfo.cpp | 61 ++++++++++++ llvm/lib/Target/X86/Makefile | 2 +- llvm/lib/Target/X86/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/X86/TargetInfo/Makefile | 15 +++ .../Target/X86/TargetInfo/X86TargetInfo.cpp | 98 +++++++++++++++++++ llvm/lib/Target/XCore/Makefile | 2 + .../Target/XCore/TargetInfo/CMakeLists.txt | 6 ++ llvm/lib/Target/XCore/TargetInfo/Makefile | 15 +++ .../XCore/TargetInfo/XCoreTargetInfo.cpp | 42 ++++++++ 56 files changed, 1173 insertions(+), 8 deletions(-) create mode 100644 llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp create mode 100644 llvm/lib/Target/ARM/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/ARM/TargetInfo/Makefile create mode 100644 llvm/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp create mode 100644 llvm/lib/Target/Alpha/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/Alpha/TargetInfo/Makefile create mode 100644 llvm/lib/Target/CBackend/TargetInfo/CBackendTargetInfo.cpp create mode 100644 llvm/lib/Target/CBackend/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/CBackend/TargetInfo/Makefile create mode 100644 llvm/lib/Target/CellSPU/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp create mode 100644 llvm/lib/Target/CellSPU/TargetInfo/Makefile create mode 100644 llvm/lib/Target/CppBackend/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp create mode 100644 llvm/lib/Target/CppBackend/TargetInfo/Makefile create mode 100644 llvm/lib/Target/IA64/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp create mode 100644 llvm/lib/Target/IA64/TargetInfo/Makefile create mode 100644 llvm/lib/Target/MSIL/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp create mode 100644 llvm/lib/Target/MSIL/TargetInfo/Makefile create mode 100644 llvm/lib/Target/MSP430/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp create mode 100644 llvm/lib/Target/MSP430/TargetInfo/Makefile create mode 100644 llvm/lib/Target/Mips/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/Mips/TargetInfo/Makefile create mode 100644 llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp create mode 100644 llvm/lib/Target/PIC16/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/PIC16/TargetInfo/Makefile create mode 100644 llvm/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp create mode 100644 llvm/lib/Target/PowerPC/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/PowerPC/TargetInfo/Makefile create mode 100644 llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp create mode 100644 llvm/lib/Target/Sparc/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/Sparc/TargetInfo/Makefile create mode 100644 llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp create mode 100644 llvm/lib/Target/X86/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/X86/TargetInfo/Makefile create mode 100644 llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp create mode 100644 llvm/lib/Target/XCore/TargetInfo/CMakeLists.txt create mode 100644 llvm/lib/Target/XCore/TargetInfo/Makefile create mode 100644 llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp diff --git a/llvm/lib/Target/ARM/Makefile b/llvm/lib/Target/ARM/Makefile index 9a3b9be5b345..d879521a2db8 100644 --- a/llvm/lib/Target/ARM/Makefile +++ b/llvm/lib/Target/ARM/Makefile @@ -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/llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp b/llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp new file mode 100644 index 000000000000..a08c915bc6af --- /dev/null +++ b/llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp @@ -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/llvm/lib/Target/ARM/TargetInfo/CMakeLists.txt b/llvm/lib/Target/ARM/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..4eddb48a7d60 --- /dev/null +++ b/llvm/lib/Target/ARM/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMARMInfo + ARMTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/ARM/TargetInfo/Makefile b/llvm/lib/Target/ARM/TargetInfo/Makefile new file mode 100644 index 000000000000..6292ab14b346 --- /dev/null +++ b/llvm/lib/Target/ARM/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/Alpha/Makefile b/llvm/lib/Target/Alpha/Makefile index d6c82c7d7435..55c7ec99d10a 100644 --- a/llvm/lib/Target/Alpha/Makefile +++ b/llvm/lib/Target/Alpha/Makefile @@ -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/llvm/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp b/llvm/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp new file mode 100644 index 000000000000..df560b8c875c --- /dev/null +++ b/llvm/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp @@ -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/llvm/lib/Target/Alpha/TargetInfo/CMakeLists.txt b/llvm/lib/Target/Alpha/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..4478ef8f8164 --- /dev/null +++ b/llvm/lib/Target/Alpha/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMAlphaInfo + AlphaTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/Alpha/TargetInfo/Makefile b/llvm/lib/Target/Alpha/TargetInfo/Makefile new file mode 100644 index 000000000000..7250358e462e --- /dev/null +++ b/llvm/lib/Target/Alpha/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/CBackend/Makefile b/llvm/lib/Target/CBackend/Makefile index 336de0c6f440..3b5ef0f34692 100644 --- a/llvm/lib/Target/CBackend/Makefile +++ b/llvm/lib/Target/CBackend/Makefile @@ -9,6 +9,9 @@ LEVEL = ../../.. LIBRARYNAME = LLVMCBackend + +DIRS = TargetInfo + include $(LEVEL)/Makefile.common CompileCommonOpts += -Wno-format diff --git a/llvm/lib/Target/CBackend/TargetInfo/CBackendTargetInfo.cpp b/llvm/lib/Target/CBackend/TargetInfo/CBackendTargetInfo.cpp new file mode 100644 index 000000000000..178c1dd8b4c6 --- /dev/null +++ b/llvm/lib/Target/CBackend/TargetInfo/CBackendTargetInfo.cpp @@ -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/llvm/lib/Target/CBackend/TargetInfo/CMakeLists.txt b/llvm/lib/Target/CBackend/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..5b35fa7c065b --- /dev/null +++ b/llvm/lib/Target/CBackend/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMCBackendInfo + CBackendTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/CBackend/TargetInfo/Makefile b/llvm/lib/Target/CBackend/TargetInfo/Makefile new file mode 100644 index 000000000000..d4d5e15b40bb --- /dev/null +++ b/llvm/lib/Target/CBackend/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/CellSPU/Makefile b/llvm/lib/Target/CellSPU/Makefile index a460db3cfeda..8415168aea20 100644 --- a/llvm/lib/Target/CellSPU/Makefile +++ b/llvm/lib/Target/CellSPU/Makefile @@ -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/llvm/lib/Target/CellSPU/TargetInfo/CMakeLists.txt b/llvm/lib/Target/CellSPU/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..b2cb2ffa4c5f --- /dev/null +++ b/llvm/lib/Target/CellSPU/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMCellSPUInfo + CellSPUTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp b/llvm/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp new file mode 100644 index 000000000000..c5ad7b8fb46f --- /dev/null +++ b/llvm/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp @@ -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/llvm/lib/Target/CellSPU/TargetInfo/Makefile b/llvm/lib/Target/CellSPU/TargetInfo/Makefile new file mode 100644 index 000000000000..9cb6827b4323 --- /dev/null +++ b/llvm/lib/Target/CellSPU/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/CppBackend/Makefile b/llvm/lib/Target/CppBackend/Makefile index ca7e1a82c808..dc9cf48c8b1e 100644 --- a/llvm/lib/Target/CppBackend/Makefile +++ b/llvm/lib/Target/CppBackend/Makefile @@ -9,6 +9,9 @@ LEVEL = ../../.. LIBRARYNAME = LLVMCppBackend + +DIRS = TargetInfo + include $(LEVEL)/Makefile.common CompileCommonOpts += -Wno-format diff --git a/llvm/lib/Target/CppBackend/TargetInfo/CMakeLists.txt b/llvm/lib/Target/CppBackend/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..edaf5d3cb188 --- /dev/null +++ b/llvm/lib/Target/CppBackend/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMCppBackendInfo + CppBackendTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp b/llvm/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp new file mode 100644 index 000000000000..3c29070804a7 --- /dev/null +++ b/llvm/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp @@ -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/llvm/lib/Target/CppBackend/TargetInfo/Makefile b/llvm/lib/Target/CppBackend/TargetInfo/Makefile new file mode 100644 index 000000000000..6e682838daec --- /dev/null +++ b/llvm/lib/Target/CppBackend/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/IA64/Makefile b/llvm/lib/Target/IA64/Makefile index d38325422c60..5c5bd635c0fb 100644 --- a/llvm/lib/Target/IA64/Makefile +++ b/llvm/lib/Target/IA64/Makefile @@ -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/llvm/lib/Target/IA64/TargetInfo/CMakeLists.txt b/llvm/lib/Target/IA64/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..c5b7bc72e0b7 --- /dev/null +++ b/llvm/lib/Target/IA64/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMIA64Info + IA64TargetInfo.cpp + ) + diff --git a/llvm/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp b/llvm/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp new file mode 100644 index 000000000000..00bdb203b58c --- /dev/null +++ b/llvm/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp @@ -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/llvm/lib/Target/IA64/TargetInfo/Makefile b/llvm/lib/Target/IA64/TargetInfo/Makefile new file mode 100644 index 000000000000..89f467b30d58 --- /dev/null +++ b/llvm/lib/Target/IA64/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/MSIL/Makefile b/llvm/lib/Target/MSIL/Makefile index 94265edf98c5..8057cc748039 100644 --- a/llvm/lib/Target/MSIL/Makefile +++ b/llvm/lib/Target/MSIL/Makefile @@ -9,6 +9,9 @@ LEVEL = ../../.. LIBRARYNAME = LLVMMSIL + +DIRS = TargetInfo + include $(LEVEL)/Makefile.common CompileCommonOpts := $(CompileCommonOpts) -Wno-format diff --git a/llvm/lib/Target/MSIL/TargetInfo/CMakeLists.txt b/llvm/lib/Target/MSIL/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..9f0c3a09341a --- /dev/null +++ b/llvm/lib/Target/MSIL/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMMSILInfo + MSILTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp b/llvm/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp new file mode 100644 index 000000000000..47e650be82ac --- /dev/null +++ b/llvm/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp @@ -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/llvm/lib/Target/MSIL/TargetInfo/Makefile b/llvm/lib/Target/MSIL/TargetInfo/Makefile new file mode 100644 index 000000000000..30b0950db0f7 --- /dev/null +++ b/llvm/lib/Target/MSIL/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/MSP430/Makefile b/llvm/lib/Target/MSP430/Makefile index 45cb3aa45b85..1ca57d7251f9 100644 --- a/llvm/lib/Target/MSP430/Makefile +++ b/llvm/lib/Target/MSP430/Makefile @@ -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/llvm/lib/Target/MSP430/TargetInfo/CMakeLists.txt b/llvm/lib/Target/MSP430/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..1bf9fe6cdd6c --- /dev/null +++ b/llvm/lib/Target/MSP430/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMMSP430Info + MSP430TargetInfo.cpp + ) + diff --git a/llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp b/llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp new file mode 100644 index 000000000000..0bdf8823be89 --- /dev/null +++ b/llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp @@ -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/llvm/lib/Target/MSP430/TargetInfo/Makefile b/llvm/lib/Target/MSP430/TargetInfo/Makefile new file mode 100644 index 000000000000..abb08f2548ee --- /dev/null +++ b/llvm/lib/Target/MSP430/TargetInfo/Makefile @@ -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 diff --git a/llvm/lib/Target/Mips/Makefile b/llvm/lib/Target/Mips/Makefile index 48ab5f994704..078034532d50 100644 --- a/llvm/lib/Target/Mips/Makefile +++ b/llvm/lib/Target/Mips/Makefile @@ -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/llvm/lib/Target/Mips/TargetInfo/CMakeLists.txt b/llvm/lib/Target/Mips/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..fda93cb80255 --- /dev/null +++ b/llvm/lib/Target/Mips/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMMipsInfo + MipsTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/Mips/TargetInfo/Makefile b/llvm/lib/Target/Mips/TargetInfo/Makefile new file mode 100644 index 000000000000..32f4e1695b1d --- /dev/null +++ b/llvm/lib/Target/Mips/TargetInfo/Makefile @@ -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/llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp b/llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp new file mode 100644 index 000000000000..1f4dc9e12239 --- /dev/null +++ b/llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp @@ -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); +} diff --git a/llvm/lib/Target/PIC16/Makefile b/llvm/lib/Target/PIC16/Makefile index c429324cc2d1..4ce60a930b03 100644 --- a/llvm/lib/Target/PIC16/Makefile +++ b/llvm/lib/Target/PIC16/Makefile @@ -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/llvm/lib/Target/PIC16/TargetInfo/CMakeLists.txt b/llvm/lib/Target/PIC16/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..7a8c4ca53a75 --- /dev/null +++ b/llvm/lib/Target/PIC16/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMPIC16Info + PIC16TargetInfo.cpp + ) + diff --git a/llvm/lib/Target/PIC16/TargetInfo/Makefile b/llvm/lib/Target/PIC16/TargetInfo/Makefile new file mode 100644 index 000000000000..76609f66d652 --- /dev/null +++ b/llvm/lib/Target/PIC16/TargetInfo/Makefile @@ -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/llvm/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp b/llvm/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp new file mode 100644 index 000000000000..454f4259ff3f --- /dev/null +++ b/llvm/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp @@ -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); +} diff --git a/llvm/lib/Target/PowerPC/Makefile b/llvm/lib/Target/PowerPC/Makefile index db688970e9e7..4015d4aa190d 100644 --- a/llvm/lib/Target/PowerPC/Makefile +++ b/llvm/lib/Target/PowerPC/Makefile @@ -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/llvm/lib/Target/PowerPC/TargetInfo/CMakeLists.txt b/llvm/lib/Target/PowerPC/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..6018c4175920 --- /dev/null +++ b/llvm/lib/Target/PowerPC/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMPowerPCInfo + PowerPCTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/PowerPC/TargetInfo/Makefile b/llvm/lib/Target/PowerPC/TargetInfo/Makefile new file mode 100644 index 000000000000..4253ce8b8966 --- /dev/null +++ b/llvm/lib/Target/PowerPC/TargetInfo/Makefile @@ -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/llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp b/llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp new file mode 100644 index 000000000000..0502e37f3fec --- /dev/null +++ b/llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp @@ -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); +} diff --git a/llvm/lib/Target/Sparc/Makefile b/llvm/lib/Target/Sparc/Makefile index fdf6afaee076..6714b4dadb29 100644 --- a/llvm/lib/Target/Sparc/Makefile +++ b/llvm/lib/Target/Sparc/Makefile @@ -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/llvm/lib/Target/Sparc/TargetInfo/CMakeLists.txt b/llvm/lib/Target/Sparc/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..835afb53de12 --- /dev/null +++ b/llvm/lib/Target/Sparc/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMSparcInfo + SparcTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/Sparc/TargetInfo/Makefile b/llvm/lib/Target/Sparc/TargetInfo/Makefile new file mode 100644 index 000000000000..641ed87160c7 --- /dev/null +++ b/llvm/lib/Target/Sparc/TargetInfo/Makefile @@ -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/llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp b/llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp new file mode 100644 index 000000000000..71c72d94821b --- /dev/null +++ b/llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp @@ -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); +} diff --git a/llvm/lib/Target/X86/Makefile b/llvm/lib/Target/X86/Makefile index 44f1c5d5a509..2596f1f436b1 100644 --- a/llvm/lib/Target/X86/Makefile +++ b/llvm/lib/Target/X86/Makefile @@ -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/llvm/lib/Target/X86/TargetInfo/CMakeLists.txt b/llvm/lib/Target/X86/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..da454f118cfc --- /dev/null +++ b/llvm/lib/Target/X86/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMX86Info + X86TargetInfo.cpp + ) + diff --git a/llvm/lib/Target/X86/TargetInfo/Makefile b/llvm/lib/Target/X86/TargetInfo/Makefile new file mode 100644 index 000000000000..6677d4bdfde1 --- /dev/null +++ b/llvm/lib/Target/X86/TargetInfo/Makefile @@ -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/llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp b/llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp new file mode 100644 index 000000000000..9d811ab8434a --- /dev/null +++ b/llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp @@ -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); +} diff --git a/llvm/lib/Target/XCore/Makefile b/llvm/lib/Target/XCore/Makefile index 568df70ab63a..9ca4560f0f1d 100644 --- a/llvm/lib/Target/XCore/Makefile +++ b/llvm/lib/Target/XCore/Makefile @@ -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/llvm/lib/Target/XCore/TargetInfo/CMakeLists.txt b/llvm/lib/Target/XCore/TargetInfo/CMakeLists.txt new file mode 100644 index 000000000000..2772a51f7bb2 --- /dev/null +++ b/llvm/lib/Target/XCore/TargetInfo/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) + +add_llvm_library(LLVMXCoreInfo + XCoreTargetInfo.cpp + ) + diff --git a/llvm/lib/Target/XCore/TargetInfo/Makefile b/llvm/lib/Target/XCore/TargetInfo/Makefile new file mode 100644 index 000000000000..07473d223f6b --- /dev/null +++ b/llvm/lib/Target/XCore/TargetInfo/Makefile @@ -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/llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp b/llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp new file mode 100644 index 000000000000..ce664e1b3843 --- /dev/null +++ b/llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp @@ -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); +}