diff options
Diffstat (limited to 'src/ortho/llvm-nodebug')
-rw-r--r-- | src/ortho/llvm-nodebug/Makefile | 32 | ||||
-rw-r--r-- | src/ortho/llvm-nodebug/llvm-target.ads | 18 | ||||
-rw-r--r-- | src/ortho/llvm-nodebug/llvm-targetmachine.ads | 4 | ||||
-rw-r--r-- | src/ortho/llvm-nodebug/ortho_code_main.adb | 6 |
4 files changed, 50 insertions, 10 deletions
diff --git a/src/ortho/llvm-nodebug/Makefile b/src/ortho/llvm-nodebug/Makefile new file mode 100644 index 000000000..68aba29cf --- /dev/null +++ b/src/ortho/llvm-nodebug/Makefile @@ -0,0 +1,32 @@ +ortho_srcdir=.. +GNAT_FLAGS=-gnaty3befhkmr -gnata -gnatf -gnatwael -gnat05 +CXX=clang++ +LLVM_CONFIG=llvm-config +GNATMAKE=gnatmake +SED=sed +BE=llvm-nodebug + +all: $(ortho_exec) + +$(ortho_exec): $(ortho_srcdir)/llvm-nodebug/ortho_llvm.ads force llvm-cbindings.o + $(GNATMAKE) -o $@ -aI$(ortho_srcdir)/llvm-nodebug -aI$(ortho_srcdir) \ + $(GNAT_FLAGS) ortho_code_main -bargs -E \ + -largs llvm-cbindings.o --LINK=$(CXX) \ + `$(LLVM_CONFIG) --ldflags --libs --system-libs` $(LDFLAGS) + +llvm-cbindings.o: $(ortho_srcdir)/llvm-nodebug/llvm-cbindings.cpp + $(CXX) -c `$(LLVM_CONFIG) --cxxflags` -o $@ $< + +clean: + $(RM) -f *.o *.ali ortho_code_main + $(RM) b~*.ad? *~ + +distclean: clean + + +force: + +.PHONY: force all clean + +ORTHO_BASENAME=ortho_llvm +include $(ortho_srcdir)/Makefile.inc diff --git a/src/ortho/llvm-nodebug/llvm-target.ads b/src/ortho/llvm-nodebug/llvm-target.ads index b7c35848a..17cd0427f 100644 --- a/src/ortho/llvm-nodebug/llvm-target.ads +++ b/src/ortho/llvm-nodebug/llvm-target.ads @@ -39,17 +39,23 @@ package LLVM.Target is pragma Import (C, InitializeNativeAsmPrinter, "LLVMInitializeNativeAsmPrinter_noinline"); + -- Target Data + + -- Obtain the data layout for a module. + -- see Module::getDataLayout() + function GetModuleDataLayout (M : ModuleRef) return TargetDataRef; + pragma Import (C, GetModuleDataLayout, "LLVMGetModuleDataLayout"); + + -- Set the data layout for a module. + -- see Module::setDataLayout() + procedure SetModuleDataLayout (M : ModuleRef; DL : TargetDataRef); + pragma Import (C, SetModuleDataLayout, "LLVMSetModuleDataLayout"); + -- Creates target data from a target layout string. -- See the constructor llvm::DataLayout::DataLayout. function CreateTargetData (StringRep : Cstring) return TargetDataRef; pragma Import (C, CreateTargetData, "LLVMCreateTargetData"); - -- Adds target data information to a pass manager. This does not take - -- ownership of the target data. - -- See the method llvm::PassManagerBase::add. - procedure AddTargetData(TD : TargetDataRef; PM : PassManagerRef); - pragma Import (C, AddTargetData, "LLVMAddTargetData"); - -- Converts target data to a target layout string. The string must be -- disposed with LLVMDisposeMessage. -- See the constructor llvm::DataLayout::DataLayout. */ diff --git a/src/ortho/llvm-nodebug/llvm-targetmachine.ads b/src/ortho/llvm-nodebug/llvm-targetmachine.ads index cbf074940..e753acf1d 100644 --- a/src/ortho/llvm-nodebug/llvm-targetmachine.ads +++ b/src/ortho/llvm-nodebug/llvm-targetmachine.ads @@ -99,6 +99,10 @@ package LLVM.TargetMachine is return TargetMachineRef; pragma Import (C, CreateTargetMachine, "LLVMCreateTargetMachine"); + -- Create a DataLayout based on the targetMachine. + function CreateTargetDataLayout (T : TargetMachineRef) return TargetDataRef; + pragma Import (C, CreateTargetDataLayout, "LLVMCreateTargetDataLayout"); + -- Returns the llvm::DataLayout used for this llvm:TargetMachine. function GetTargetMachineData(T : TargetMachineRef) return TargetDataRef; pragma Import (C, GetTargetMachineData, "LLVMGetTargetMachineData"); diff --git a/src/ortho/llvm-nodebug/ortho_code_main.adb b/src/ortho/llvm-nodebug/ortho_code_main.adb index b15cf782a..d5b11872a 100644 --- a/src/ortho/llvm-nodebug/ortho_code_main.adb +++ b/src/ortho/llvm-nodebug/ortho_code_main.adb @@ -195,9 +195,8 @@ begin Target_Machine := CreateTargetMachine (Target, Triple, CPU, Features, Optimization, Reloc, CodeModelDefault); - Target_Data := GetTargetMachineData (Target_Machine); - - SetDataLayout (Module, CopyStringRepOfTargetData (Target_Data)); + Target_Data := CreateTargetDataLayout (Target_Machine); + SetModuleDataLayout (Module, Target_Data); Ortho_LLVM.Init; @@ -257,7 +256,6 @@ begin Pass_Manager := CreateFunctionPassManagerForModule (Module); end if; - LLVM.Target.AddTargetData (Target_Data, Pass_Manager); AddPromoteMemoryToRegisterPass (Pass_Manager); AddCFGSimplificationPass (Pass_Manager); |