[llvm-commits] [llvm] r113235 - in /llvm/trunk: autoconf/ include/llvm/ADT/ lib/Support/ lib/Target/PTX/ lib/Target/PTX/AsmPrinter/ lib/Target/PTX/TargetInfo/
Nick Lewycky
nicholas at mxc.ca
Tue Sep 7 11:14:24 PDT 2010
Author: nicholas
Date: Tue Sep 7 13:14:24 2010
New Revision: 113235
URL: http://llvm.org/viewvc/llvm-project?rev=113235&view=rev
Log:
Create PTX backend. Patch by Che-Liang Chiou!
Added:
llvm/trunk/lib/Target/PTX/
llvm/trunk/lib/Target/PTX/AsmPrinter/
llvm/trunk/lib/Target/PTX/AsmPrinter/CMakeLists.txt
llvm/trunk/lib/Target/PTX/AsmPrinter/Makefile
llvm/trunk/lib/Target/PTX/AsmPrinter/PTXAsmPrinter.cpp
llvm/trunk/lib/Target/PTX/CMakeLists.txt
llvm/trunk/lib/Target/PTX/Makefile
llvm/trunk/lib/Target/PTX/PTX.h
llvm/trunk/lib/Target/PTX/PTX.td
llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp
llvm/trunk/lib/Target/PTX/PTXTargetMachine.h
llvm/trunk/lib/Target/PTX/TargetInfo/
llvm/trunk/lib/Target/PTX/TargetInfo/CMakeLists.txt
llvm/trunk/lib/Target/PTX/TargetInfo/Makefile
llvm/trunk/lib/Target/PTX/TargetInfo/PTXTargetInfo.cpp
Modified:
llvm/trunk/autoconf/configure.ac
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/lib/Support/Triple.cpp
Modified: llvm/trunk/autoconf/configure.ac
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=113235&r1=113234&r2=113235&view=diff
==============================================================================
--- llvm/trunk/autoconf/configure.ac (original)
+++ llvm/trunk/autoconf/configure.ac Tue Sep 7 13:14:24 2010
@@ -332,6 +332,7 @@
s390x-*) llvm_cv_target_arch="SystemZ" ;;
bfin-*) llvm_cv_target_arch="Blackfin" ;;
mblaze-*) llvm_cv_target_arch="MBlaze" ;;
+ ptx-*) llvm_cv_target_arch="PTX" ;;
*) llvm_cv_target_arch="Unknown" ;;
esac])
@@ -469,6 +470,7 @@
SystemZ) AC_SUBST(TARGET_HAS_JIT,0) ;;
Blackfin) AC_SUBST(TARGET_HAS_JIT,0) ;;
MBlaze) AC_SUBST(TARGET_HAS_JIT,0) ;;
+ PTX) AC_SUBST(TARGET_HAS_JIT,0) ;;
*) AC_SUBST(TARGET_HAS_JIT,0) ;;
esac
fi
@@ -543,13 +545,13 @@
AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
[Build specific host targets: all or target1,target2,... Valid targets are:
host, x86, x86_64, sparc, powerpc, alpha, arm, mips, spu, pic16,
- xcore, msp430, systemz, blackfin, cbe, and cpp (default=all)]),,
+ xcore, msp430, systemz, blackfin, ptx, cbe, and cpp (default=all)]),,
enableval=all)
if test "$enableval" = host-only ; then
enableval=host
fi
case "$enableval" in
- all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha ARM Mips CellSPU PIC16 XCore MSP430 SystemZ Blackfin CBackend CppBackend MBlaze" ;;
+ all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha ARM Mips CellSPU PIC16 XCore MSP430 SystemZ Blackfin CBackend CppBackend MBlaze PTX" ;;
*)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do
case "$a_target" in
x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
@@ -568,6 +570,7 @@
cbe) TARGETS_TO_BUILD="CBackend $TARGETS_TO_BUILD" ;;
cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;;
mblaze) TARGETS_TO_BUILD="MBlaze $TARGETS_TO_BUILD" ;;
+ ptx) TARGETS_TO_BUILD="PTX $TARGETS_TO_BUILD" ;;
host) case "$llvm_cv_target_arch" in
x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
x86_64) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
@@ -583,6 +586,7 @@
MSP430) TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;;
s390x) TARGETS_TO_BUILD="SystemZ $TARGETS_TO_BUILD" ;;
Blackfin) TARGETS_TO_BUILD="Blackfin $TARGETS_TO_BUILD" ;;
+ PTX) TARGETS_TO_BUILD="PTX $TARGETS_TO_BUILD" ;;
*) AC_MSG_ERROR([Can not set target to build]) ;;
esac ;;
*) AC_MSG_ERROR([Unrecognized target $a_target]) ;;
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=113235&r1=113234&r2=113235&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Tue Sep 7 13:14:24 2010
@@ -65,6 +65,7 @@
x86_64, // X86-64: amd64, x86_64
xcore, // XCore: xcore
mblaze, // MBlaze: mblaze
+ ptx, // PTX: ptx
InvalidArch
};
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=113235&r1=113234&r2=113235&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Tue Sep 7 13:14:24 2010
@@ -41,6 +41,7 @@
case x86_64: return "x86_64";
case xcore: return "xcore";
case mblaze: return "mblaze";
+ case ptx: return "ptx";
}
return "<invalid>";
@@ -70,7 +71,10 @@
case x86:
case x86_64: return "x86";
+
case xcore: return "xcore";
+
+ case ptx: return "ptx";
}
}
@@ -149,6 +153,8 @@
return x86_64;
if (Name == "xcore")
return xcore;
+ if (Name == "ptx")
+ return ptx;
return UnknownArch;
}
@@ -187,6 +193,9 @@
Str == "armv6" || Str == "armv7")
return Triple::arm;
+ if (Str == "ptx")
+ return Triple::ptx;
+
return Triple::UnknownArch;
}
@@ -216,6 +225,8 @@
return "armv6";
if (Str == "armv7" || Str == "thumbv7")
return "armv7";
+ if (Str == "ptx")
+ return "ptx";
return NULL;
}
@@ -266,6 +277,8 @@
return tce;
else if (ArchName == "xcore")
return xcore;
+ else if (ArchName == "ptx")
+ return ptx;
else
return UnknownArch;
}
Added: llvm/trunk/lib/Target/PTX/AsmPrinter/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/AsmPrinter/CMakeLists.txt?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/AsmPrinter/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/PTX/AsmPrinter/CMakeLists.txt Tue Sep 7 13:14:24 2010
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMPTXAsmPrinter
+ PTXAsmPrinter.cpp
+ )
+add_dependencies(LLVMPTXAsmPrinter PTXCodeGenTable_gen)
Added: llvm/trunk/lib/Target/PTX/AsmPrinter/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/AsmPrinter/Makefile?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/AsmPrinter/Makefile (added)
+++ llvm/trunk/lib/Target/PTX/AsmPrinter/Makefile Tue Sep 7 13:14:24 2010
@@ -0,0 +1,15 @@
+##===- lib/Target/PTX/AsmPrinter/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 = LLVMPTXAsmPrinter
+
+# Hack: we need to include 'main' PTX target directory to grab private headers
+CPP.Flags += -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
Added: llvm/trunk/lib/Target/PTX/AsmPrinter/PTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/AsmPrinter/PTXAsmPrinter.cpp?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/AsmPrinter/PTXAsmPrinter.cpp (added)
+++ llvm/trunk/lib/Target/PTX/AsmPrinter/PTXAsmPrinter.cpp Tue Sep 7 13:14:24 2010
@@ -0,0 +1,35 @@
+//===-- PTXAsmPrinter.cpp - PTX LLVM assembly writer ----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains a printer that converts from our internal representation
+// of machine-dependent LLVM code to PTX assembly language.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PTX.h"
+#include "PTXTargetMachine.h"
+#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/Target/TargetRegistry.h"
+
+using namespace llvm;
+
+namespace {
+ class PTXAsmPrinter : public AsmPrinter {
+ public:
+ explicit PTXAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) :
+ AsmPrinter(TM, Streamer) {}
+ const char *getPassName() const { return "PTX Assembly Printer"; }
+ };
+} // namespace
+
+// Force static initialization.
+extern "C" void LLVMInitializePTXAsmPrinter()
+{
+ RegisterAsmPrinter<PTXAsmPrinter> X(ThePTXTarget);
+}
Added: llvm/trunk/lib/Target/PTX/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/CMakeLists.txt?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/PTX/CMakeLists.txt Tue Sep 7 13:14:24 2010
@@ -0,0 +1,6 @@
+set(LLVM_TARGET_DEFINITIONS PTX.td)
+
+add_llvm_target(PTXCodeGen
+ )
+
+target_link_libraries (LLVMPTXCodeGen LLVMSelectionDAG)
Added: llvm/trunk/lib/Target/PTX/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/Makefile?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/Makefile (added)
+++ llvm/trunk/lib/Target/PTX/Makefile Tue Sep 7 13:14:24 2010
@@ -0,0 +1,19 @@
+##===- lib/Target/PTX/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 = LLVMPTXCodeGen
+TARGET = PTX
+
+# Make sure that tblgen is run, first thing.
+BUILT_SOURCES =
+
+DIRS = AsmPrinter TargetInfo
+
+include $(LEVEL)/Makefile.common
Added: llvm/trunk/lib/Target/PTX/PTX.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.h?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTX.h (added)
+++ llvm/trunk/lib/Target/PTX/PTX.h Tue Sep 7 13:14:24 2010
@@ -0,0 +1,24 @@
+//===-- PTX.h - Top-level interface for PTX representation ------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the entry points for global functions defined in the LLVM
+// PTX back-end.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef PTX_H
+#define PTX_H
+
+#include "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+ extern Target ThePTXTarget;
+} // namespace llvm;
+
+#endif // PTX_H
Added: llvm/trunk/lib/Target/PTX/PTX.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.td?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTX.td (added)
+++ llvm/trunk/lib/Target/PTX/PTX.td Tue Sep 7 13:14:24 2010
@@ -0,0 +1,10 @@
+//===- PTX.td - Describe the PTX Target Machine ---------------*- tblgen -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// This is the top level entry point for the PTX target.
+//===----------------------------------------------------------------------===//
Added: llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp (added)
+++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp Tue Sep 7 13:14:24 2010
@@ -0,0 +1,31 @@
+//===-- PTXTargetMachine.cpp - Define TargetMachine for PTX ---------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Top-level implementation for the PTX target.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PTX.h"
+#include "PTXTargetMachine.h"
+#include "llvm/Target/TargetRegistry.h"
+
+using namespace llvm;
+
+extern "C" void LLVMInitializePTXTarget()
+{
+ // Register the target
+ RegisterTargetMachine<PTXTargetMachine> X(ThePTXTarget);
+}
+
+PTXTargetMachine::PTXTargetMachine(const Target &T,
+ const std::string &TT,
+ const std::string &FS) :
+ LLVMTargetMachine(T, TT)
+{
+}
Added: llvm/trunk/lib/Target/PTX/PTXTargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.h?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXTargetMachine.h (added)
+++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.h Tue Sep 7 13:14:24 2010
@@ -0,0 +1,27 @@
+//===-- PTXTargetMachine.h - Define TargetMachine for PTX -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the PTX specific subclass of TargetMachine.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef PTX_TARGET_MACHINE_H
+#define PTX_TARGET_MACHINE_H
+
+#include "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+ class PTXTargetMachine : public LLVMTargetMachine {
+ public:
+ PTXTargetMachine(const Target &T, const std::string &TT,
+ const std::string &FS);
+ }; // class PTXTargetMachine
+} // namespace llvm
+
+#endif // PTX_TARGET_MACHINE_H
Added: llvm/trunk/lib/Target/PTX/TargetInfo/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/TargetInfo/CMakeLists.txt?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/TargetInfo/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/PTX/TargetInfo/CMakeLists.txt Tue Sep 7 13:14:24 2010
@@ -0,0 +1,7 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMPTXInfo
+ PTXTargetInfo.cpp
+ )
+
+add_dependencies(LLVMPTXInfo PTXCodeGenTable_gen)
Added: llvm/trunk/lib/Target/PTX/TargetInfo/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/TargetInfo/Makefile?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/TargetInfo/Makefile (added)
+++ llvm/trunk/lib/Target/PTX/TargetInfo/Makefile Tue Sep 7 13:14:24 2010
@@ -0,0 +1,15 @@
+##===- lib/Target/PTX/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 = LLVMPTXInfo
+
+# 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
Added: llvm/trunk/lib/Target/PTX/TargetInfo/PTXTargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/TargetInfo/PTXTargetInfo.cpp?rev=113235&view=auto
==============================================================================
--- llvm/trunk/lib/Target/PTX/TargetInfo/PTXTargetInfo.cpp (added)
+++ llvm/trunk/lib/Target/PTX/TargetInfo/PTXTargetInfo.cpp Tue Sep 7 13:14:24 2010
@@ -0,0 +1,22 @@
+//===-- PTXTargetInfo.cpp - PTX Target Implementation ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PTX.h"
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+
+using namespace llvm;
+
+Target llvm::ThePTXTarget;
+
+extern "C" void LLVMInitializePTXTargetInfo()
+{
+ // see llvm/ADT/Triple.h
+ RegisterTarget<Triple::ptx> X(ThePTXTarget, "ptx", "PTX");
+}
More information about the llvm-commits
mailing list