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 | |
parent | f9b36f08efbc66670910a8a85dd89f03d36196d4 (diff) |
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
56 files changed, 1173 insertions, 8 deletions
diff --git a/lib/Target/ARM/Makefile b/lib/Target/ARM/Makefile index 9a3b9be5b3..d879521a2d 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 0000000000..a08c915bc6 --- /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 0000000000..4eddb48a7d --- /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 0000000000..6292ab14b3 --- /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 d6c82c7d74..55c7ec99d1 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 0000000000..df560b8c87 --- /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 0000000000..4478ef8f81 --- /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 0000000000..7250358e46 --- /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 336de0c6f4..3b5ef0f346 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 0000000000..178c1dd8b4 --- /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 0000000000..5b35fa7c06 --- /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 0000000000..d4d5e15b40 --- /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 a460db3cfe..8415168aea 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 0000000000..b2cb2ffa4c --- /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 0000000000..c5ad7b8fb4 --- /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 0000000000..9cb6827b43 --- /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 ca7e1a82c8..dc9cf48c8b 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 0000000000..edaf5d3cb1 --- /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 0000000000..3c29070804 --- /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 0000000000..6e682838da --- /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 d38325422c..5c5bd635c0 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 0000000000..c5b7bc72e0 --- /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 0000000000..00bdb203b5 --- /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" +usin |