diff --git a/test/Pipeline/warpforthc-options.forth b/test/Pipeline/warpforthc-options.forth new file mode 100644 index 0000000..2a20e58 --- /dev/null +++ b/test/Pipeline/warpforthc-options.forth @@ -0,0 +1,12 @@ +\ RUN: %warpforthc -O3 --features=+ptx70 --mlir-print-ir-after-all --mlir-disable-threading %s -o %t.ptx 2>&1 | %FileCheck %s +\ RUN: %warpforthc --opt-level=0 --arch sm_80 --mlir-print-ir-after-all --mlir-disable-threading %s -o %t.ptx 2>&1 | %FileCheck %s --check-prefix=O0 +\ RUN: %warpforthc --features=+ptx70 %s -o - | %FileCheck %s --check-prefix=PTX +\ RUN: %not %warpforthc -O4 %s -o %t.ptx 2>&1 | %FileCheck %s --check-prefix=BAD-OPT + +\! kernel main +42 + +\ CHECK: #nvvm.target targetArchitecture("arch", llvm::cl::desc("GPU architecture"), llvm::cl::value_desc("sm_XX"), llvm::cl::init("sm_70")); +static llvm::cl::opt + optLevel("O", llvm::cl::desc("Optimization level (0, 1, 2, or 3)"), + llvm::cl::value_desc("level"), llvm::cl::Prefix, + llvm::cl::init("")); +static llvm::cl::alias optLevelAlias("opt-level", + llvm::cl::desc("Alias for -O"), + llvm::cl::aliasopt(optLevel)); + +static llvm::cl::opt + targetFeatures("features", llvm::cl::desc("NVVM target features"), + llvm::cl::value_desc("+ptxNN"), llvm::cl::init("")); + +static llvm::cl::opt + libdevicePath("libdevice", llvm::cl::desc("Path to the libdevice bitcode"), + llvm::cl::value_desc("path"), llvm::cl::init("")); + int main(int argc, char **argv) { llvm::InitLLVM y(argc, argv); warpforth::registerConversionPasses(); @@ -85,6 +102,16 @@ int main(int argc, char **argv) { if (failed(applyPassManagerCLOptions(pm))) return 1; warpforth::WarpForthPipelineOptions pipelineOptions; + std::string overrides; + llvm::raw_string_ostream overridesOS(overrides); + if (!optLevel.empty()) + overridesOS << " opt-level=" << optLevel; + if (!targetFeatures.empty()) + overridesOS << " features=" << targetFeatures; + if (!libdevicePath.empty()) + overridesOS << " libdevice=" << libdevicePath; + if (failed(pipelineOptions.parseFromString(overrides))) + return 1; pipelineOptions.chip = targetArchitecture.getValue(); warpforth::buildWarpForthPipeline(pm, pipelineOptions); if (failed(pm.run(*module)))