Changeset 5776


Ignore:
Timestamp:
Dec 12, 2017, 8:27:47 AM (10 months ago)
Author:
cameron
Message:

ShowPablo?=filename option

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_toolchain.cpp

    r5732 r5776  
    3131   
    3232static cl::bits<PabloDebugFlags>
    33 DebugOptions(cl::values(clEnumVal(ShowPablo, "Print generated Pablo code"),
    34                         clEnumVal(ShowOptimizedPablo, "Print optimizeed Pablo code"),
    35                         clEnumVal(VerifyPablo, "Run the Pablo verifier"),
     33DebugOptions(cl::values(clEnumVal(VerifyPablo, "Run the Pablo verifier"),
    3634                        clEnumVal(DumpTrace, "Generate dynamic traces of executed Pablo assignments.")
    3735                        CL_ENUM_VAL_SENTINEL), cl::cat(PabloOptions));
    3836   
    39 static cl::opt<std::string> PabloOutputFilename("print-pablo-output", cl::init(""), cl::desc("output Pablo filename"), cl::cat(PabloOptions));
     37std::string ShowPabloOption = codegen::OmittedOption;
     38static cl::opt<std::string, true> PabloOutputOption("ShowPablo", cl::location(ShowPabloOption), cl::ValueOptional,
     39                                                    cl::desc("Print generated Pablo code to stderr (by omitting =<filename>) or a file"), cl::value_desc("filename"), cl::cat(PabloOptions));
     40sys::fs::OpenFlags PabloOutputFileFlag = sys::fs::OpenFlags::F_None;
     41   
     42std::string ShowOptimizedPabloOption = codegen::OmittedOption;
     43static cl::opt<std::string, true> OptimizedPabloOutputOption("ShowOptimizedPablo", cl::location(ShowOptimizedPabloOption), cl::ValueOptional,
     44                                                    cl::desc("Print optimized Pablo code to stderr (by omitting =<filename>) or a file"), cl::value_desc("filename"), cl::cat(PabloOptions));
     45sys::fs::OpenFlags PabloOptimizedOutputFileFlag = sys::fs::OpenFlags::F_None;
     46
    4047static cl::opt<bool> Flatten("flatten-if", cl::init(false), cl::desc("Flatten all the Ifs in the Pablo AST"), cl::cat(PabloOptions));
    4148
     
    5158   
    5259bool CompileOptionIsSet(const PabloCompilationFlags flag) {return PabloOptimizationsOptions.isSet(flag);}
     60   
     61
    5362
    5463void pablo_function_passes(PabloKernel * kernel) {
    5564
    56     if (DebugOptions.isSet(ShowPablo)) {
     65    if (ShowPabloOption != codegen::OmittedOption) {
    5766        //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    58         errs() << "Initial Pablo AST:\n";
    59         PabloPrinter::print(kernel, errs());
     67        if (ShowPabloOption.empty()) {
     68            errs() << "Initial Pablo AST:\n";
     69            PabloPrinter::print(kernel, errs());
     70        } else {
     71            std::error_code error;
     72            llvm::raw_fd_ostream out(ShowPabloOption, error, PabloOutputFileFlag);
     73            PabloPrinter::print(kernel, out);
     74            PabloOutputFileFlag = sys::fs::OpenFlags::F_Append;   // append subsequent Pablo kernels
     75        }
    6076    }
    6177
     
    84100        SchedulingPrePass::optimize(kernel);
    85101    }
    86     if (DebugOptions.isSet(ShowOptimizedPablo)) {
    87         if (PabloOutputFilename.empty()) {
    88             //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
     102    if (ShowOptimizedPabloOption != codegen::OmittedOption) {
     103        if (ShowOptimizedPabloOption.empty()) {
     104            //Print to the terminal the final Pablo AST after optimization.
    89105            errs() << "Final Pablo AST:\n";
    90106            PabloPrinter::print(kernel, errs());
    91107        } else {
    92108            std::error_code error;
    93             llvm::raw_fd_ostream out(PabloOutputFilename, error, sys::fs::OpenFlags::F_None);
     109            llvm::raw_fd_ostream out(ShowOptimizedPabloOption, error, PabloOptimizedOutputFileFlag);
    94110            PabloPrinter::print(kernel, out);
     111            PabloOptimizedOutputFileFlag = sys::fs::OpenFlags::F_Append;  // append subsequent Pablo kernels
    95112        }
    96113    }
  • icGREP/icgrep-devel/icgrep/pablo/pablo_toolchain.h

    r5620 r5776  
    1414
    1515enum PabloDebugFlags {
    16     ShowPablo, ShowOptimizedPablo, VerifyPablo, DumpTrace,
     16    VerifyPablo, DumpTrace,
    1717};
     18extern std::string ShowOptimizedPabloOption;
     19extern std::string ShowPabloOption;
    1820
    1921enum PabloCompilationFlags {
Note: See TracChangeset for help on using the changeset viewer.