diff options
Diffstat (limited to 'tools/llc/llc.cpp')
-rw-r--r-- | tools/llc/llc.cpp | 104 |
1 files changed, 34 insertions, 70 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 378cc63..f3eed56 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -119,7 +119,8 @@ GetFileNameRoot(const std::string &InputFilename) { return outputFilename; } -static formatted_raw_ostream *GetOutputStream(const char *TargetName, +static formatted_raw_ostream *GetOutputStream(const char *TargetName, + Triple::OSType OS, const char *ProgName) { if (OutputFilename != "") { if (OutputFilename == "-") @@ -166,7 +167,10 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName, OutputFilename += ".s"; break; case TargetMachine::CGFT_ObjectFile: - OutputFilename += ".o"; + if (OS == Triple::Win32) + OutputFilename += ".obj"; + else + OutputFilename += ".o"; Binary = true; break; case TargetMachine::CGFT_Null: @@ -284,7 +288,8 @@ int main(int argc, char **argv) { TargetMachine &Target = *target.get(); // Figure out where we are going to send the output... - formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), argv[0]); + formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), + TheTriple.getOS(), argv[0]); if (Out == 0) return 1; CodeGenOpt::Level OLvl = CodeGenOpt::Default; @@ -307,75 +312,34 @@ int main(int argc, char **argv) { bool DisableVerify = true; #endif - // If this target requires addPassesToEmitWholeFile, do it now. This is - // used by strange things like the C backend. - if (Target.WantsWholeFile()) { - PassManager PM; - - // Add the target data from the target machine, if it exists, or the module. - if (const TargetData *TD = Target.getTargetData()) - PM.add(new TargetData(*TD)); - else - PM.add(new TargetData(&mod)); - - if (!NoVerify) - PM.add(createVerifierPass()); - - // Ask the target to add backend passes as necessary. - if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl, - DisableVerify)) { - errs() << argv[0] << ": target does not support generation of this" - << " file type!\n"; - if (Out != &fouts()) delete Out; - // And the Out file is empty and useless, so remove it now. - sys::Path(OutputFilename).eraseFromDisk(); - return 1; - } - PM.run(mod); - } else { - // Build up all of the passes that we want to do to the module. - FunctionPassManager Passes(M.get()); - - // Add the target data from the target machine, if it exists, or the module. - if (const TargetData *TD = Target.getTargetData()) - Passes.add(new TargetData(*TD)); - else - Passes.add(new TargetData(&mod)); - -#ifndef NDEBUG - if (!NoVerify) - Passes.add(createVerifierPass()); -#endif - - // Override default to generate verbose assembly. - Target.setAsmVerbosityDefault(true); - - if (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl, - DisableVerify)) { - errs() << argv[0] << ": target does not support generation of this" - << " file type!\n"; - if (Out != &fouts()) delete Out; - // And the Out file is empty and useless, so remove it now. - sys::Path(OutputFilename).eraseFromDisk(); - return 1; - } - - Passes.doInitialization(); - - // Run our queue of passes all at once now, efficiently. - // TODO: this could lazily stream functions out of the module. - for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I) - if (!I->isDeclaration()) { - if (DisableRedZone) - I->addFnAttr(Attribute::NoRedZone); - if (NoImplicitFloats) - I->addFnAttr(Attribute::NoImplicitFloat); - Passes.run(*I); - } - - Passes.doFinalization(); + // Build up all of the passes that we want to do to the module. + PassManager PM; + + // Add the target data from the target machine, if it exists, or the module. + if (const TargetData *TD = Target.getTargetData()) + PM.add(new TargetData(*TD)); + else + PM.add(new TargetData(&mod)); + + if (!NoVerify) + PM.add(createVerifierPass()); + + // Override default to generate verbose assembly. + Target.setAsmVerbosityDefault(true); + + // Ask the target to add backend passes as necessary. + if (Target.addPassesToEmitFile(PM, *Out, FileType, OLvl, + DisableVerify)) { + errs() << argv[0] << ": target does not support generation of this" + << " file type!\n"; + if (Out != &fouts()) delete Out; + // And the Out file is empty and useless, so remove it now. + sys::Path(OutputFilename).eraseFromDisk(); + return 1; } + PM.run(mod); + // Delete the ostream if it's not a stdout stream if (Out != &fouts()) delete Out; |