Ignore:
Timestamp:
Jun 29, 2016, 4:25:15 PM (3 years ago)
Author:
cameron
Message:

DumpASM option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r5067 r5078  
    1515#include <llvm/ExecutionEngine/ExecutionEngine.h>
    1616#include <llvm/ExecutionEngine/MCJIT.h>
     17#include "llvm/IR/LegacyPassManager.h"
     18
    1719#include <llvm/IRReader/IRReader.h>
    1820#include <llvm/Support/CommandLine.h>
     
    3638static cl::opt<bool> DumpGeneratedIR("dump-generated-IR", cl::init(false), cl::desc("Print LLVM IR generated by Pablo Compiler."), cl::cat(CodeGenOptions));
    3739static cl::opt<std::string> IROutputFilename("dump-generated-IR-output", cl::init(""), cl::desc("output IR filename"), cl::cat(CodeGenOptions));
     40static cl::opt<bool> DumpASM("DumpASM", cl::init(false), cl::desc("Print Assembly Code."), cl::cat(CodeGenOptions));
    3841
    3942char OptLevel;
     
    7073}
    7174
     75void WriteAssembly (llvm::TargetMachine *TM, Module * m) {
     76    llvm::legacy::PassManager PM;
    7277
     78    llvm::SmallString<128> Str;
     79    llvm::raw_svector_ostream dest(Str);
     80
     81    if (TM->addPassesToEmitFile( PM , dest , llvm::TargetMachine::CGFT_AssemblyFile ) ) {
     82      std::cout << "addPassesToEmitFile failed\n";
     83      exit(1);
     84    }
     85    PM.run(*m);
     86    std::cerr << std::string( Str.c_str() ) << "\n";
     87}
    7388
    7489ExecutionEngine * JIT_to_ExecutionEngine (Module * m) {
     
    110125    }
    111126
     127    if (codegen::DumpASM) {
     128      WriteAssembly(builder.selectTarget(), m);
     129    }
    112130    ExecutionEngine * engine = builder.create();
    113131    if (engine == nullptr) {
     
    128146    }   
    129147}
     148
     149
Note: See TracChangeset for help on using the changeset viewer.