diff --git a/include/mc_inst.h b/include/mc_inst.h index cde97d6..8dce4aa 100644 --- a/include/mc_inst.h +++ b/include/mc_inst.h @@ -207,9 +207,11 @@ public: class MCModule { public: + std::string file_name; std::list function_list; std::list global_list; void IR2MC(const Module &ir_module); + void MC2ASM(std::ostream& ostr); }; class MInstBinary : public MInst { diff --git a/src/main.cpp b/src/main.cpp index 0411bf7..fe7a20f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,6 +128,7 @@ int main(int argc, const char **argv) { // std::cout << tree->toStringTree(&parser) << std::endl << std::endl; MCModule mc_module; + mc_module.file_name = source_file; mc_module.IR2MC(visitor.module); std::vector mc_passes = {std::make_shared()}; for (auto pass : mc_passes) { diff --git a/src/mc_asmgen.cpp b/src/mc_asmgen.cpp index 0d2ecb6..8387a69 100644 --- a/src/mc_asmgen.cpp +++ b/src/mc_asmgen.cpp @@ -1,3 +1,15 @@ #include "mc_inst.h" #include "common.h" +namespace CompSysY { + + +void MCModule::MC2ASM(std::ostream &ostr) { + // header, specifying align and arch + ostr << "\t.text\n" << "\t.attribute\t4,\t16\n" + << "\t.attribute\t5\t\"rv64i2p0_m2p0_f2p0_d2p0\"\n"; + ostr << "\t.file\t\"" << this->file_name << "\"\n" << std::endl; + +} + +} \ No newline at end of file