comparison dang/compiler.d @ 97:198ad05f3ace new_gen

"-c" as argument now generates out.o (only works on linux now)
author Anders Johnsen <skabet@gmail.com>
date Tue, 06 May 2008 21:28:05 +0200
parents 48bb2287c035
children 5f258eaf9517
comparison
equal deleted inserted replaced
96:438e6ed4cda1 97:198ad05f3ace
25 import sema.Visitor, 25 import sema.Visitor,
26 sema.AstAction, 26 sema.AstAction,
27 sema.ScopeBuilder, 27 sema.ScopeBuilder,
28 sema.ScopeCheck, 28 sema.ScopeCheck,
29 sema.TypeCheck; 29 sema.TypeCheck;
30
31 import tango.stdc.posix.unistd;
30 32
31 import Opt = dang.OptParse; 33 import Opt = dang.OptParse;
32 34
33 void checkFiles(char[][] *files) 35 void checkFiles(char[][] *files)
34 { 36 {
150 else if (what == "compile") 152 else if (what == "compile")
151 postParse.attach( 153 postParse.attach(
152 (Module m, SourceManager sm) { 154 (Module m, SourceManager sm) {
153 StopWatch w; w.start; 155 StopWatch w; w.start;
154 auto llvmGen = new CodeGen(); 156 auto llvmGen = new CodeGen();
155 auto llc = new Process("llc"); 157 auto llc = new Process("llc","-o=-");
156 llvmGen.gen(m, llc.stdin.fileHandle, optimize, inline); 158 auto gcc = new Process("gcc","-c","-o","out.o","-x","assembler","-");
159 llc.execute();
160 int i = dup(llc.stdin.fileHandle);
161 llc.stdin.detach;
162 llvmGen.gen(m, i, optimize, inline);
163 llc.wait();
164 gcc.execute();
165 gcc.stdin.copy(llc.stdout);
166 gcc.stdin.detach;
167 gcc.wait();
168
157 timings ~= Measurement("Generating assemble bytecode", w.stop); 169 timings ~= Measurement("Generating assemble bytecode", w.stop);
158 }); 170 });
159 else if (what == "dot") 171 else if (what == "dot")
160 postParse.attach( 172 postParse.attach(
161 (Module m, SourceManager sm) { 173 (Module m, SourceManager sm) {