Ignore:
Timestamp:
Nov 26, 2017, 12:09:25 PM (22 months ago)
Author:
cameron
Message:

ShowIR, ShowASM, ShowUnoptimizedIR options can set filename: -ShowIR=myIRfile

Location:
icGREP/icgrep-devel/icgrep/toolchain
Files:
3 edited

Legend:

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

    r5735 r5745  
    148148
    149149    legacy::PassManager PM;
    150     if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::ShowUnoptimizedIR))) {
     150    if (LLVM_UNLIKELY(codegen::ShowUnoptimizedIROption != codegen::OmittedOption)) {
    151151        if (LLVM_LIKELY(mIROutputStream == nullptr)) {
    152             if (codegen::IROutputFilename) {
     152            if (codegen::ShowUnoptimizedIROption != "") {
    153153                std::error_code error;
    154                 mIROutputStream = new raw_fd_ostream(codegen::IROutputFilename, error, sys::fs::OpenFlags::F_None);
     154                mIROutputStream = new raw_fd_ostream(codegen::ShowUnoptimizedIROption, error, sys::fs::OpenFlags::F_None);
    155155            } else {
    156156                mIROutputStream = new raw_fd_ostream(STDERR_FILENO, false, true);
     
    170170    PM.add(createCFGSimplificationPass());          // Repeat CFG Simplification to "clean up" any newly found redundant phi nodes
    171171
    172     if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::ShowIR))) {
     172    if (LLVM_UNLIKELY(codegen::ShowIROption != codegen::OmittedOption)) {
    173173        if (LLVM_LIKELY(mIROutputStream == nullptr)) {
    174             if (codegen::IROutputFilename) {
     174            if (codegen::ShowIROption != "") {
    175175                std::error_code error;
    176                 mIROutputStream = new raw_fd_ostream(codegen::IROutputFilename, error, sys::fs::OpenFlags::F_None);
     176                mIROutputStream = new raw_fd_ostream(codegen::ShowIROption, error, sys::fs::OpenFlags::F_None);
    177177            } else {
    178178                mIROutputStream = new raw_fd_ostream(STDERR_FILENO, false, true);
     
    183183
    184184#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
    185     if (LLVM_UNLIKELY(codegen::DebugOptionIsSet(codegen::ShowASM))) {
    186         if (codegen::ASMOutputFilename) {
     185    if (LLVM_UNLIKELY(codegen::ShowASMOption != codegen::OmittedOption)) {
     186        if (codegen::ShowASMOption != "") {
    187187            std::error_code error;
    188             mASMOutputStream = new raw_fd_ostream(codegen::ASMOutputFilename, error, sys::fs::OpenFlags::F_None);
     188            mASMOutputStream = new raw_fd_ostream(codegen::ShowASMOption, error, sys::fs::OpenFlags::F_None);
    189189        } else {
    190190            mASMOutputStream = new raw_fd_ostream(STDERR_FILENO, false, true);
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.cpp

    r5738 r5745  
    2323
    2424static cl::bits<DebugFlags>
    25 DebugOptions(cl::values(clEnumVal(ShowUnoptimizedIR, "Print generated LLVM IR."),
    26                         clEnumVal(ShowIR, "Print optimized LLVM IR."),
    27                         clEnumVal(VerifyIR, "Run the IR verification pass."),
    28 #if LLVM_VERSION_INTEGER >= LLVM_3_7_0
    29                         clEnumVal(ShowASM, "Print assembly code."),
    30 #endif
     25DebugOptions(cl::values(clEnumVal(VerifyIR, "Run the IR verification pass."),
    3126                        clEnumVal(SerializeThreads, "Force segment threads to run sequentially."),
    3227                        clEnumVal(TraceCounts, "Show kernel processed and produced item counts."),
     
    3631                        CL_ENUM_VAL_SENTINEL), cl::cat(CodeGenOptions));
    3732
    38 static cl::opt<std::string> IROutputFilenameOption("dump-generated-IR-output", cl::init(""),
    39                                                        cl::desc("output IR filename"), cl::cat(CodeGenOptions));
     33std::string ShowIROption = OmittedOption;
     34static cl::opt<std::string, true> IROutputOption("ShowIR", cl::location(ShowIROption), cl::ValueOptional,
     35                                                         cl::desc("Print optimized LLVM IR to stderr (by omitting =<filename>) or a file"), cl::value_desc("filename"), cl::cat(CodeGenOptions));
     36
     37std::string ShowUnoptimizedIROption = OmittedOption;
     38static cl::opt<std::string, true> UnoptimizedIROutputOption("ShowUnoptimizedIR", cl::location(ShowUnoptimizedIROption), cl::ValueOptional,
     39                                                         cl::desc("Print generated LLVM IR to stderr (by omitting =<filename> or a file"), cl::value_desc("filename"), cl::cat(CodeGenOptions));
    4040
    4141#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
    42 static cl::opt<std::string> ASMOutputFilenameOption("asm-output", cl::init(""),
    43                                                     cl::desc("output ASM filename"), cl::cat(CodeGenOptions));
    44 
    45 static cl::opt<bool> AsmVerbose("asm-verbose", cl::init(true),
    46                                 cl::desc("Add comments to directives."), cl::cat(CodeGenOptions));
     42std::string ShowASMOption = OmittedOption;
     43static cl::opt<std::string, true> ASMOutputFilenameOption("ShowASM", cl::location(ShowASMOption), cl::ValueOptional,
     44                                                         cl::desc("Print generated assembly code to stderr (by omitting =<filename> or a file"), cl::value_desc("filename"), cl::cat(CodeGenOptions));
    4745#endif
    4846
     
    9088
    9189bool SegmentPipelineParallel;
    92 
    93 const char * ASMOutputFilename;
    94 
    95 const char * IROutputFilename;
    9690
    9791const char * ObjectCacheDir;
     
    160154#endif
    161155    cl::ParseCommandLineOptions(argc, argv);
    162     if (DebugOptions.getBits()) {
     156    if (DebugOptions.getBits() || (ShowIROption != OmittedOption) || (ShowUnoptimizedIROption != OmittedOption) || (ShowASMOption != OmittedOption)) {
    163157        EnableObjectCache = false;
    164158    }
    165159    ObjectCacheDir = ObjectCacheDirOption.empty() ? nullptr : ObjectCacheDirOption.data();
    166     IROutputFilename = IROutputFilenameOption.empty() ? nullptr : IROutputFilenameOption.data();
    167     ASMOutputFilename = ASMOutputFilenameOption.empty() ? nullptr : ASMOutputFilenameOption.data();
    168160    Options = InitTargetOptionsFromCodeGenFlags();
    169161#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
    170     Options.MCOptions.AsmVerbose = AsmVerbose;
     162    Options.MCOptions.AsmVerbose = true;
    171163#endif
    172164    switch (OptLevelOption) {
  • icGREP/icgrep-devel/icgrep/toolchain/toolchain.h

    r5734 r5745  
    4242// Command Parameters
    4343enum DebugFlags {
    44     ShowUnoptimizedIR,
    45     ShowIR,
    4644    VerifyIR,
    47 #if LLVM_VERSION_INTEGER >= LLVM_3_7_0
    48     ShowASM,
    49 #endif
    5045    SerializeThreads,
    5146    TraceCounts,
     
    6055extern bool PipelineParallel;
    6156extern bool SegmentPipelineParallel;
     57   
     58// Options for generating IR or ASM to files
     59const std::string OmittedOption = ".";
     60extern std::string ShowUnoptimizedIROption;
     61extern std::string ShowIROption;
    6262#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
    63 extern const char * ASMOutputFilename;
     63extern std::string ShowASMOption;
    6464#endif
    65 extern const char * IROutputFilename;
    6665extern const char * ObjectCacheDir;
    6766extern llvm::CodeGenOpt::Level OptLevel;  // set from command line
Note: See TracChangeset for help on using the changeset viewer.