diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-11-15 13:55:18 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-11-15 13:55:18 +0100 |
commit | d07c5bc14edbe071ee7b4f47f174780e95e451aa (patch) | |
tree | 889ed88ea6907119b75b7b76f616a604c9857e3d /asm/intel64/encode.cpp | |
parent | 9e7f4c9d43b310c280cd6432cd4150411f4b914e (diff) |
Simplify Asm construction
Diffstat (limited to 'asm/intel64/encode.cpp')
-rw-r--r-- | asm/intel64/encode.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
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<int>(op.type()))); + } else if (typeid(node_deref) == typeid(FlowGraph::CreateScopeOp)) { + //FlowGraph::CreateScopeOp& op {dynamic_cast<FlowGraph::CreateScopeOp&>(*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<FlowGraph::DestroyScopeOp&>(*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"); |