summaryrefslogtreecommitdiff
path: root/src/mir/from_hir.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-12-11 12:17:17 +0800
committerJohn Hodge <tpg@mutabah.net>2016-12-11 12:17:17 +0800
commit5f22f9f6d48411d56d9999d9a7d2c64b1aa31e73 (patch)
treea5513e62de44aa6f0a3ae37fd0ebfa0a50f54a0e /src/mir/from_hir.cpp
parentb556656fc9141c2d157b8da8fc95adaa16683e40 (diff)
downloadmrust-5f22f9f6d48411d56d9999d9a7d2c64b1aa31e73.tar.gz
Trans - Intrinsics (partially complete)
Diffstat (limited to 'src/mir/from_hir.cpp')
-rw-r--r--src/mir/from_hir.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 75ff1619..258449ef 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -1385,11 +1385,31 @@ namespace {
auto next_block = m_builder.new_bb_unlinked();
auto res = m_builder.new_temporary( node.m_res_type );
- m_builder.end_block(::MIR::Terminator::make_Call({
- next_block, panic_block,
- res.clone(), node.m_path.clone(),
- mv$(values)
- }));
+ // Emit intrinsics as a special call type
+ // TODO: Should the parameters be stored? (trans has get_lvalue_type, so no 100% needed)
+ if( node.m_path.m_data.is_Generic() )
+ {
+ const auto& gpath = node.m_path.m_data.as_Generic();
+ const auto& fcn = m_builder.crate().get_function_by_path(node.span(), gpath.m_path);
+ if( fcn.m_abi == "rust-intrinsic" )
+ {
+ m_builder.end_block(::MIR::Terminator::make_Call({
+ next_block, panic_block,
+ res.clone(), ::MIR::CallTarget::make_Intrinsic({ gpath.m_path.m_components.back(), gpath.m_params.clone() }),
+ mv$(values)
+ }));
+ }
+ }
+
+ // If the call wasn't to an intrinsic, emit it as a path
+ if( m_builder.block_active() )
+ {
+ m_builder.end_block(::MIR::Terminator::make_Call({
+ next_block, panic_block,
+ res.clone(), node.m_path.clone(),
+ mv$(values)
+ }));
+ }
m_builder.set_cur_block(panic_block);
// TODO: Proper panic handling, including scope destruction