summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-10-14 18:06:03 +0200
committerRoland Reichwein <mail@reichwein.it>2020-10-14 18:06:03 +0200
commit5577b531291fd5e8e02d2a1246d72ef7c129e3cf (patch)
treeda264dd58cb197773ee8bf8d77760ef0510a97cd
parent29b57bfa7c2c7b3297e88c66ad9e45a5979844a8 (diff)
Registration of instructions, parameterized by argument types
-rw-r--r--intel.cpp29
1 files changed, 28 insertions, 1 deletions
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<uint8_t> 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<Op>{ return std::make_shared<Op_nop>(); }) };
+template<typename T>
+std::string mangleNameOne(const std::string& s)
+{
+ return s + "_" + typeid(T).name();
+}
+
+template<typename T, typename... Targs>
+std::string mangleName(const std::string& s)
+{
+ if constexpr (sizeof...(Targs) == 0)
+ return mangleNameOne<T>(s);
+ else
+ return mangleName<Targs...>(s + "_" + typeid(T).name());
+}
+
+bool registered { registerOp("nop", [](AsmArgs& args) -> std::shared_ptr<Op>{
+ return std::make_shared<Op_nop>();
+ }) };
class Assembler {