From 5577b531291fd5e8e02d2a1246d72ef7c129e3cf Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 14 Oct 2020 18:06:03 +0200 Subject: Registration of instructions, parameterized by argument types --- intel.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/intel.cpp b/intel.cpp index 471dcbf..1de2275 100644 --- a/intel.cpp +++ b/intel.cpp @@ -372,6 +372,16 @@ protected: std::vector machine_code; }; +class Op_Label: public OpSimple +{ +public: + Op_Label(const std::string& name) : OpSimple({}), m_name(name) {} + std::string name(){return m_name;} + +private: + std::string m_name; +}; + class Op_nop: public OpSimple { public: @@ -379,7 +389,24 @@ public: }; -bool registered { registerOp("nop", [](AsmArgs& args) -> std::shared_ptr{ return std::make_shared(); }) }; +template +std::string mangleNameOne(const std::string& s) +{ + return s + "_" + typeid(T).name(); +} + +template +std::string mangleName(const std::string& s) +{ + if constexpr (sizeof...(Targs) == 0) + return mangleNameOne(s); + else + return mangleName(s + "_" + typeid(T).name()); +} + +bool registered { registerOp("nop", [](AsmArgs& args) -> std::shared_ptr{ + return std::make_shared(); + }) }; class Assembler { -- cgit v1.2.3