[llvm-commits] [gcc-plugin] r79545 - in /gcc-plugin/trunk: Makefile llvm-backend.cpp
Duncan Sands
baldrick at free.fr
Thu Aug 20 10:50:25 PDT 2009
Author: baldrick
Date: Thu Aug 20 12:50:25 2009
New Revision: 79545
URL: http://llvm.org/viewvc/llvm-project?rev=79545&view=rev
Log:
Determine the target triple automagically, rather
than hard-wiring it.
Modified:
gcc-plugin/trunk/Makefile
gcc-plugin/trunk/llvm-backend.cpp
Modified: gcc-plugin/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/Makefile?rev=79545&r1=79544&r2=79545&view=diff
==============================================================================
--- gcc-plugin/trunk/Makefile (original)
+++ gcc-plugin/trunk/Makefile Thu Aug 20 12:50:25 2009
@@ -8,8 +8,10 @@
#CFLAGS+=-I$(GCCPLUGINS_DIR)/include -fPIC -O2
+TARGET_TRIPLE:=$(shell $(GCCOBJECT_DIR)/gcc/xgcc -v 2>&1 | grep "^Target:" | sed -e "s/^Target: *//")
+
CFLAGS+=-Werror -fPIC -g -O2
-CFLAGS+=-DIN_GCC
+CFLAGS+=-DIN_GCC -DTARGET_NAME=\"$(TARGET_TRIPLE)\"
CFLAGS+=-I${GCCOBJECT_DIR}/gcc -I${GCCOBJECT_DIR}/gcc/include \
-I${GCCSOURCE_DIR}/gcc -I${GCCSOURCE_DIR}/include \
-I${GCCSOURCE_DIR}/libcpp/include -I${GCCSOURCE_DIR}/libdecnumber \
Modified: gcc-plugin/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-backend.cpp?rev=79545&r1=79544&r2=79545&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-backend.cpp (original)
+++ gcc-plugin/trunk/llvm-backend.cpp Thu Aug 20 12:50:25 2009
@@ -468,23 +468,22 @@
// If the target wants to override the architecture, e.g. turning
// powerpc-darwin-... into powerpc64-darwin-... when -m64 is enabled, do so
// now.
- std::string TargetTriple = "x86_64-linux-gnu"; // FIXME!
-//TODO std::string TargetTriple = TARGET_NAME;
-//TODO#ifdef LLVM_OVERRIDE_TARGET_ARCH
-//TODO std::string Arch = LLVM_OVERRIDE_TARGET_ARCH();
-//TODO if (!Arch.empty()) {
-//TODO std::string::size_type DashPos = TargetTriple.find('-');
-//TODO if (DashPos != std::string::npos)// If we have a sane t-t, replace the arch.
-//TODO TargetTriple = Arch + TargetTriple.substr(DashPos);
-//TODO }
-//TODO#endif
-//TODO#ifdef LLVM_OVERRIDE_TARGET_VERSION
-//TODO char *NewTriple;
-//TODO bool OverRidden = LLVM_OVERRIDE_TARGET_VERSION(TargetTriple.c_str(),
-//TODO &NewTriple);
-//TODO if (OverRidden)
-//TODO TargetTriple = std::string(NewTriple);
-//TODO#endif
+ std::string TargetTriple = TARGET_NAME;
+#ifdef LLVM_OVERRIDE_TARGET_ARCH
+ std::string Arch = LLVM_OVERRIDE_TARGET_ARCH();
+ if (!Arch.empty()) {
+ std::string::size_type DashPos = TargetTriple.find('-');
+ if (DashPos != std::string::npos)// If we have a sane t-t, replace the arch.
+ TargetTriple = Arch + TargetTriple.substr(DashPos);
+ }
+#endif
+#ifdef LLVM_OVERRIDE_TARGET_VERSION
+ char *NewTriple;
+ bool OverRidden = LLVM_OVERRIDE_TARGET_VERSION(TargetTriple.c_str(),
+ &NewTriple);
+ if (OverRidden)
+ TargetTriple = std::string(NewTriple);
+#endif
TheModule->setTargetTriple(TargetTriple);
TheTypeConverter = new TypeConverter();
More information about the llvm-commits
mailing list