@@ -39,19 +39,17 @@ class AppHack : public maiken::Application {
3939 std::string_view constexpr static base0 = " -save-temps=obj" ;
4040
4141 auto static drop_file_type (std::string filename) {
42- mkn::kul::File file{filename};
43- filename = file.name ();
42+ filename = mkn::kul::File{filename}.name ();
4443 return filename.substr (0 , filename.rfind (" ." ));
4544 }
4645
47- public:
46+ public:
4847 auto update (maiken::Source const &s) {
49- std::string arg = s.args () + std::string{base0};
48+ std::string const arg = s.args () + std::string{base0};
5049 return maiken::Source{s.in (), arg};
5150 }
5251 void hack () {
53- if (this ->main_ )
54- this ->main_ = update (*this ->main_ );
52+ if (this ->main_ ) this ->main_ = update (*this ->main_ );
5553 }
5654
5755 auto hack_link () { return drop_file_type (this ->main_ ->in ()) + " .s" ; }
@@ -60,40 +58,44 @@ class AppHack : public maiken::Application {
6058};
6159
6260class LLVM_MCA_Module : public maiken ::Module {
63- public:
64- void compile (maiken::Application &a, YAML::Node const &node)
65- KTHROW(std::exception) override {
61+ public:
62+ void compile (maiken::Application &a, YAML::Node const &node) KTHROW(std::exception) override {
6663 reinterpret_cast <AppHack *>(&a)->hack ();
6764 }
6865
69- void link (maiken::Application &a, YAML::Node const &node)
70- KTHROW(std::exception) override {
66+ void link (maiken::Application &a, YAML::Node const &node) KTHROW(std::exception) override {
7167 AppHack *hack = reinterpret_cast <AppHack *>(&a);
72- if (!hack->valid ())
73- return ;
68+ if (!hack->valid ()) return ;
7469
75- mkn::kul::Dir res{" res" , a.buildDir ()};
70+ mkn::kul::Dir const res{" res" , a.buildDir ()};
7671 res.mk ();
7772
78- mkn::kul::Dir tmp{" tmp" , a.buildDir ()};
73+ mkn::kul::Dir const tmp{" tmp" , a.buildDir ()};
7974 mkn::kul::File sss{hack->hack_link (), tmp};
8075
81- mkn::kul::Process p{" llvm-mca-14" };
76+ auto const mca_bin = [&]() -> std::string {
77+ if (node[" bin" ]) return node[" bin" ].Scalar ();
78+ return " llvm-mca" ;
79+ }();
80+ mkn::kul::Process p{mca_bin};
8281 mkn::kul::ProcessCapture pc{p};
8382 p << sss.mini ();
8483 p.start ();
8584
86- mkn::kul::File outfile{" llvm-mca.txt" , res};
85+ auto const mca_out = [&]() -> std::string {
86+ if (node[" out" ]) return node[" out" ].Scalar ();
87+ return " llvm-mca.txt" ;
88+ }();
89+
90+ mkn::kul::File const outfile{mca_out, res};
8791 mkn::kul::io::Writer{outfile} << pc.outs ();
8892 }
8993};
9094
91- } // namespace mkn::clang
95+ } // namespace mkn::clang
9296
9397extern " C" KUL_PUBLISH maiken::Module *maiken_module_construct () {
9498 return new mkn ::clang ::LLVM_MCA_Module;
9599}
96100
97- extern " C" KUL_PUBLISH void maiken_module_destruct (maiken::Module *p) {
98- delete p;
99- }
101+ extern " C" KUL_PUBLISH void maiken_module_destruct (maiken::Module *p) { delete p; }
0 commit comments