[llvm-commits] [llvm] r76230 - in /llvm/trunk: CMakeLists.txt autoconf/configure.ac cmake/modules/LLVMConfig.cmake include/llvm/Config/AsmParsers.def.in include/llvm/Target/TargetAsmParser.h include/llvm/Target/TargetRegistry.h lib/Target/X86/AsmParser/ lib/Target/X86/AsmParser/CMakeLists.txt lib/Target/X86/AsmParser/Makefile lib/Target/X86/AsmParser/X86AsmParser.cpp lib/Target/X86/Makefile tools/llvm-config/llvm-config.in.in
Daniel Dunbar
daniel at zuster.org
Fri Jul 17 13:42:17 PDT 2009
Author: ddunbar
Date: Fri Jul 17 15:42:00 2009
New Revision: 76230
URL: http://llvm.org/viewvc/llvm-project?rev=76230&view=rev
Log:
Sketch support for target specific assembly parser.
- Not fully enabled yet, need a configure regeneration.
Added:
llvm/trunk/include/llvm/Config/AsmParsers.def.in
llvm/trunk/include/llvm/Target/TargetAsmParser.h
llvm/trunk/lib/Target/X86/AsmParser/ (with props)
llvm/trunk/lib/Target/X86/AsmParser/CMakeLists.txt
llvm/trunk/lib/Target/X86/AsmParser/Makefile
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Modified:
llvm/trunk/CMakeLists.txt
llvm/trunk/autoconf/configure.ac
llvm/trunk/cmake/modules/LLVMConfig.cmake
llvm/trunk/include/llvm/Target/TargetRegistry.h
llvm/trunk/lib/Target/X86/Makefile
llvm/trunk/tools/llvm-config/llvm-config.in.in
Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=76230&r1=76229&r2=76230&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Fri Jul 17 15:42:00 2009
@@ -257,6 +257,7 @@
add_subdirectory(lib/MC)
set(LLVM_ENUM_ASM_PRINTERS "")
+ set(LLVM_ENUM_ASM_PARSERS "")
foreach(t ${LLVM_TARGETS_TO_BUILD})
message(STATUS "Targeting ${t}")
add_subdirectory(lib/Target/${t})
@@ -266,6 +267,11 @@
set(LLVM_ENUM_ASM_PRINTERS
"${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n")
endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
+ if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmParser/CMakeLists.txt )
+ add_subdirectory(lib/Target/${t}/AsmParser)
+ set(LLVM_ENUM_ASM_PARSERS
+ "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n")
+ endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmParser/CMakeLists.txt )
endforeach(t)
# Produce llvm/Config/AsmPrinters.def
@@ -274,6 +280,12 @@
${LLVM_BINARY_DIR}/include/llvm/Config/AsmPrinters.def
)
+# Produce llvm/Config/AsmParsers.def
+configure_file(
+ ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in
+ ${LLVM_BINARY_DIR}/include/llvm/Config/AsmParsers.def
+ )
+
add_subdirectory(lib/ExecutionEngine)
add_subdirectory(lib/ExecutionEngine/Interpreter)
add_subdirectory(lib/ExecutionEngine/JIT)
Modified: llvm/trunk/autoconf/configure.ac
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=76230&r1=76229&r2=76230&view=diff
==============================================================================
--- llvm/trunk/autoconf/configure.ac (original)
+++ llvm/trunk/autoconf/configure.ac Fri Jul 17 15:42:00 2009
@@ -458,17 +458,22 @@
done
# Build the LLVM_TARGET and LLVM_ASM_PRINTER macro uses for
-# Targets.def and AsmPrinters.def.
+# Targets.def, AsmPrinters.def, and AsmParsers.def.
LLVM_ENUM_TARGETS=""
LLVM_ENUM_ASM_PRINTERS=""
+LLVM_ENUM_ASM_PARSERS=""
for target_to_build in $TARGETS_TO_BUILD; do
LLVM_ENUM_TARGETS="LLVM_TARGET($target_to_build) $LLVM_ENUM_TARGETS"
if test -f ${srcdir}/lib/Target/${target_to_build}/AsmPrinter/Makefile ; then
LLVM_ENUM_ASM_PRINTERS="LLVM_ASM_PRINTER($target_to_build) $LLVM_ENUM_ASM_PRINTERS";
fi
+ if test -f ${srcdir}/lib/Target/${target_to_build}/AsmParser/Makefile ; then
+ LLVM_ENUM_ASM_PARSERS="LLVM_ASM_PARSER($target_to_build) $LLVM_ENUM_ASM_PARSERS";
+ fi
done
AC_SUBST(LLVM_ENUM_TARGETS)
AC_SUBST(LLVM_ENUM_ASM_PRINTERS)
+AC_SUBST(LLVM_ENUM_ASM_PARSERS)
dnl Prevent the CBackend from using printf("%a") for floating point so older
dnl C compilers that cannot deal with the 0x0p+0 hex floating point format
@@ -1257,6 +1262,7 @@
AC_CONFIG_HEADERS([include/llvm/Config/config.h])
AC_CONFIG_FILES([include/llvm/Config/Targets.def])
AC_CONFIG_FILES([include/llvm/Config/AsmPrinters.def])
+AC_CONFIG_FILES([include/llvm/Config/AsmParser.def])
AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h])
AC_CONFIG_HEADERS([include/llvm/ADT/iterator.h])
Modified: llvm/trunk/cmake/modules/LLVMConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake?rev=76230&r1=76229&r2=76230&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/LLVMConfig.cmake (original)
+++ llvm/trunk/cmake/modules/LLVMConfig.cmake Fri Jul 17 15:42:00 2009
@@ -35,7 +35,7 @@
function(explicit_map_components_to_libraries out_libs)
set( link_components ${ARGN} )
foreach(c ${link_components})
- # add codegen/asmprinter
+ # add codegen, asmprinter, asmparser
list(FIND LLVM_TARGETS_TO_BUILD ${c} idx)
if( NOT idx LESS 0 )
list(FIND llvm_libs "LLVM${c}CodeGen" idx)
@@ -53,6 +53,10 @@
if( NOT asmidx LESS 0 )
list(APPEND expanded_components "LLVM${c}AsmPrinter")
endif()
+ list(FIND llvm_libs "LLVM${c}AsmParser" asmidx)
+ if( NOT asmidx LESS 0 )
+ list(APPEND expanded_components "LLVM${c}AsmParser")
+ endif()
list(FIND llvm_libs "LLVM${c}Info" asmidx)
if( NOT asmidx LESS 0 )
list(APPEND expanded_components "LLVM${c}Info")
Added: llvm/trunk/include/llvm/Config/AsmParsers.def.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/AsmParsers.def.in?rev=76230&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Config/AsmParsers.def.in (added)
+++ llvm/trunk/include/llvm/Config/AsmParsers.def.in Fri Jul 17 15:42:00 2009
@@ -0,0 +1,29 @@
+//===- llvm/Config/AsmParsers.def - LLVM Assembly Parsers -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file enumerates all of the assembly-language parsers
+// supported by this build of LLVM. Clients of this file should define
+// the LLVM_ASM_PARSER macro to be a function-like macro with a
+// single parameter (the name of the target whose assembly can be
+// generated); including this file will then enumerate all of the
+// targets with assembly parsers.
+//
+// The set of targets supported by LLVM is generated at configuration
+// time, at which point this header is generated. Do not modify this
+// header directly.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ASM_PARSER
+# error Please define the macro LLVM_ASM_PARSER(TargetName)
+#endif
+
+ at LLVM_ENUM_ASM_PARSERS@
+
+#undef LLVM_ASM_PARSER
Added: llvm/trunk/include/llvm/Target/TargetAsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmParser.h?rev=76230&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmParser.h (added)
+++ llvm/trunk/include/llvm/Target/TargetAsmParser.h Fri Jul 17 15:42:00 2009
@@ -0,0 +1,34 @@
+//===-- llvm/Target/TargetAsmParser.h - Target Assembly Parser --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGET_TARGETPARSER_H
+#define LLVM_TARGET_TARGETPARSER_H
+
+namespace llvm {
+class Target;
+
+/// TargetAsmParser - Generic interface to target specific assembly parsers.
+class TargetAsmParser {
+ TargetAsmParser(const TargetAsmParser &); // DO NOT IMPLEMENT
+ void operator=(const TargetAsmParser &); // DO NOT IMPLEMENT
+protected: // Can only create subclasses.
+ TargetAsmParser(const Target &);
+
+ /// TheTarget - The Target that this machine was created for.
+ const Target &TheTarget;
+
+public:
+ virtual ~TargetAsmParser();
+
+ const Target &getTarget() const { return TheTarget; }
+};
+
+} // End llvm namespace
+
+#endif
Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegistry.h?rev=76230&r1=76229&r2=76230&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetRegistry.h (original)
+++ llvm/trunk/include/llvm/Target/TargetRegistry.h Fri Jul 17 15:42:00 2009
@@ -25,6 +25,7 @@
namespace llvm {
class FunctionPass;
class Module;
+ class TargetAsmParser;
class TargetMachine;
class formatted_raw_ostream;
@@ -48,6 +49,7 @@
typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
TargetMachine &,
bool);
+ typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &);
friend struct TargetRegistry;
@@ -81,6 +83,10 @@
/// if registered.
AsmPrinterCtorTy AsmPrinterCtorFn;
+ /// AsmParserCtorFn - Construction function for this target's AsmParser,
+ /// if registered.
+ AsmParserCtorTy AsmParserCtorFn;
+
public:
// getNext - Return the next registered target.
const Target *getNext() const { return Next; }
@@ -101,6 +107,9 @@
/// hasAsmPrinter - Check if this target supports .s printing.
bool hasAsmPrinter() const { return AsmPrinterCtorFn != 0; }
+ /// hasAsmParser - Check if this target supports .s parsing.
+ bool hasAsmParser() const { return AsmParserCtorFn != 0; }
+
/// createTargetMachine - Create a target specific machine implementation.
TargetMachine *createTargetMachine(const Module &M,
const std::string &Features) const {
@@ -117,6 +126,13 @@
return 0;
return AsmPrinterCtorFn(OS, M, Verbose);
}
+
+ /// createAsmParser - Create a target specific assembly parser.
+ TargetAsmParser *createAsmParser() const {
+ if (!AsmParserCtorFn)
+ return 0;
+ return AsmParserCtorFn(*this);
+ }
};
/// TargetRegistry - Generic interface to target specific features.
@@ -225,8 +241,9 @@
/// @param Fn - A function to construct a TargetMachine for the target.
static void RegisterTargetMachine(Target &T,
Target::TargetMachineCtorTy Fn) {
- assert(!T.TargetMachineCtorFn && "Constructor already registered!");
- T.TargetMachineCtorFn = Fn;
+ // Ignore duplicate registration.
+ if (!T.TargetMachineCtorFn)
+ T.TargetMachineCtorFn = Fn;
}
/// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
@@ -239,8 +256,23 @@
/// @param T - The target being registered.
/// @param Fn - A function to construct an AsmPrinter for the target.
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
- assert(!T.AsmPrinterCtorFn && "Constructor already registered!");
- T.AsmPrinterCtorFn = Fn;
+ // Ignore duplicate registration.
+ if (!T.AsmPrinterCtorFn)
+ T.AsmPrinterCtorFn = Fn;
+ }
+
+ /// RegisterAsmParser - Register a TargetAsmParser implementation for the
+ /// given target.
+ ///
+ /// Clients are responsible for ensuring that registration doesn't occur
+ /// while another thread is attempting to access the registry. Typically
+ /// this is done by initializing all targets at program startup.
+ ///
+ /// @param T - The target being registered.
+ /// @param Fn - A function to construct an AsmPrinter for the target.
+ static void RegisterAsmParser(Target &T, Target::AsmParserCtorTy Fn) {
+ if (!T.AsmParserCtorFn)
+ T.AsmParserCtorFn = Fn;
}
/// @}
Propchange: llvm/trunk/lib/Target/X86/AsmParser/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jul 17 15:42:00 2009
@@ -0,0 +1,3 @@
+Debug
+Release-Asserts
+Release
Added: llvm/trunk/lib/Target/X86/AsmParser/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/CMakeLists.txt?rev=76230&view=auto
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/X86/AsmParser/CMakeLists.txt Fri Jul 17 15:42:00 2009
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMX86AsmParser
+ X86AsmParser.cpp
+ )
+add_dependencies(LLVMX86AsmParser X86CodeGenTable_gen)
Added: llvm/trunk/lib/Target/X86/AsmParser/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/Makefile?rev=76230&view=auto
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/Makefile (added)
+++ llvm/trunk/lib/Target/X86/AsmParser/Makefile Fri Jul 17 15:42:00 2009
@@ -0,0 +1,15 @@
+##===- lib/Target/X86/AsmParser/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 = LLVMX86AsmParser
+
+# Hack: we need to include 'main' x86 target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
Added: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=76230&view=auto
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (added)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Fri Jul 17 15:42:00 2009
@@ -0,0 +1,40 @@
+//===-- X86AsmParser.cpp - Parse X86 assembly to MCInst instructions ------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Target/TargetRegistry.h"
+#include "llvm/Target/TargetAsmParser.h"
+using namespace llvm;
+
+namespace {
+
+class X86ATTAsmParser : public TargetAsmParser {
+ public:
+ explicit X86ATTAsmParser(const Target &);
+};
+
+}
+
+X86ATTAsmParser::X86ATTAsmParser(const Target &T)
+ : TargetAsmParser(T)
+{
+}
+
+namespace {
+ TargetAsmParser *createAsmParser(const Target &T) {
+ return new X86ATTAsmParser(T);
+ }
+}
+
+// Force static initialization.
+extern "C" void LLVMInitializeX86AsmParser() {
+ extern Target TheX86_32Target;
+ TargetRegistry::RegisterAsmParser(TheX86_32Target, &createAsmParser);
+ extern Target TheX86_64Target;
+ TargetRegistry::RegisterAsmParser(TheX86_64Target, &createAsmParser);
+}
Modified: llvm/trunk/lib/Target/X86/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Makefile?rev=76230&r1=76229&r2=76230&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/Makefile (original)
+++ llvm/trunk/lib/Target/X86/Makefile Fri Jul 17 15:42:00 2009
@@ -18,6 +18,6 @@
X86GenFastISel.inc \
X86GenCallingConv.inc X86GenSubtarget.inc
-DIRS = AsmPrinter TargetInfo
+DIRS = AsmPrinter AsmParser TargetInfo
include $(LEVEL)/Makefile.common
Modified: llvm/trunk/tools/llvm-config/llvm-config.in.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/llvm-config.in.in?rev=76230&r1=76229&r2=76230&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-config/llvm-config.in.in (original)
+++ llvm/trunk/tools/llvm-config/llvm-config.in.in Fri Jul 17 15:42:00 2009
@@ -340,6 +340,11 @@
$NAME_MAP{$target} = [$target.'info',
$NAME_MAP{$target}[0]]
}
+
+ if (defined $NAME_MAP{$target.'asmparser'}) {
+ $NAME_MAP{$target} = [$target.'asmparser',
+ $NAME_MAP{$target}[0]]
+ }
}
# Add virtual entries.
More information about the llvm-commits
mailing list