-
Notifications
You must be signed in to change notification settings - Fork 174
QAT refactor #1131
QAT refactor #1131
Changes from all commits
fd1a5ed
316272b
893407c
ec3c877
4ae8a93
f0dc513
5ac1088
2f71437
8615017
8c65c37
d11281e
00d0e59
3677b69
49c4ea2
2fac7db
3207a7b
7a91387
6f56454
3050f9c
08b6a2a
309a498
d5ae180
2ac2419
b1703d9
643a278
2027fbb
61f54cc
24b496f
06cad4c
6f8f790
4964a02
f360ce0
d3a7f68
517e1f0
12dc452
4a2d09e
eb542f1
69bc4cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,5 +109,4 @@ message(STATUS "${llvm_libs}") | |
|
|
||
| # Adding the libraries | ||
| add_subdirectory(Source) | ||
| add_subdirectory(tests) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # QIR Passes | ||
|
|
||
| This document contains a brief introduction on how to use the QIR passes. A more comprehensive [walk-through is found here](./docs/src/index.md). | ||
|
|
||
| ## Building | ||
|
|
||
| To build the tool, create a new build directory and switch to that directory: | ||
|
|
||
| ```sh | ||
| mkdir Debug | ||
| cd Debug/ | ||
| ``` | ||
|
|
||
| To build the library, first configure CMake from the build directory | ||
|
|
||
| ```sh | ||
| cmake .. | ||
| ``` | ||
|
|
||
| and then make your target | ||
|
|
||
| ```sh | ||
| make qat | ||
| ``` | ||
|
|
||
| For full instructions on dependencies and how to build, follow [these instructions](./docs/src/DeveloperGuide/Building.md). | ||
|
|
||
| ## Getting started | ||
|
|
||
| Once the project is built (see next sections), you can transform a QIR according to a profile as follows: | ||
|
|
||
| ```sh | ||
| ./Source/Apps/qat --generate --profile baseProfile -S ../examples/QirAllocationAnalysis/analysis-example.ll | ||
| ``` | ||
|
|
||
| Likewise, you can validate that a QIR follows a specification by running (Note, not implemented yet): | ||
|
|
||
| ```sh | ||
| ./Source/Apps/qat --validate --profile baseProfile -S ../examples/QirAllocationAnalysis/analysis-example.ll | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| Most of the documentation is available [directly on Github](./docs/src/index.md). If you need API documentation, you can build and run it by typing | ||
|
|
||
| ```sh | ||
| make serve-docs | ||
| ``` | ||
|
|
||
| in the root folder of the passes directory. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| add_executable(qat Qat/Qat.cpp Qat/LlvmAnalysis.cpp) | ||
|
|
||
| target_link_libraries(qat ${llvm_libs}) | ||
| target_link_libraries(qat ExpandStaticAllocation QirAllocationAnalysis TransformationRule Rules AllocationManager Commandline Profiles) | ||
| target_link_libraries(qat ProfilePass Rules AllocationManager Commandline Profiles) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| #include "Commandline/Settings.hpp" | ||
| #include "Profiles/BaseProfile.hpp" | ||
| #include "Profiles/IProfile.hpp" | ||
| #include "Profiles/RuleSetProfile.hpp" | ||
|
|
||
| #include "Llvm/Llvm.hpp" | ||
|
|
||
|
|
@@ -35,14 +36,24 @@ int main(int argc, char** argv) | |
| {{"debug", "false"}, | ||
| {"generate", "false"}, | ||
| {"validate", "false"}, | ||
| {"profile", "base-profile"}, | ||
| {"S", "false"}}}; | ||
| {"profile", "baseProfile"}, | ||
| {"S", "false"}, | ||
| {"O0", "false"}, | ||
| {"O1", "false"}, | ||
| {"O2", "false"}, | ||
| {"O3", "false"}, | ||
| {"verify-module", "false"}}}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What exactly does verify-module do?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It verifies the module (that the IR is valid) once the transformation was ran.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this using built-in llvm infrastructure only or is there anything custom about it? I believe it is the former. |
||
|
|
||
| ParameterParser parser(settings); | ||
| parser.addFlag("debug"); | ||
| parser.addFlag("generate"); | ||
| parser.addFlag("validate"); | ||
| parser.addFlag("verify-module"); | ||
| parser.addFlag("S"); | ||
| parser.addFlag("O0"); | ||
| parser.addFlag("O1"); | ||
| parser.addFlag("O2"); | ||
| parser.addFlag("O3"); | ||
|
|
||
| parser.parseArgs(argc, argv); | ||
|
|
||
|
|
@@ -64,11 +75,27 @@ int main(int argc, char** argv) | |
| } | ||
|
|
||
| // Extracting commandline parameters | ||
| bool debug = settings.get("debug") == "true"; | ||
| bool generate = settings.get("generate") == "true"; | ||
| bool validate = settings.get("validate") == "true"; | ||
| auto optimisation_level = llvm::PassBuilder::OptimizationLevel::O1; | ||
| std::shared_ptr<BaseProfile> profile = std::make_shared<BaseProfile>(); | ||
| bool debug = settings.get("debug") == "true"; | ||
| bool generate = settings.get("generate") == "true"; | ||
| bool validate = settings.get("validate") == "true"; | ||
| auto optimisation_level = llvm::PassBuilder::OptimizationLevel::O0; | ||
| std::shared_ptr<IProfile> profile = std::make_shared<BaseProfile>(); | ||
|
|
||
| // Setting the optimisation level | ||
| if (settings.get("O1") == "true") | ||
| { | ||
| optimisation_level = llvm::PassBuilder::OptimizationLevel::O1; | ||
| } | ||
|
|
||
| if (settings.get("O2") == "true") | ||
| { | ||
| optimisation_level = llvm::PassBuilder::OptimizationLevel::O2; | ||
| } | ||
|
|
||
| if (settings.get("O3") == "true") | ||
| { | ||
| optimisation_level = llvm::PassBuilder::OptimizationLevel::O3; | ||
| } | ||
|
|
||
| // In case we debug, we also print the settings to allow provide a full | ||
| // picture of what is going. | ||
|
|
@@ -103,6 +130,19 @@ int main(int argc, char** argv) | |
| llvm::errs() << "Byte code ouput is not supported yet. Please add -S to get human readible " | ||
| "LL code.\n"; | ||
| } | ||
|
|
||
| // Verifying the module. | ||
| if (settings.get("verify-module") == "true") | ||
| { | ||
| llvm::VerifierAnalysis verifier; | ||
| auto result = verifier.run(*module, analyser.moduleAnalysisManager()); | ||
| if (result.IRBroken) | ||
| { | ||
| llvm::errs() << "IR is broken." | ||
| << "\n"; | ||
| exit(-1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (validate) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,15 +8,18 @@ microsoft_add_library(Commandline) | |
| microsoft_add_library(AllocationManager) | ||
| microsoft_add_library_tests(AllocationManager) | ||
|
|
||
| microsoft_add_library(ProfilePass) | ||
| target_link_libraries(ProfilePass PRIVATE Rules) | ||
| # microsoft_add_library_tests(ProfilePass) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this not enabled?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not have any tests for this component yet aside from the running the examples. All the functionality that does the transformation is tested in the profiles test.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation. I assume these are the tests that you wanted to add next week. |
||
|
|
||
|
|
||
| microsoft_add_library(Rules) | ||
| microsoft_add_library_tests(Rules ExpandStaticAllocation QirAllocationAnalysis TransformationRule Rules AllocationManager Commandline Profiles) | ||
| microsoft_add_library_tests(Rules Rules ProfilePass AllocationManager Commandline Profiles) | ||
|
|
||
| target_link_libraries(Rules PRIVATE AllocationManager) | ||
|
|
||
| add_subdirectory(Passes) | ||
|
|
||
| microsoft_add_library(Profiles) | ||
| target_link_libraries(Profiles PRIVATE Rules ExpandStaticAllocation TransformationRule QirAllocationAnalysis) | ||
| microsoft_add_library_tests(Profiles ExpandStaticAllocation QirAllocationAnalysis TransformationRule Rules AllocationManager Commandline Profiles) | ||
| target_link_libraries(Profiles PRIVATE Rules) | ||
| microsoft_add_library_tests(Profiles Rules AllocationManager Commandline Profiles) | ||
|
|
||
| add_subdirectory(Apps) | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.