llvm.org GIT mirror llvm / f7a3c50
Create PTX backend. Patch by Che-Liang Chiou! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113235 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 8 years ago
15 changed file(s) with 237 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
331331 s390x-*) llvm_cv_target_arch="SystemZ" ;;
332332 bfin-*) llvm_cv_target_arch="Blackfin" ;;
333333 mblaze-*) llvm_cv_target_arch="MBlaze" ;;
334 ptx-*) llvm_cv_target_arch="PTX" ;;
334335 *) llvm_cv_target_arch="Unknown" ;;
335336 esac])
336337
468469 SystemZ) AC_SUBST(TARGET_HAS_JIT,0) ;;
469470 Blackfin) AC_SUBST(TARGET_HAS_JIT,0) ;;
470471 MBlaze) AC_SUBST(TARGET_HAS_JIT,0) ;;
472 PTX) AC_SUBST(TARGET_HAS_JIT,0) ;;
471473 *) AC_SUBST(TARGET_HAS_JIT,0) ;;
472474 esac
473475 fi
542544 AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
543545 [Build specific host targets: all or target1,target2,... Valid targets are:
544546 host, x86, x86_64, sparc, powerpc, alpha, arm, mips, spu, pic16,
545 xcore, msp430, systemz, blackfin, cbe, and cpp (default=all)]),,
547 xcore, msp430, systemz, blackfin, ptx, cbe, and cpp (default=all)]),,
546548 enableval=all)
547549 if test "$enableval" = host-only ; then
548550 enableval=host
549551 fi
550552 case "$enableval" in
551 all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha ARM Mips CellSPU PIC16 XCore MSP430 SystemZ Blackfin CBackend CppBackend MBlaze" ;;
553 all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha ARM Mips CellSPU PIC16 XCore MSP430 SystemZ Blackfin CBackend CppBackend MBlaze PTX" ;;
552554 *)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do
553555 case "$a_target" in
554556 x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
567569 cbe) TARGETS_TO_BUILD="CBackend $TARGETS_TO_BUILD" ;;
568570 cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;;
569571 mblaze) TARGETS_TO_BUILD="MBlaze $TARGETS_TO_BUILD" ;;
572 ptx) TARGETS_TO_BUILD="PTX $TARGETS_TO_BUILD" ;;
570573 host) case "$llvm_cv_target_arch" in
571574 x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
572575 x86_64) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;;
582585 MSP430) TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;;
583586 s390x) TARGETS_TO_BUILD="SystemZ $TARGETS_TO_BUILD" ;;
584587 Blackfin) TARGETS_TO_BUILD="Blackfin $TARGETS_TO_BUILD" ;;
588 PTX) TARGETS_TO_BUILD="PTX $TARGETS_TO_BUILD" ;;
585589 *) AC_MSG_ERROR([Can not set target to build]) ;;
586590 esac ;;
587591 *) AC_MSG_ERROR([Unrecognized target $a_target]) ;;
6464 x86_64, // X86-64: amd64, x86_64
6565 xcore, // XCore: xcore
6666 mblaze, // MBlaze: mblaze
67 ptx, // PTX: ptx
6768
6869 InvalidArch
6970 };
4040 case x86_64: return "x86_64";
4141 case xcore: return "xcore";
4242 case mblaze: return "mblaze";
43 case ptx: return "ptx";
4344 }
4445
4546 return "";
6970
7071 case x86:
7172 case x86_64: return "x86";
73
7274 case xcore: return "xcore";
75
76 case ptx: return "ptx";
7377 }
7478 }
7579
148152 return x86_64;
149153 if (Name == "xcore")
150154 return xcore;
155 if (Name == "ptx")
156 return ptx;
151157
152158 return UnknownArch;
153159 }
185191 if (Str == "arm" || Str == "armv4t" || Str == "armv5" || Str == "xscale" ||
186192 Str == "armv6" || Str == "armv7")
187193 return Triple::arm;
194
195 if (Str == "ptx")
196 return Triple::ptx;
188197
189198 return Triple::UnknownArch;
190199 }
215224 return "armv6";
216225 if (Str == "armv7" || Str == "thumbv7")
217226 return "armv7";
227 if (Str == "ptx")
228 return "ptx";
218229 return NULL;
219230 }
220231
265276 return tce;
266277 else if (ArchName == "xcore")
267278 return xcore;
279 else if (ArchName == "ptx")
280 return ptx;
268281 else
269282 return UnknownArch;
270283 }
0 include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
1
2 add_llvm_library(LLVMPTXAsmPrinter
3 PTXAsmPrinter.cpp
4 )
5 add_dependencies(LLVMPTXAsmPrinter PTXCodeGenTable_gen)
0 ##===- lib/Target/PTX/AsmPrinter/Makefile ------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8 LEVEL = ../../../..
9 LIBRARYNAME = LLVMPTXAsmPrinter
10
11 # Hack: we need to include 'main' PTX target directory to grab private headers
12 CPP.Flags += -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
13
14 include $(LEVEL)/Makefile.common
0 //===-- PTXAsmPrinter.cpp - PTX LLVM assembly writer ----------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains a printer that converts from our internal representation
10 // of machine-dependent LLVM code to PTX assembly language.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "PTX.h"
15 #include "PTXTargetMachine.h"
16 #include "llvm/CodeGen/AsmPrinter.h"
17 #include "llvm/Target/TargetRegistry.h"
18
19 using namespace llvm;
20
21 namespace {
22 class PTXAsmPrinter : public AsmPrinter {
23 public:
24 explicit PTXAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) :
25 AsmPrinter(TM, Streamer) {}
26 const char *getPassName() const { return "PTX Assembly Printer"; }
27 };
28 } // namespace
29
30 // Force static initialization.
31 extern "C" void LLVMInitializePTXAsmPrinter()
32 {
33 RegisterAsmPrinter X(ThePTXTarget);
34 }
0 set(LLVM_TARGET_DEFINITIONS PTX.td)
1
2 add_llvm_target(PTXCodeGen
3 )
4
5 target_link_libraries (LLVMPTXCodeGen LLVMSelectionDAG)
0 ##===- lib/Target/PTX/Makefile -----------------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8
9 LEVEL = ../../..
10 LIBRARYNAME = LLVMPTXCodeGen
11 TARGET = PTX
12
13 # Make sure that tblgen is run, first thing.
14 BUILT_SOURCES =
15
16 DIRS = AsmPrinter TargetInfo
17
18 include $(LEVEL)/Makefile.common
0 //===-- PTX.h - Top-level interface for PTX representation ------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the entry points for global functions defined in the LLVM
10 // PTX back-end.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef PTX_H
15 #define PTX_H
16
17 #include "llvm/Target/TargetMachine.h"
18
19 namespace llvm {
20 extern Target ThePTXTarget;
21 } // namespace llvm;
22
23 #endif // PTX_H
0 //===- PTX.td - Describe the PTX Target Machine ---------------*- tblgen -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 // This is the top level entry point for the PTX target.
9 //===----------------------------------------------------------------------===//
0 //===-- PTXTargetMachine.cpp - Define TargetMachine for PTX ---------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Top-level implementation for the PTX target.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "PTX.h"
14 #include "PTXTargetMachine.h"
15 #include "llvm/Target/TargetRegistry.h"
16
17 using namespace llvm;
18
19 extern "C" void LLVMInitializePTXTarget()
20 {
21 // Register the target
22 RegisterTargetMachine X(ThePTXTarget);
23 }
24
25 PTXTargetMachine::PTXTargetMachine(const Target &T,
26 const std::string &TT,
27 const std::string &FS) :
28 LLVMTargetMachine(T, TT)
29 {
30 }
0 //===-- PTXTargetMachine.h - Define TargetMachine for PTX -------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the PTX specific subclass of TargetMachine.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef PTX_TARGET_MACHINE_H
14 #define PTX_TARGET_MACHINE_H
15
16 #include "llvm/Target/TargetMachine.h"
17
18 namespace llvm {
19 class PTXTargetMachine : public LLVMTargetMachine {
20 public:
21 PTXTargetMachine(const Target &T, const std::string &TT,
22 const std::string &FS);
23 }; // class PTXTargetMachine
24 } // namespace llvm
25
26 #endif // PTX_TARGET_MACHINE_H
0 include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
1
2 add_llvm_library(LLVMPTXInfo
3 PTXTargetInfo.cpp
4 )
5
6 add_dependencies(LLVMPTXInfo PTXCodeGenTable_gen)
0 ##===- lib/Target/PTX/TargetInfo/Makefile ------------------*- Makefile -*-===##
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 ##===----------------------------------------------------------------------===##
8 LEVEL = ../../../..
9 LIBRARYNAME = LLVMPTXInfo
10
11 # Hack: we need to include 'main' target directory to grab private headers
12 CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
13
14 include $(LEVEL)/Makefile.common
0 //===-- PTXTargetInfo.cpp - PTX Target Implementation ---------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "PTX.h"
10 #include "llvm/Module.h"
11 #include "llvm/Target/TargetRegistry.h"
12
13 using namespace llvm;
14
15 Target llvm::ThePTXTarget;
16
17 extern "C" void LLVMInitializePTXTargetInfo()
18 {
19 // see llvm/ADT/Triple.h
20 RegisterTarget X(ThePTXTarget, "ptx", "PTX");
21 }