[llvm] r337263 - [LLVM-C] Add target triple normalization to the C API.
whitequark via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 17 03:57:39 PDT 2018
Author: whitequark
Date: Tue Jul 17 03:57:39 2018
New Revision: 337263
URL: http://llvm.org/viewvc/llvm-project?rev=337263&view=rev
Log:
[LLVM-C] Add target triple normalization to the C API.
rL333307 was introduced to remove automatic target triple
normalization when calling sys::getDefaultTargetTriple(), arguing
that users of the latter already called Triple::normalize()
if necessary. However, users of the C API currently have no way of
doing target triple normalization.
This patch introduces an LLVMNormalizeTargetTriple function to
the C API which wraps Triple::normalize() and can be used on
the result of LLVMGetDefaultTargetTriple to achieve the same effect.
Differential Revision: https://reviews.llvm.org/D49414
Reviewed By: whitequark
Modified:
llvm/trunk/include/llvm-c/TargetMachine.h
llvm/trunk/lib/Target/TargetMachineC.cpp
Modified: llvm/trunk/include/llvm-c/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/TargetMachine.h?rev=337263&r1=337262&r2=337263&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/TargetMachine.h (original)
+++ llvm/trunk/include/llvm-c/TargetMachine.h Tue Jul 17 03:57:39 2018
@@ -137,6 +137,10 @@ LLVMBool LLVMTargetMachineEmitToMemoryBu
disposed with LLVMDisposeMessage. */
char* LLVMGetDefaultTargetTriple(void);
+/** Normalize a target triple. The result needs to be disposed with
+ LLVMDisposeMessage. */
+char* LLVMNormalizeTargetTriple(const char* triple);
+
/** Get the host CPU as a string. The result needs to be disposed with
LLVMDisposeMessage. */
char* LLVMGetHostCPUName(void);
Modified: llvm/trunk/lib/Target/TargetMachineC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachineC.cpp?rev=337263&r1=337262&r2=337263&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachineC.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachineC.cpp Tue Jul 17 03:57:39 2018
@@ -238,6 +238,10 @@ char *LLVMGetDefaultTargetTriple(void) {
return strdup(sys::getDefaultTargetTriple().c_str());
}
+char *LLVMNormalizeTargetTriple(const char* triple) {
+ return strdup(Triple::normalize(StringRef(triple)).c_str());
+}
+
char *LLVMGetHostCPUName(void) {
return strdup(sys::getHostCPUName().data());
}
More information about the llvm-commits
mailing list