@@ -94,6 +94,9 @@ lto::Config BitcodeCompiler::createConfig() {
94
94
WriteBitcodeToFile (m, *os, false );
95
95
return false ;
96
96
};
97
+ } else if (ctx.config .emit == EmitKind::ASM) {
98
+ c.CGFileType = CodeGenFileType::AssemblyFile;
99
+ c.Options .MCOptions .AsmVerbose = true ;
97
100
}
98
101
99
102
if (ctx.config .saveTemps )
@@ -213,6 +216,8 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
213
216
pruneCache (ctx.config .ltoCache , ctx.config .ltoCachePolicy , files);
214
217
215
218
std::vector<InputFile *> ret;
219
+ bool emitASM = ctx.config .emit == EmitKind::ASM;
220
+ const char *Ext = emitASM ? " .s" : " .obj" ;
216
221
for (unsigned i = 0 ; i != maxTasks; ++i) {
217
222
StringRef bitcodeFilePath;
218
223
// Get the native object contents either from the cache or from memory. Do
@@ -235,20 +240,21 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
235
240
if (bitcodeFilePath == " ld-temp.o" ) {
236
241
ltoObjName =
237
242
saver ().save (Twine (ctx.config .outputFile ) + " .lto" +
238
- (i == 0 ? Twine (" " ) : Twine (' .' ) + Twine (i)) + " .obj " );
243
+ (i == 0 ? Twine (" " ) : Twine (' .' ) + Twine (i)) + Ext );
239
244
} else {
240
245
StringRef directory = sys::path::parent_path (bitcodeFilePath);
241
- StringRef baseName = sys::path::filename (bitcodeFilePath);
246
+ StringRef baseName = sys::path::stem (bitcodeFilePath);
242
247
StringRef outputFileBaseName = sys::path::filename (ctx.config .outputFile );
243
248
SmallString<64 > path;
244
249
sys::path::append (path, directory,
245
- outputFileBaseName + " .lto." + baseName);
250
+ outputFileBaseName + " .lto." + baseName + Ext );
246
251
sys::path::remove_dots (path, true );
247
252
ltoObjName = saver ().save (path.str ());
248
253
}
249
- if (ctx.config .saveTemps )
254
+ if (ctx.config .saveTemps || emitASM )
250
255
saveBuffer (buf[i].second , ltoObjName);
251
- ret.push_back (make<ObjFile>(ctx, MemoryBufferRef (objBuf, ltoObjName)));
256
+ if (!emitASM)
257
+ ret.push_back (make<ObjFile>(ctx, MemoryBufferRef (objBuf, ltoObjName)));
252
258
}
253
259
254
260
return ret;
0 commit comments