From 7c4a074505ca4c74685cbce6558fddf04ccbe036 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 17 Jul 2018 10:57:39 +0000 Subject: [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 llvm-svn: 337263 --- llvm/lib/Target/TargetMachineC.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Target/TargetMachineC.cpp') diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp index a6f4790b866..37d398d580f 100644 --- a/llvm/lib/Target/TargetMachineC.cpp +++ b/llvm/lib/Target/TargetMachineC.cpp @@ -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()); } -- cgit v1.2.3