diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-15 06:35:19 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-15 06:35:19 +0000 |
commit | c984df8602a8b2450cbdb6ff55fd49ba709a391e (patch) | |
tree | d89b8c66dffaa5a83f7614d3a11de26c84e9bea1 /lib | |
parent | f9b36f08efbc66670910a8a85dd89f03d36196d4 (diff) | |
download | external_llvm-c984df8602a8b2450cbdb6ff55fd49ba709a391e.zip external_llvm-c984df8602a8b2450cbdb6ff55fd49ba709a391e.tar.gz external_llvm-c984df8602a8b2450cbdb6ff55fd49ba709a391e.tar.bz2 |
Add TargetInfo libraries for all targets.
- 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
Diffstat (limited to 'lib')
56 files changed, 1173 insertions, 8 deletions
diff --git a/lib/Target/ARM/Makefile b/lib/Target/ARM/Makefile index 9a3b9be..d879521 100644 --- a/lib/Target/ARM/Makefile +++ b/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/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp b/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp new file mode 100644 index 0000000..a08c915 --- /dev/null +++ b/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/lib/Target/ARM/TargetInfo/CMakeLists.txt b/lib/Target/ARM/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..4eddb48 --- /dev/null +++ b/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/lib/Target/ARM/TargetInfo/Makefile b/lib/Target/ARM/TargetInfo/Makefile new file mode 100644 index 0000000..6292ab1 --- /dev/null +++ b/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/lib/Target/Alpha/Makefile b/lib/Target/Alpha/Makefile index d6c82c7..55c7ec9 100644 --- a/lib/Target/Alpha/Makefile +++ b/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/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp b/lib/Target/Alpha/TargetInfo/AlphaTargetInfo.cpp new file mode 100644 index 0000000..df560b8 --- /dev/null +++ b/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/lib/Target/Alpha/TargetInfo/CMakeLists.txt b/lib/Target/Alpha/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..4478ef8 --- /dev/null +++ b/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/lib/Target/Alpha/TargetInfo/Makefile b/lib/Target/Alpha/TargetInfo/Makefile new file mode 100644 index 0000000..7250358 --- /dev/null +++ b/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/lib/Target/CBackend/Makefile b/lib/Target/CBackend/Makefile index 336de0c..3b5ef0f 100644 --- a/lib/Target/CBackend/Makefile +++ b/lib/Target/CBackend/Makefile @@ -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 index 0000000..178c1dd --- /dev/null +++ b/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/lib/Target/CBackend/TargetInfo/CMakeLists.txt b/lib/Target/CBackend/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..5b35fa7 --- /dev/null +++ b/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/lib/Target/CBackend/TargetInfo/Makefile b/lib/Target/CBackend/TargetInfo/Makefile new file mode 100644 index 0000000..d4d5e15 --- /dev/null +++ b/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/lib/Target/CellSPU/Makefile b/lib/Target/CellSPU/Makefile index a460db3..8415168 100644 --- a/lib/Target/CellSPU/Makefile +++ b/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/lib/Target/CellSPU/TargetInfo/CMakeLists.txt b/lib/Target/CellSPU/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..b2cb2ff --- /dev/null +++ b/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/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp b/lib/Target/CellSPU/TargetInfo/CellSPUTargetInfo.cpp new file mode 100644 index 0000000..c5ad7b8 --- /dev/null +++ b/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/lib/Target/CellSPU/TargetInfo/Makefile b/lib/Target/CellSPU/TargetInfo/Makefile new file mode 100644 index 0000000..9cb6827 --- /dev/null +++ b/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/lib/Target/CppBackend/Makefile b/lib/Target/CppBackend/Makefile index ca7e1a8..dc9cf48 100644 --- a/lib/Target/CppBackend/Makefile +++ b/lib/Target/CppBackend/Makefile @@ -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 index 0000000..edaf5d3 --- /dev/null +++ b/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/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp b/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp new file mode 100644 index 0000000..3c29070 --- /dev/null +++ b/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/lib/Target/CppBackend/TargetInfo/Makefile b/lib/Target/CppBackend/TargetInfo/Makefile new file mode 100644 index 0000000..6e68283 --- /dev/null +++ b/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/lib/Target/IA64/Makefile b/lib/Target/IA64/Makefile index d383254..5c5bd63 100644 --- a/lib/Target/IA64/Makefile +++ b/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/lib/Target/IA64/TargetInfo/CMakeLists.txt b/lib/Target/IA64/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..c5b7bc7 --- /dev/null +++ b/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/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp b/lib/Target/IA64/TargetInfo/IA64TargetInfo.cpp new file mode 100644 index 0000000..00bdb20 --- /dev/null +++ b/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/lib/Target/IA64/TargetInfo/Makefile b/lib/Target/IA64/TargetInfo/Makefile new file mode 100644 index 0000000..89f467b --- /dev/null +++ b/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/lib/Target/MSIL/Makefile b/lib/Target/MSIL/Makefile index 94265ed..8057cc7 100644 --- a/lib/Target/MSIL/Makefile +++ b/lib/Target/MSIL/Makefile @@ -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 index 0000000..9f0c3a0 --- /dev/null +++ b/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/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp b/lib/Target/MSIL/TargetInfo/MSILTargetInfo.cpp new file mode 100644 index 0000000..47e650b --- /dev/null +++ b/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/lib/Target/MSIL/TargetInfo/Makefile b/lib/Target/MSIL/TargetInfo/Makefile new file mode 100644 index 0000000..30b0950 --- /dev/null +++ b/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/lib/Target/MSP430/Makefile b/lib/Target/MSP430/Makefile index 45cb3aa..1ca57d7 100644 --- a/lib/Target/MSP430/Makefile +++ b/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/lib/Target/MSP430/TargetInfo/CMakeLists.txt b/lib/Target/MSP430/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..1bf9fe6 --- /dev/null +++ b/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/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp b/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp new file mode 100644 index 0000000..0bdf882 --- /dev/null +++ b/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/lib/Target/MSP430/TargetInfo/Makefile b/lib/Target/MSP430/TargetInfo/Makefile new file mode 100644 index 0000000..abb08f2 --- /dev/null +++ b/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/lib/Target/Mips/Makefile b/lib/Target/Mips/Makefile index 48ab5f9..0780345 100644 --- a/lib/Target/Mips/Makefile +++ b/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/lib/Target/Mips/TargetInfo/CMakeLists.txt b/lib/Target/Mips/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..fda93cb --- /dev/null +++ b/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/lib/Target/Mips/TargetInfo/Makefile b/lib/Target/Mips/TargetInfo/Makefile new file mode 100644 index 0000000..32f4e16 --- /dev/null +++ b/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/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp b/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp new file mode 100644 index 0000000..1f4dc9e --- /dev/null +++ b/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/lib/Target/PIC16/Makefile b/lib/Target/PIC16/Makefile index c429324..4ce60a9 100644 --- a/lib/Target/PIC16/Makefile +++ b/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/lib/Target/PIC16/TargetInfo/CMakeLists.txt b/lib/Target/PIC16/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..7a8c4ca --- /dev/null +++ b/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/lib/Target/PIC16/TargetInfo/Makefile b/lib/Target/PIC16/TargetInfo/Makefile new file mode 100644 index 0000000..76609f6 --- /dev/null +++ b/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/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp b/lib/Target/PIC16/TargetInfo/PIC16TargetInfo.cpp new file mode 100644 index 0000000..454f425 --- /dev/null +++ b/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/lib/Target/PowerPC/Makefile b/lib/Target/PowerPC/Makefile index db68897..4015d4a 100644 --- a/lib/Target/PowerPC/Makefile +++ b/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/lib/Target/PowerPC/TargetInfo/CMakeLists.txt b/lib/Target/PowerPC/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..6018c41 --- /dev/null +++ b/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/lib/Target/PowerPC/TargetInfo/Makefile b/lib/Target/PowerPC/TargetInfo/Makefile new file mode 100644 index 0000000..4253ce8 --- /dev/null +++ b/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/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp b/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp new file mode 100644 index 0000000..0502e37 --- /dev/null +++ b/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/lib/Target/Sparc/Makefile b/lib/Target/Sparc/Makefile index fdf6afa..6714b4d 100644 --- a/lib/Target/Sparc/Makefile +++ b/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/lib/Target/Sparc/TargetInfo/CMakeLists.txt b/lib/Target/Sparc/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..835afb5 --- /dev/null +++ b/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/lib/Target/Sparc/TargetInfo/Makefile b/lib/Target/Sparc/TargetInfo/Makefile new file mode 100644 index 0000000..641ed87 --- /dev/null +++ b/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/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp b/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp new file mode 100644 index 0000000..71c72d9 --- /dev/null +++ b/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/lib/Target/X86/Makefile b/lib/Target/X86/Makefile index 44f1c5d..2596f1f 100644 --- a/lib/Target/X86/Makefile +++ b/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/lib/Target/X86/TargetInfo/CMakeLists.txt b/lib/Target/X86/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..da454f1 --- /dev/null +++ b/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/lib/Target/X86/TargetInfo/Makefile b/lib/Target/X86/TargetInfo/Makefile new file mode 100644 index 0000000..6677d4b --- /dev/null +++ b/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/lib/Target/X86/TargetInfo/X86TargetInfo.cpp b/lib/Target/X86/TargetInfo/X86TargetInfo.cpp new file mode 100644 index 0000000..9d811ab --- /dev/null +++ b/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/lib/Target/XCore/Makefile b/lib/Target/XCore/Makefile index 568df70..9ca4560 100644 --- a/lib/Target/XCore/Makefile +++ b/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/lib/Target/XCore/TargetInfo/CMakeLists.txt b/lib/Target/XCore/TargetInfo/CMakeLists.txt new file mode 100644 index 0000000..2772a51 --- /dev/null +++ b/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/lib/Target/XCore/TargetInfo/Makefile b/lib/Target/XCore/TargetInfo/Makefile new file mode 100644 index 0000000..07473d2 --- /dev/null +++ b/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/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp b/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp new file mode 100644 index 0000000..ce664e1 --- /dev/null +++ b/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); +} |