authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2015-11-29 11:12:40-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2015-11-29 11:12:40-07:00
log855d51840dbb14888b4a727c495e01f96027985a
tree03b7c52c0bf4c7ca455149261ed960577a7773e4
parente5d1f0eea592e6efc4c4665eb473de95ef106e8a

remove LLVMZigTargetMachineEmitToFile

The llvm C API provided function is adequate.

4 files changed, 3 insertions(+), 57 deletions(-)

README.md+2-1
......@@ -42,9 +42,10 @@ make
4242
4343## Roadmap
4444
45 * Math expression
45 * variables and parameters
4646 * Export .so library
4747 * Multiple files
48 * Type checking
4849 * inline assembly and syscalls
4950 * running code at compile time
5051 * print! macro that takes var args
src/codegen.cpp+1-1
......@@ -1313,7 +1313,7 @@ void code_gen_link(CodeGen *g, const char *out_file) {
13131313 }
13141314
13151315 char *err_msg = nullptr;
1316 if (LLVMZigTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&out_file_o),
1316 if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&out_file_o),
13171317 LLVMObjectFile, &err_msg))
13181318 {
13191319 zig_panic("unable to write object file: %s", err_msg);
src/zig_llvm.cpp-52
......@@ -115,58 +115,6 @@ void LLVMZigOptimizeModule(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef
115115 MPM->run(*module);
116116}
117117
118static LLVMBool LLVMZigTargetMachineEmit(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref,
119 raw_pwrite_stream &out_stream, LLVMCodeGenFileType codegen, char **err_msg)
120{
121 TargetMachine* target_machine = reinterpret_cast<TargetMachine*>(targ_machine_ref);
122 Module* module = unwrap(module_ref);
123 TargetLibraryInfoImpl tlii(Triple(module->getTargetTriple()));
124
125 legacy::PassManager pass;
126
127 pass.add(new TargetLibraryInfoWrapperPass(tlii));
128
129 const DataLayout *td = target_machine->getDataLayout();
130
131 if (!td) {
132 *err_msg = strdup("No DataLayout in TargetMachine");
133 return true;
134 }
135 module->setDataLayout(*td);
136
137
138 TargetMachine::CodeGenFileType ft;
139 switch (codegen) {
140 case LLVMAssemblyFile:
141 ft = TargetMachine::CGFT_AssemblyFile;
142 break;
143 default:
144 ft = TargetMachine::CGFT_ObjectFile;
145 break;
146 }
147 if (target_machine->addPassesToEmitFile(pass, out_stream, ft)) {
148 *err_msg = strdup("TargetMachine can't emit a file of this type");
149 return true;
150 }
151
152 pass.run(*module);
153
154 out_stream.flush();
155 return false;
156}
157
158LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref,
159 const char* filename, LLVMCodeGenFileType codegen, char** err_msg)
160{
161 std::error_code error_code;
162 raw_fd_ostream dest(filename, error_code, sys::fs::F_None);
163 if (error_code) {
164 *err_msg = strdup(error_code.message().c_str());
165 return true;
166 }
167 return LLVMZigTargetMachineEmit(targ_machine_ref, module_ref, dest, codegen, err_msg);
168}
169
170118LLVMValueRef LLVMZigBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args,
171119 unsigned NumArgs, unsigned CC, const char *Name)
172120{
src/zig_llvm.hpp-3
......@@ -21,9 +21,6 @@ void LLVMZigInitializeUnreachableBlockElimPass(LLVMPassRegistryRef R);
2121char *LLVMZigGetHostCPUName(void);
2222char *LLVMZigGetNativeFeatures(void);
2323
24LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef target_machine, LLVMModuleRef module,
25 const char* filename, LLVMCodeGenFileType codegen, char** error_msg);
26
2724void LLVMZigOptimizeModule(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref);
2825
2926LLVMValueRef LLVMZigBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args,