forked from OSchip/llvm-project
First step of implementing PR1538: move llvm2cpp logic to new 'target'
llvm-svn: 50189
This commit is contained in:
parent
d871fa5cb6
commit
78695035c4
|
@ -363,7 +363,7 @@ AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
|
|||
[Build specific host targets: all,host-only,{target-name} (default=all)]),,
|
||||
enableval=all)
|
||||
case "$enableval" in
|
||||
all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha IA64 ARM Mips CellSPU CBackend MSIL" ;;
|
||||
all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha IA64 ARM Mips CellSPU CBackend MSIL CppBackend" ;;
|
||||
host-only)
|
||||
case "$llvm_cv_target_arch" in
|
||||
x86) TARGETS_TO_BUILD="X86" ;;
|
||||
|
@ -391,6 +391,7 @@ case "$enableval" in
|
|||
spu) TARGETS_TO_BUILD="CellSPU $TARGETS_TO_BUILD" ;;
|
||||
cbe) TARGETS_TO_BUILD="CBackend $TARGETS_TO_BUILD" ;;
|
||||
msil) TARGETS_TO_BUILD="MSIL $TARGETS_TO_BUILD" ;;
|
||||
cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;;
|
||||
*) AC_MSG_ERROR([Unrecognized target $a_target]) ;;
|
||||
esac
|
||||
done
|
||||
|
|
|
@ -4743,7 +4743,7 @@ else
|
|||
fi
|
||||
|
||||
case "$enableval" in
|
||||
all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha IA64 ARM Mips CellSPU CBackend MSIL" ;;
|
||||
all) TARGETS_TO_BUILD="X86 Sparc PowerPC Alpha IA64 ARM Mips CellSPU CBackend MSIL CppBackend" ;;
|
||||
host-only)
|
||||
case "$llvm_cv_target_arch" in
|
||||
x86) TARGETS_TO_BUILD="X86" ;;
|
||||
|
@ -4773,6 +4773,7 @@ echo "$as_me: error: Can not set target to build" >&2;}
|
|||
spu) TARGETS_TO_BUILD="CellSPU $TARGETS_TO_BUILD" ;;
|
||||
cbe) TARGETS_TO_BUILD="CBackend $TARGETS_TO_BUILD" ;;
|
||||
msil) TARGETS_TO_BUILD="MSIL $TARGETS_TO_BUILD" ;;
|
||||
cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;;
|
||||
*) { { echo "$as_me:$LINENO: error: Unrecognized target $a_target" >&5
|
||||
echo "$as_me: error: Unrecognized target $a_target" >&2;}
|
||||
{ (exit 1); exit 1; }; } ;;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,41 @@
|
|||
//===-- CPPTargetMachine.h - TargetMachine for the C++ backend --*- 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 TargetMachine that is used by the C++ backend.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CPPTARGETMACHINE_H
|
||||
#define CPPTARGETMACHINE_H
|
||||
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
struct CPPTargetMachine : public TargetMachine {
|
||||
const TargetData DataLayout; // Calculates type size & alignment
|
||||
|
||||
CPPTargetMachine(const Module &M, const std::string &FS)
|
||||
: DataLayout(&M) {}
|
||||
|
||||
virtual bool WantsWholeFile() const { return true; }
|
||||
virtual bool addPassesToEmitWholeFile(PassManager &PM, std::ostream &Out,
|
||||
CodeGenFileType FileType, bool Fast);
|
||||
|
||||
// This class always works, but shouldn't be the default in most cases.
|
||||
static unsigned getModuleMatchQuality(const Module &M) { return 1; }
|
||||
|
||||
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
##===- lib/Target/CppBackend/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 = LLVMCppBackend
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
CompileCommonOpts += -Wno-format
|
|
@ -134,10 +134,15 @@ static std::ostream *GetOutputStream(const char *ProgName) {
|
|||
|
||||
switch (FileType) {
|
||||
case TargetMachine::AssemblyFile:
|
||||
if (MArch->Name[0] != 'c' || MArch->Name[1] != 0) // not CBE
|
||||
if (MArch->Name[0] == 'c') {
|
||||
if (MArch->Name[1] == 0)
|
||||
OutputFilename += ".cbe.c";
|
||||
else if (MArch->Name[1] == 'p' && MArch->Name[2] == 'p')
|
||||
OutputFilename += ".cpp";
|
||||
else
|
||||
OutputFilename += ".s";
|
||||
} else
|
||||
OutputFilename += ".s";
|
||||
else
|
||||
OutputFilename += ".cbe.c";
|
||||
break;
|
||||
case TargetMachine::ObjectFile:
|
||||
OutputFilename += ".o";
|
||||
|
|
Loading…
Reference in New Issue