llvm.org GIT mirror llvm / b1fb18e
Restore the capability to manipulate datalayout from the C API Summary: This consist in variosu addition to the C API: LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M); void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL); LLVMTargetDataRef LLVMCreateTargetMachineData(LLVMTargetMachineRef T); Reviewers: joker.eph, Wallbraker, echristo Subscribers: axw Differential Revision: http://reviews.llvm.org/D17255 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260936 91177308-0d34-0410-b5e6-96231b3b80d8 Amaury Sechet 4 years ago
6 changed file(s) with 38 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
182182
183183 /*===-- Target Data -------------------------------------------------------===*/
184184
185 /**
186 * Obtain the data layout for a module.
187 *
188 * @see Module::getDataLayout()
189 */
190 LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M);
191
192 /**
193 * Set the data layout for a module.
194 *
195 * @see Module::setDataLayout()
196 */
197 void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL);
198
185199 /** Creates target data from a target layout string.
186200 See the constructor llvm::DataLayout::DataLayout. */
187201 LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep);
114114 LLVMDisposeMessage. */
115115 char *LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T);
116116
117 /** Create a DataLayout based on the targetMachine. */
118 LLVMTargetDataRef LLVMCreateTargetDataLayout(LLVMTargetMachineRef T);
119
117120 /** Set the target machine's ASM verbosity. */
118121 void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T,
119122 LLVMBool VerboseAsm);
3939
4040 void LLVMInitializeTarget(LLVMPassRegistryRef R) {
4141 initializeTarget(*unwrap(R));
42 }
43
44 LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M) {
45 return wrap(&unwrap(M)->getDataLayout());
46 }
47
48 void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL) {
49 unwrap(M)->setDataLayout(*unwrap(DL));
4250 }
4351
4452 LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep) {
170170 unwrap(T)->Options.MCOptions.AsmVerbose = VerboseAsm;
171171 }
172172
173 LLVMTargetDataRef LLVMCreateTargetDataLayout(LLVMTargetMachineRef T) {
174 return wrap(new DataLayout(unwrap(T)->createDataLayout()));
175 }
176
173177 static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
174178 raw_pwrite_stream &OS,
175179 LLVMCodeGenFileType codegen,
0 ; RUN: llvm-as < %s | llvm-dis > %t.orig
11 ; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
22 ; RUN: diff -w %t.orig %t.echo
3
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.11.0"
36
47 %S = type { i64, %S* }
58
1515 //===----------------------------------------------------------------------===//
1616
1717 #include "llvm-c-test.h"
18 #include "llvm-c/Target.h"
1819 #include "llvm/ADT/DenseMap.h"
1920 #include "llvm/Support/ErrorHandling.h"
2021
628629 LLVMContextRef Ctx = LLVMContextCreate();
629630 LLVMModuleRef M = LLVMModuleCreateWithNameInContext("", Ctx);
630631
632 LLVMSetTarget(M, LLVMGetTarget(Src));
633 LLVMSetModuleDataLayout(M, LLVMGetModuleDataLayout(Src));
634 if (strcmp(LLVMGetDataLayoutStr(M), LLVMGetDataLayoutStr(Src)))
635 report_fatal_error("Inconsistent DataLayout string representation");
636
631637 clone_functions(Src, M);
632638 char *Str = LLVMPrintModuleToString(M);
633639 fputs(Str, stdout);