From d07c5bc14edbe071ee7b4f47f174780e95e451aa Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 15 Nov 2020 13:55:18 +0100 Subject: Simplify Asm construction --- asm/intel64/encode.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'asm/intel64/encode.cpp') diff --git a/asm/intel64/encode.cpp b/asm/intel64/encode.cpp index b26bf9c..123dff2 100644 --- a/asm/intel64/encode.cpp +++ b/asm/intel64/encode.cpp @@ -96,8 +96,16 @@ void Asm::toMachineCode(const FlowGraph::Graph& graph, Segment& segment) else throw std::runtime_error("ICE: Asm: Unsupported binary operation type: "s + std::to_string(static_cast(op.type()))); + } else if (typeid(node_deref) == typeid(FlowGraph::CreateScopeOp)) { + //FlowGraph::CreateScopeOp& op {dynamic_cast(*node)}; + segment.push_back(makeOp("push", Asm::Args{{Asm::Args::Register64("rbp")}})); + segment.push_back(makeOp("mov", Asm::Args{{Asm::Args::Register64("rbp"), Asm::Args::Register64("rsp")}})); + + } else if (typeid(node_deref) == typeid(FlowGraph::DestroyScopeOp)) { + //FlowGraph::DestroyScopeOp& op {dynamic_cast(*node)}; + segment.push_back(makeOp("pop", Asm::Args{{Asm::Args::Register64("rbp")}})); } else { - throw std::runtime_error("ICE: Encoding: Unsupported node"); + throw std::runtime_error("ICE: Encoding: Unsupported node: "s + demangle(typeid(node_deref))); } } else { throw std::runtime_error("ICE: encode: flowgraph node is null"); -- cgit v1.2.3