llvm-mc.cpp (218885) | llvm-mc.cpp (221337) |
---|---|
1//===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 99 unchanged lines hidden (view full) --- 108 cl::desc("Target a specific cpu type (-mcpu=help for details)"), 109 cl::value_desc("cpu-name"), 110 cl::init("")); 111 112static cl::opt<bool> 113NoInitialTextSection("n", cl::desc( 114 "Don't assume assembly file starts in the text section")); 115 | 1//===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 99 unchanged lines hidden (view full) --- 108 cl::desc("Target a specific cpu type (-mcpu=help for details)"), 109 cl::value_desc("cpu-name"), 110 cl::init("")); 111 112static cl::opt<bool> 113NoInitialTextSection("n", cl::desc( 114 "Don't assume assembly file starts in the text section")); 115 |
116static cl::opt<bool> 117SaveTempLabels("L", cl::desc( 118 "Don't discard temporary labels")); 119 |
|
116enum ActionType { 117 AC_AsLex, 118 AC_Assemble, 119 AC_Disassemble, 120 AC_EDisassemble 121}; 122 123static cl::opt<ActionType> --- 198 unchanged lines hidden (view full) --- 322 if (!TM) { 323 errs() << ProgName << ": error: could not create target for triple '" 324 << TripleName << "'.\n"; 325 return 1; 326 } 327 328 const TargetAsmInfo *tai = new TargetAsmInfo(*TM); 329 MCContext Ctx(*MAI, tai); | 120enum ActionType { 121 AC_AsLex, 122 AC_Assemble, 123 AC_Disassemble, 124 AC_EDisassemble 125}; 126 127static cl::opt<ActionType> --- 198 unchanged lines hidden (view full) --- 326 if (!TM) { 327 errs() << ProgName << ": error: could not create target for triple '" 328 << TripleName << "'.\n"; 329 return 1; 330 } 331 332 const TargetAsmInfo *tai = new TargetAsmInfo(*TM); 333 MCContext Ctx(*MAI, tai); |
334 if (SaveTempLabels) 335 Ctx.setAllowTemporaryLabels(false); |
|
330 331 OwningPtr<tool_output_file> Out(GetOutputStream()); 332 if (!Out) 333 return 1; 334 335 formatted_raw_ostream FOS(Out->os()); 336 OwningPtr<MCStreamer> Str; 337 338 const TargetLoweringObjectFile &TLOF = 339 TM->getTargetLowering()->getObjFileLowering(); 340 const_cast<TargetLoweringObjectFile&>(TLOF).Initialize(Ctx, *TM); 341 342 // FIXME: There is a bit of code duplication with addPassesToEmitFile. 343 if (FileType == OFT_AssemblyFile) { 344 MCInstPrinter *IP = | 336 337 OwningPtr<tool_output_file> Out(GetOutputStream()); 338 if (!Out) 339 return 1; 340 341 formatted_raw_ostream FOS(Out->os()); 342 OwningPtr<MCStreamer> Str; 343 344 const TargetLoweringObjectFile &TLOF = 345 TM->getTargetLowering()->getObjFileLowering(); 346 const_cast<TargetLoweringObjectFile&>(TLOF).Initialize(Ctx, *TM); 347 348 // FIXME: There is a bit of code duplication with addPassesToEmitFile. 349 if (FileType == OFT_AssemblyFile) { 350 MCInstPrinter *IP = |
345 TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI); | 351 TheTarget->createMCInstPrinter(*TM, OutputAsmVariant, *MAI); |
346 MCCodeEmitter *CE = 0; 347 TargetAsmBackend *TAB = 0; 348 if (ShowEncoding) { 349 CE = TheTarget->createCodeEmitter(*TM, Ctx); 350 TAB = TheTarget->createAsmBackend(TripleName); 351 } 352 Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true, | 352 MCCodeEmitter *CE = 0; 353 TargetAsmBackend *TAB = 0; 354 if (ShowEncoding) { 355 CE = TheTarget->createCodeEmitter(*TM, Ctx); 356 TAB = TheTarget->createAsmBackend(TripleName); 357 } 358 Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true, |
353 /*useLoc*/ true, IP, CE, TAB, | 359 /*useLoc*/ true, 360 /*useCFI*/ true, IP, CE, TAB, |
354 ShowInst)); 355 } else if (FileType == OFT_Null) { 356 Str.reset(createNullStreamer(Ctx)); 357 } else { 358 assert(FileType == OFT_ObjectFile && "Invalid file type!"); 359 MCCodeEmitter *CE = TheTarget->createCodeEmitter(*TM, Ctx); 360 TargetAsmBackend *TAB = TheTarget->createAsmBackend(TripleName); 361 Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *TAB, --- 36 unchanged lines hidden (view full) --- 398 return 1; 399 } 400 401 OwningPtr<tool_output_file> Out(GetOutputStream()); 402 if (!Out) 403 return 1; 404 405 int Res; | 361 ShowInst)); 362 } else if (FileType == OFT_Null) { 363 Str.reset(createNullStreamer(Ctx)); 364 } else { 365 assert(FileType == OFT_ObjectFile && "Invalid file type!"); 366 MCCodeEmitter *CE = TheTarget->createCodeEmitter(*TM, Ctx); 367 TargetAsmBackend *TAB = TheTarget->createAsmBackend(TripleName); 368 Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *TAB, --- 36 unchanged lines hidden (view full) --- 405 return 1; 406 } 407 408 OwningPtr<tool_output_file> Out(GetOutputStream()); 409 if (!Out) 410 return 1; 411 412 int Res; |
406 if (Enhanced) | 413 if (Enhanced) { |
407 Res = 408 Disassembler::disassembleEnhanced(TripleName, *Buffer.take(), Out->os()); | 414 Res = 415 Disassembler::disassembleEnhanced(TripleName, *Buffer.take(), Out->os()); |
409 else 410 Res = Disassembler::disassemble(*TheTarget, TripleName, | 416 } else { 417 // Package up features to be passed to target/subtarget 418 std::string FeaturesStr; 419 if (MCPU.size()) { 420 SubtargetFeatures Features; 421 Features.setCPU(MCPU); 422 FeaturesStr = Features.getString(); 423 } 424 425 // FIXME: We shouldn't need to do this (and link in codegen). 426 // When we split this out, we should do it in a way that makes 427 // it straightforward to switch subtargets on the fly (.e.g, 428 // the .cpu and .code16 directives). 429 OwningPtr<TargetMachine> TM(TheTarget->createTargetMachine(TripleName, 430 FeaturesStr)); 431 432 if (!TM) { 433 errs() << ProgName << ": error: could not create target for triple '" 434 << TripleName << "'.\n"; 435 return 1; 436 } 437 438 Res = Disassembler::disassemble(*TheTarget, *TM, TripleName, |
411 *Buffer.take(), Out->os()); | 439 *Buffer.take(), Out->os()); |
440 } |
|
412 413 // Keep output if no errors. 414 if (Res == 0) Out->keep(); 415 416 return Res; 417} 418 419 --- 32 unchanged lines hidden --- | 441 442 // Keep output if no errors. 443 if (Res == 0) Out->keep(); 444 445 return Res; 446} 447 448 --- 32 unchanged lines hidden --- |